SOLVED, but still with questions (see bottom.)
Hi!
New to HA and struggling with something I believe ought to be quite simple. I have a Broadlink RM4 and have successfully learned codes and set up scripts to turn on and off some IR remote controlled candles.
Here’s what the script looks like:
What would be more natural, of course, is to have a single script that runs the on script to turn on, and off script to turn off. I believe a template script is the right choice for this, and I think I’m close, but can’t quite get the syntax to reference the scripts correct.
switch:
- platform: template
switches:
fireplace_candles_switch:
turn_on:
target:
entity_id: script.1663570647553
service: fireplace_candles_on
turn_off:
target:
entity_id: script.1663570647553
service: fireplace_candles_off
friendly_name: "Fireplace Candles"
I can’t quite figure out how to structure the action
to refer to the scripts I already have. I know the entity_id
for the script, and the name
of the script, but not sure how to set up the config.
I have also tried:
turn_off:
service: script.fireplace_candles_off
but get
Failed to call service switch/turn_off. Unable to find service script.fireplace_candles_off
The entity id for the remote itself is remote.broadlink_remote
.
UPDATE
Ok, I actually figured out a way to make this work but figured I would post anyway for anyone who is searching in the future. My full working conf is now:
switch:
- platform: template
switches:
fireplace_candles_switch:
turn_on:
service: script.1663570647553
turn_off:
service: script.1663571141834
friendly_name: "Fireplace Candles"
I see people referencing devices, entities and scripts in various ways inside switch templates, and none of them were using the auto-generated script IDs as mine does, so I think there are more elegant ways to do it, but this is one simple way to create a switch from two scripts.