I have the following automation set up that SHOULD turn the lights in my kids room green at certain times to let them know that they can come out (either in the morning or from nap time). It hasn’t been working so I set up the notify action as well to see if my template was working fine. The notify action will send me the entity_id I want like it’s supposed to, but the automation is not triggering. If I set the variable to a static entity, it works fine. I’m thinking that the template returns a string, and the script is looking for something else, but I’m not sure what or how to convert it.
Automation:
- id: '1589220886910'
alias: Kids Light Turns Green
description: ' '
trigger:
- entity_id: sensor.time
platform: state
to: 06:45
- entity_id: sensor.time
platform: state
to: '14:30'
- entity_id: sensor.time
platform: state
to: '15:30'
- entity_id: sensor.time
platform: state
to: '14:26'
condition: []
action:
- data:
variables:
entity_id: {{ state_attr( {% if states.sensor.time.state == '06:45' %}'light.charlottes_light,light.justins_light'{%
elif states.sensor.time.state == '14:30' %}'light.charlottes_light'{%
elif states.sensor.time.state == '15:30' %}'light.justins_light'{% elif
states.sensor.time.state == '14:26' %}'light.office_lamp'{% endif %} ) }}
entity_id: script.1589220206391
service: script.turn_on
- data_template:
data:
push:
thread-id: test
message: '{% if states.sensor.time.state == '06:45' %}'light.charlottes_light,light.justins_light'{%
elif states.sensor.time.state == '14:30' %}'light.charlottes_light'{%
elif states.sensor.time.state == '15:30' %}'light.justins_light'{% elif
states.sensor.time.state == '14:26' %}'light.office_lamp'{% endif %}'
title: Test
service: notify.mobile_app_brians_iphone
Yes. Your templates are a mess. If you convert them to multi-line templates and apply some indentation to aid readability you should be able to see the problems.
For example, the open and close single quotes here:
OK, let me give that a shot. And I know it’s very dim, I only want it barely on so it doesn’t wake them up. Also sengled seems to have issues with transitions where the bulb has to be on before transition works. So I could turn it on to 1, then transition to 255 over 5 minutes or so if I wanted. If I go from off to 255 over 5 minutes, it instantly turns on.
Also, I tried the time trigger, but it seemed to be off by a few seconds from the states.sensor.time.state so it never actually triggered.
Yes, but if I have the trigger set to 15:30 using the time platform, states.sensor.time.state is still at 15:29. Maybe 10 seconds later or so it will actually change to 15:30 but by then the trigger has already been checked as false.