Turn off heating in a certain time slot and prevent it from being turned on manually


I made an automation that switches off the heating during the night between 23.30h and 05.00h
I think this works but when someone manually turns on the heating, it stays on.
I would like the automation to restart when this happens. (or prevent this)
My kids have the bad habbit to turn the heating in the livingroom to the max and then go to sleep.
I could make use of an motion detector but I just want to turn the heating off in the above period. This is my code (entities\livingroom\heating_off_at_night.yaml)

alias: 'Verwarming s nachts uit'
initial_state: 'on'
  - platform: homeassistant
    event: start
  - platform: template
    value_template: "{{ states('sensor.time') == '23:30' }}"
  - platform: template
    value_template: "{{ states('sensor.time') == '05:00' }}"
  - service_template: >
      {% if '23:30' <= states('sensor.time') < '05:00' %}
      {% else %}
      {% endif %}
    entity_id: climate.huiskamer

Any help is appreciated

1 Like

Add this trigger. Will hit, if heating is running for more than 5mins. Your time check in the service template will turn the heating off during night, but keep it on during day.

  - platform: state
    entity_id: climate.huiskamer
    to: "on"
    for: "00:05:00"
1 Like

Thank you… Works like a charme!