Hi, I have done this automation to turn on the light of the xwhen gw at the opening of the door of the house and it works perfectly. What I can not do is pass a color of my choice.
If I put this rows at the end of the code
service: ....
date:
entity_id: ...
rgb_color: ..
when the door is opened, the LED lights up in the right color, but then it does not go off when I close the door.
How should I pass the right color and make sure that the atomization works correctly?
This codes are currently in use
indent preformatted text by 4 spaces
- alias: Accensione/Spegnimento luce con apertura porta
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d00023ea03f
to: 'on'
- platform: state
entity_id: binary_sensor.door_window_sensor_158d00023ea03f
to: 'off'
condition:
condition: time
after: '20:00'
before: 06:00
action:
service_template: '{% if trigger.to_state.state == "on" %} homeassistant.turn_on
{% elif trigger.to_state.state == "off" %} homeassistant.turn_off {% endif %}'
entity_id: light.gateway_light_7811dce210d1
Why not to make second pretty same automation with another trigger (door off) and another action?
Your way to automate light is more nice, but I do not know if it is reasonoble to do, when there is easier way.
What do you think?
Or write two scripts one for turning on, secon for turning of. And then use your automation to choose whitch script to use.
Not sure if it will fix it but perhaps change your original code as most of the templates I see have the statements on separate lines. On my phone at the moment so hard to show you
EDIT: maybe…
- alias: Accensione/Spegnimento luce con apertura porta
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d00023ea03f
to: 'on'
- platform: state
entity_id: binary_sensor.door_window_sensor_158d00023ea03f
to: 'off'
condition:
condition: time
after: '20:00'
before: 06:00
action:
service_template: >
{% if trigger.to_state.state == "on" %} homeassistant.turn_on
{% elif trigger.to_state.state == "off" %} homeassistant.turn_off
{% endif %}
entity_id: light.gateway_light_7811dce210d1
EDIT 2: I just noticed that the indentation in the triggers is wrong. Updated mine above
So maybe try your original action, but take note of the extra 2 spaces I put in front of your triggers
Tnx for reply. My problem isn’t the automation that it works…my problem is set a custom color to my automation. If i use my orignal code or your (ive tried and it works)the lights is white (default), but i’d like to change.
Right, so I wasn’t mistaken. Well to change the colour simply use the code I deleted in my other post but substitute the 255,255,255 for different numbers to get the colour you want. You can look on Google to get the numbers for any colour in the spectrum.
Hello, the problem is i can’t sent a custom color to the light, if i use data:
entity_id: light.gateway_light_7811dce210d1
rgb_color: [255, 0, 0]
The light turn on with the correct color but when I close the door the light does not go out