Time of day (TOD) - Bug?

Hello,

what do you expect this binary sensor to be when sunrise is before 6am.

binary_sensor:
  - platform: tod
    name: "TOD_Morning"
    after: '06:00:00'
    before: sunrise

Does not look right to me. I expected this binary te false all day/24/7.

Regards
Ralf

Seems not many of your using this integration. I see your point … ,-).

I refactored this portion of my logic and created a template sensor like this. Might be useful for others in the future. I am currently testing before putting it to production. Looks good so far.

    tod:
      friendly_name: 'Time of Day'
      entity_id: sensor.time
      value_template: >
        {% set currentTime = now().strftime('%H:%M') %}
        {% set sunrise     = as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom('%H:%M') %}
        {% set afternoon   = (as_timestamp(states.sun.sun.attributes.next_setting) | float - 90 * 60 ) | timestamp_custom('%H:%M') %}
        {% set sunset      = (as_timestamp(states.sun.sun.attributes.next_setting) | float ) | timestamp_custom('%H:%M') %}

        {%   if   '00:00' < currentTime <= '06:00'   %} bed
        {% elif   '06:00' < currentTime <= sunrise   %} morning
        {% elif   sunrise < currentTime <= '10:00'   %} forenoon
        {% elif   '10:00' < currentTime <= afternoon %} day
        {% elif afternoon < currentTime <= sunset    %} afternoon
        {% elif    sunset < currentTime <= '22:00'   %} evening
        {% elif   '22:00' < currentTime <= '23:59'   %} night
        {% else %}                                      unknown
        {% endif %}
      icon_template: >
        {% set currentTime = now().strftime('%H:%M') %}
        {% set sunrise     = as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom('%H:%M') %}
        {% set afternoon   = (as_timestamp(states.sun.sun.attributes.next_setting) | float - 90 * 60 ) | timestamp_custom('%H:%M') %}
        {% set sunset      = (as_timestamp(states.sun.sun.attributes.next_setting) | float ) | timestamp_custom('%H:%M') %}

        {%   if   '00:00' < currentTime <= '06:00'   %} mdi:weather-night
        {% elif   '06:00' < currentTime <= sunrise   %} mdi:weather-sunset-up
        {% elif   sunrise < currentTime <= '10:00'   %} mdi:weather-sunset
        {% elif   '10:00' < currentTime <= afternoon %} mdi:weather-sunny
        {% elif afternoon < currentTime <= sunset    %} mdi-weather-sunset
        {% elif    sunset < currentTime <= '22:00'   %} mdi-weather-sunset-down
        {% elif   '22:00' < currentTime <= '23:59'   %} mdi:weather-night
        {% else %}                                      mdi:infinity
        {% endif %}