Here is my time of day sensor and the script I use to determine which temperature is appropriate resulting from that.
Use, pull apart or throw away as you see fit.
sensor:
- platform: template
sensors:
heat_set_temperature:
entity_id: climate.house_heat, input_number.in_heat_temp_control_val
friendly_name: Heating Set Temperature
value_template: "{{ state_attr('climate.house_heat', 'temperature') }}"
icon_template: "{{'mdi:emoticon-cool' if ((state_attr('climate.house_heat', 'current_temperature') | float) >= (states('input_number.in_heat_temp_control_val') | float)) else 'mdi:emoticon-sad-outline'}}"
heat_day_segment:
entity_id: sensor.time
friendly_name: Heating Segment
value_template: >
{% set time = states('sensor.time') %}
{% set slt1start = states('input_datetime.id_heat_day_on') [0:5] %}
{% set slt1stop = states('input_datetime.id_heat_evening_on') [0:5] %}
{% set dy = (slt1start <= time < slt1stop) if (slt1start < slt1stop) else (slt1start <= time or time < slt1stop) %}
{% set slt1start = states('input_datetime.id_heat_evening_on') [0:5] %}
{% set slt1stop = states('input_datetime.id_heat_night_on') [0:5] %}
{% set evng = (slt1start <= time < slt1stop) if (slt1start < slt1stop) else (slt1start <= time or time < slt1stop) %}
{% set slt1start = states('input_datetime.id_heat_night_on') [0:5] %}
{% set slt1stop = states('input_datetime.id_heat_day_on') [0:5] %}
{% set nght = (slt1start <= time < slt1stop) if (slt1start < slt1stop) else (slt1start <= time or time < slt1stop) %}
{% if dy %}Day{% elif evng %}Evening{% else %}Night{% endif %}
icon_template: >
{% set seg = states('sensor.heat_day_segment') %}
{% if seg == 'Day' %}mdi:shovel{% elif seg == 'Evening' %}mdi:glass-cocktail{% else %}mdi:sleep{% endif %}
## resets temperature following any pattern change
sc_heat_reset_value:
alias: Heating Reset Value
sequence:
- service: input_number.set_value
data_template:
entity_id: input_number.in_heat_temp_control_val
value: >
{% if false and not is_state('binary_sensor.bs_door_open', 'on') %}
{{ '6' | float }}
{% elif not is_state('binary_sensor.bs_occupied', 'on') %}
{{ states('input_number.in_heat_temp_away_val') | float }}
{% elif is_state('sensor.heat_day_segment', 'Night') %}
{{ states('input_number.in_heat_temp_night_val') | float }}
{% elif is_state('sensor.heat_day_segment', 'Day') %}
{{ states('input_number.in_heat_temp_day_val') | float }}
{% else %}
{{ states('input_number.in_heat_temp_evening_val') | float }}
{% endif %}
#### end of template
I did a basic interpetation of jinja wrapped python in this post : -