Quick Template code that needs a fix

Cheers.

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.

Any quick input would be appreciated!

May a set of additional brackets:

{% 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 ) %}

Just tried. Sadly doesn’t work either. The last part is now recognized as not true even tho it should be true.

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 ) %}

Thank you! That solved the issue.