- platform: template
  sensors:
    day_phase:
      friendly_name: 'Day Phase'
      value_template: >
        {% if now() > now().replace(hour=5).replace(minute=0).replace(second=0) and
            now() < now().replace(hour=8).replace(minute=0).replace(second=0) and 
            now().isoweekday() <= 5 %}
            Morning
        {% elif states.sun.sun.state == "above_horizon" or
            now() > now().replace(hour=5).replace(minute=0).replace(second=0) and
            now() < now().replace(hour=12).replace(minute=0).replace(second=0) %}
            Day
        {% elif now() < now().replace(hour=21).replace(minute=45).replace(second=0) and
            now() > now().replace(hour=5).replace(minute=0).replace(second=0) %}
            Evening
        {% else %}
            Night
        {% endif %}
    lights_on:
        friendly_name: 'Lights On'
        unit_of_measurement: 'Count'
        value_template: >
            {{ states.light
                | selectattr('state', 'eq', 'on')
                | rejectattr('attributes.is_hue_group')
                | list 
                | count
            }}
    rooms_on:
        friendly_name: 'Rooms On'
        unit_of_measurement: 'Count'
        value_template: >
            {{ states.light
                | selectattr('state', 'eq', 'on')
                | selectattr('attributes.is_hue_group')
                | list 
                | count
            }}
- platform: template
  sensors:
    day_phase:
      friendly_name: "Day Phase"
      value_template: >
        {% if now() > now().replace(hour=5).replace(minute=0).replace(second=0) and
            now() < now().replace(hour=7).replace(minute=0).replace(second=0) and 
            now().isoweekday() <= 5 %}
            Morning
        {% elif states.sun.sun.state == "above_horizon" or
            now() > now().replace(hour=5).replace(minute=0).replace(second=0) and
            now() < now().replace(hour=12).replace(minute=0).replace(second=0) %}
            Day
        {% elif now() < now().replace(hour=21).replace(minute=45).replace(second=0) and
            now() > now().replace(hour=5).replace(minute=0).replace(second=0) %}
            Evening
        {% else %}
            Night
        {% endif %}
    lights_on:
      friendly_name: "Lights On"
      unit_of_measurement: "Count"
      value_template: >
        {{ states.light
            | selectattr('state', 'eq', 'on')
            | rejectattr('attributes.is_hue_group')
            | list 
            | count
        }}
    rooms_on:
      friendly_name: "Rooms On"
      unit_of_measurement: "Count"
      value_template: >
        {{ states.light
            | selectattr('state', 'eq', 'on')
            | selectattr('attributes.is_hue_group')
            | list 
            | count
        }}

Set dayphase day back to 7am
Set dayphase day back to 7am
