Help with settting climate when away from home

I am trying to set up a generic_thermostat to control my central heating, I’m currently at the point where I have presets change based on time using automations, and presence detection using the following yaml

alias: "[Heating] Presence"
description: ""
trigger:
  - platform: state
    entity_id: zone.home
    to: "0"
    id: empty
  - platform: state
    entity_id: zone.home
    from: "0"
    id: notempty
condition: []
action:
  - if:
      - condition: trigger
        id: empty
    then:
      - service: scene.create
        data:
          scene_id: heating_before
          snapshot_entities: climate.house
      - service: climate.turn_off
        data: {}
        target:
          entity_id: climate.house
    else:
      - service: scene.turn_on
        data: {}
        target:
          entity_id: scene.heating_before
mode: single

The issue is that I have the sleep preset set to activate at 9pm, and then comfort setting to activate at 7am the following day, if the house is empty before 7am, the climate then gets changed to comfort after we leave, but then when someone returns to the house it restores the scene.heating_before and as a result also restores the preset of sleep.

How can I work around this issue?

I have conditions for my HVAC based on time of day. So I have 4 time periods as automations for each day that have conditions of between this time and this time.

When someone returns I have another automation that says to run all the temp setting automations. All of them will fail EXCEPT the one where the day/time conditions are met.

That is how I worked around it.