{{
is_state('front_wall_light_schedule_on', 'on') or
(is_state('motion_sensor_occupancy_front', 'on') and is_state('sun.sun', 'below_horizon'))
}}
But in the UI this claims:
This template listens for the following state changed events:
Entity: front_wall_light_schedule_on
Entity: motion_sensor_occupancy_front
Is sun actually not supported here for some reason? This seems weird since I can create another helper that I add the automation to flip… which is silly
It looks like the template interpreter does not check whether the entities do really exist when using is_state.
For instance this template is rendering “false” although I am sure the entity does not exist:
I am pretty sure that each entity ID always contains a dot, so could it be that you forgot to add the entity types?
For instance, should it be binary_sensor.front_wall_light_schedule_on for your sensor?
@viraptor It’s because your if statement fails and never hits the is_state function for sun.sun because the and fails. It will hit that part when the or statement passes.
A or b and c is essentially a or (b and c). If b is false, there’s no reason to check c because the and fails. Therefore it won’t show up in your watched entities. It is still part of the template so there’s nothing to worry about. When b becomes true, sun.sun will be checked and added to the template listener.
EDIT: The reason your b is false is because of what @Troon highlighted in the next post.
Your entity IDs are missing their domains (at a guess, schedule.front_wall_light_schedule_on and binary_sensor.motion_sensor_occupancy_front), like Ed said.
This:
is_state('motion_sensor_occupancy_front', 'on')
…will always be false, so the template system doesn’t need to check the sun state.