I don’t understand the workaround but I think it will not work because it will fix to one color. I want to basically toggle red and toggle white. Another option would be toggle a scene. I can turn scenes on/off with Amazon echo and Smart Things but I can only find turn scene on in HASS no turn scene off or more specifically toggle scene.
@Danielhiversen Thanks for another example. That seems very close to what I want to do but I don’t understand how the “condition” applies the true or false to the action. The action looks to me like it turns on the media player, sets the volume, reads the new and no sure what the last homeassistant.turn_on service does.
Does this act like a toggle?
I have the following which turns the light on RED when I single press. I am trying to change this to a toggle.
BTW: Does HASS have to be restarted every time you edit an automation? It makes trial and error cumbersome. Wondering if there is a better way.
UPDATE:
I thought I had this figured out. I think the condition decides if rule should take action. So I tried the following.
alias: ‘Toggle BedSide Light RED on if off’
trigger:
platform: event
event_type: flic_click
event_data:
button_name: flic_80e4da717c9a
click_type: single
condition:
But this results in the light flashing on and then back off with every press. I think because of timing. The first rule fires with the light off so it turns on, then the second rule fires and since it is now “on” it turns off.
I need to stop the other rule once one is satisfied. I think…
Then I created my automation to assign the flic button press to the primary script which makes the decision to call on or off. I called this flic.yaml in the automations folder.
- alias: 'Toggle BedSide Light RED on/off'
trigger:
platform: event
event_type: flic_click
event_data:
button_name: flic_80e4da717c9a
click_type: single
action:
service_template: script.toggle_red_bedside
Has anyone worked out how to generalise this workaround so that the toggle script can be used on any of the lights rather than having to have a separate script for each light you wan to toggle.
I am imagining the passing of a parameter to the script of the light to be toggled but am lost as to how to code it.