Time template with minutes

Hi, I have the folowing template which is fine

        volume: >-
          {% if now().hour > 22 or now().hour < 11 %} 25
          {% else %} 15
          {% endif %}

But I get error when I add minutes

        volume: >-
          {% if now().hour > "22:30" or now().hour < "11:45" %} 25
          {% else %} 15
          {% endif %}

Put {{ now().hour }} in the template editor. What does it return?

An integer.

You are trying to compare this integer with the strings "22:30", and "11:45".

You may not compare strings and integers.

You can do this:

{% if now() > today_at('22:30') or now() < today_at('11:45') %}
1 Like