I just wanted to see if someone could quickly help me clean up the following line of code:
{% if is_state('sensor.alarm_clock_correct_day', 'on') and is_state('input_boolean.alarm_clock_status', 'on') and states.sensor.alarm_clock_hour.state | int - now().hour() >= 0 %}
The first two if’s work fine but the third which is supposed to subtract and compare to 0 doesn’t do what i want it to do.
{% if is_state('sensor.alarm_clock_correct_day', 'on') and is_state('input_boolean.alarm_clock_status', 'on') and ( states.sensor.alarm_clock_hour.state | int - now().hour() >= 0 ) %}
Oh wait: ‘hour’ is a field of now(), not a method. The trailing brackets must be removed. It should read:
{% if is_state('sensor.alarm_clock_correct_day', 'on') and is_state('input_boolean.alarm_clock_status', 'on') and ( states.sensor.alarm_clock_hour.state | int - now().hour >= 0 ) %}