Blinds with Home Assistant (part two)
In the previous post, we saw how you can use Node-RED to control RF 433Mhz roller blinds via Home Assistant using a Broadlink unit.
The next step is to make it properly clickable from the Lovelace UI, without having to open a Node-RED UI.
The first step is to created an template (emulated) cover entity. In this example, I generate two entities for blinds operating on two different channels (in file configuration.yaml
):
cover: - platform: template covers: roller_blinds_chan1: device_class: blind friendly_name: "Roller blinds (Bedroom)" unique_id: "roller_blinds_chan1" position_template: 50 open_cover: service: script.open_roller_blinds_chan1 close_cover: service: script.close_roller_blinds_chan1 stop_cover: service: script.stop_roller_blinds_chan1 roller_blinds_chan2: device_class: blind friendly_name: "Roller blinds (Office)" unique_id: "roller_blinds_chan2" position_template: 50 open_cover: service: script.open_roller_blinds_chan2 close_cover: service: script.close_roller_blinds_chan2 stop_cover: service: script.stop_roller_blinds_chan2
NB: since these roller blinds don’t provide open/closed feedback (it’s one-way communication), we use position_template: 50
to tell Home Assistant that the blind is always halfway, which means that open/close/stop buttons are always available to be pressed. Furthermore, by using unique_id
, your entity will be added to the registry in Home Assistant so that you can (among other things) add it to an area.
Next, create dummy scripts for these service calls (inspiration taken from Bonanitech) in file scripts.yaml
:
- open_roller_blinds_chan1: sequence: - close_roller_blinds_chan1: sequence: - stop_roller_blinds_chan1: sequence: - open_roller_blinds_chan2: sequence: - close_roller_blinds_chan2: sequence: - stop_roller_blinds_chan2: sequence:
Now you should have roller blinds in your Lovelace that you can click but will not do anything at the moment.
Following Bonanitech’s example, we will now change our Node-RED flow to listen to these events. I had to tweak it a little bit in order to get it working, so my approach differs slightly.
The node on the top-left is an “events: all” node. Its Event Type is “call_service” (this is unchanged from Bonanitech’s example). The first switch in the flow checks on the property payload.event.service_data.entity_id
and matches the condition cover.roller_blinds_chan1
:
This check, however, does not yet tell us what operation was executed. For that we need to check a different field; the next switch checks property payload.event.service
and has as first condition close_cover
and as second condition open_cover
:
This should already be enough to get you a working setup.
There is one more (unrelated) change I made since my previous post. Sometimes the RF signal doesn’t come through to the blinds the first time. Therefore, I’ve made use of the “looptimer” node to send the RF commands a couple of times in quick succession to make sure at least one signal comes through. The looptimer is the “2 Second Loop” node that you see in the above Node-RED screenshot. The self-explanatory properties I’ve configured are: