Hi all,
I have a bunch of Etekcity switches that I have set up like this:
- platform: rpi_rf
gpio: 22
switches:
etekcity_0305_1:
pulselength: 183
protocol: 1
code_on: 21888
code_off: 21899
signal_repetitions: 5
Because some of the switches are too far away from my Pi3 to work reliably I have bought a Broadlink RM Pro+ and would like to use it as a backup/secondary driver for the switch actions.
I have the Broadlink working separately from the rpi-rf switches by triggering some scripts, but now I would like for the switch to trigger the script.
And that’s where I need somebody to put me on the right track, please.
I know I could write an automation for each switch for each of the two cases, i.e. turning the switch on through rpi-rf and turning it off the same way each triggers its own script.
- alias: etekcity switch triggers etekcity script on
trigger:
- platform: state
entity_id: switch.etekcity_0305_1
from: 'off'
to: 'on'
action:
- service: script.turn_on
entity_id: script.etekcity_0305_1_on
- alias: etekcity switch triggers etekcity script off
trigger:
- platform: state
entity_id: switch.etekcity_0305_1
from: 'on'
to: 'off'
action:
- service: script.turn_on
entity_id: script.etekcity_0305_1_off
But I think there must be a smarter way by templating this so that I only need two automations for all switches.
One that triggers the correct script if any of the switches changes the state to ‘on’ and another that does the same thing in case a switch is turned ‘off’?
As you can see the switches are named switch.etekcity_0305_1
and the scripts are named script.etekcity_0305_1_on
and script.etekcity_0305_1_off
respectively.
Anybody got any ideas?
-Chairstacker