I am trying to figure out how to get a button to scroll through colors.
I am currently using Lutron Casata Pico remotes to control my color lights. I have ON, Off, and Brightness working with a blueprint (stephack/core-pico.yaml). I would like to use the middle button to scroll through colors. I have been trying to figure out how to do an if than statement with no success. I need something like this:
if
light is white then change to blue
if
light is blue change to red
if
light is red change to green
if
light is green change to white
I don’t see away to select a color from the automatons or scripts so I’m stuck.
Someone please point me in the right direction.
Thanks. This looks like what I need but I can’t get it to work in the automation. I get error
“Error loading /config/configuration.yaml: while scanning for the next token
found character ‘%’ that cannot start any token
in “/config/automations.yaml”, line 249, column 14”
am I missing something? Thanks again for your help.
middle_stop:
- service: light.turn_on
target:
device_id: 844f3632fa92177373341cfa9067a34e
data:
color_name:
{% if is_state_attr('844f3632fa92177373341cfa9067a34e', 'color_name', 'white') %}
blue
{% elif is_state_attr('844f3632fa92177373341cfa9067a34e', 'color_name', 'blue') %}
red
{% elif is_state_attr('844f3632fa92177373341cfa9067a34e', 'color_name', 'red') %}
green
{% elif is_state_attr('844f3632fa92177373341cfa9067a34e', 'color_name', 'green') %}
white
{% else %}
white
{% endif %}
You are using a device id instead of an entity id in the is_state_attr() tests. This not supported as far as I am aware. You should avoid using device ids as much as possible. They are not easily changed if you replace a device. Entity ids can be changed (new to old) in one place.
This automation was created with a blueprint. I changed it to device_id and I still get the same error.
Error loading /config/configuration.yaml: while scanning for the next token
found character ‘%’ that cannot start any token
in “/config/automations.yaml”, line 249, column 14
line 249 is {% if is_state_attr(‘light.desk_light’, ‘color_name’, ‘white’) %}
I tried to look at the template info from the link you posted but can’t see a problem. Is it possible to use template info in a yaml file?
I have not been able to get this to work so I thought I would try to create a script that would change the light from white to blue and blue to white. I can not get that to work ether. I tried to use the gui in HA but there was not a color_name option under state so I added it in yaml. Here is what I tried. Please, please, let me know what I am doing wrong.
alias: Scroll Colors
sequence:
- choose:
- conditions:
- condition: state
entity_id: light.office_desk
state: white
attribute: color_name
sequence:
- service: light.turn_on
target:
device_id: 844f3632fa92177373341cfa9067a34e
data:
color_name: blue
- conditions:
- condition: state
entity_id: light.office_desk
state: blue
attribute: color_name
sequence:
- service: light.turn_on
target:
device_id: 844f3632fa92177373341cfa9067a34e
data:
color_name: white
default: []
mode: single