Time after/before automation

Hi all,

Thanks for reading and helping. I’m pretty new with HA and I am trying to understand some automations. One of the automations that I can’t figure out is the following: I want the thermostat to be set to, say, 18 degrees between 5 p.m. and 10 p.m. and only when someone is home. If someone from the group is not at home, the temperature is set to 13 (this automation works), but the temperature may only be set to 18 in that period when someone comes home or is at home.
What I’ve set up now doesn’t work and I can’t figure out why not. Does anyone have a solution?
Here is my automation:

alias: 'Thermostat: at 18 from 17.00 PM'
description: ''
trigger:
  - platform: state
    entity_id: group.everyone
    to: home
condition:
  - condition: time
    after: '17:00:00'
    before: '22:00:00'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
action:
  - service: climate.set_temperature
    data:
      temperature: 18
    target:
      entity_id: climate.honeywell
mode: single

Thanks in advance!

I have this divided in 2 parts: The switching times for comfort and standby temps
In which i check if anyone is home before setting the temperature for comfort.
So in this case the trigger is time.

The 2nd automation triggers if anyone is at home or nobody is and sets the temperature.

That way there will always be a check at a certain time and when the family pressent or not

You could (and i should) put this in 1 automation.
Set the times and presence as triggers, give them an ID and use Choose.
For example this checks if the family is home and is triggered by the morning time (5:50)

alias: Heating Times
description: ''
trigger:
  - platform: time
    at: '05:50'
    id: Morning_Weekday
  - platform: time
    at: '07:00'
    id: Morning_Weekend
  - platform: time
    id: Evening_Weekday
    at: '22:00'
  - platform: time
    id: Evening_Weekend
    at: '23:30'
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: group.family
            state: home
          - condition: trigger
            id: Morning_Weekday
          - condition: time
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
        sequence:
          - service: climate.set_temperature
            target:
              entity_id: climate.woonkamer
            data:
              temperature: '{{ states.input_number.setpoint_woonkamer_comfort.state }}'

In any case, I have merged 2 automations on your instructions:
1: If someone is at home, set the temperature to 17 at 8 am
2: If someone is at home, set the temperature to 18 at 5 pm
Is my new automation correct?

alias: 'Thermostat: 8 AM and 5 PM'
description: ''
trigger:
  - platform: time
    at: '08:00:00'
    id: wake-up
  - platform: time
    at: '17:00:00'
    id: evening
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: group.everyone
            state: home
          - condition: trigger
            id: wake-up
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 17
            target:
              entity_id: climate.honeywell
      - conditions:
          - condition: trigger
            id: evening
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 18
            target:
              entity_id: climate.honeywell
    default: []
mode: single

Then I still have no solution for when everyone is gone and the temperature is at 13. This has to go back to 17 during the day and to 18 in the evening when someone comes/is home.

just add the trigger with the home and not-home.

trigger:
  - platform: state
    entity_id: group.family
    to: not_home
    for:
      hours: 0
      minutes: 30
      seconds: 0
    id: nothome30min
  - platform: state
    entity_id: group.family
    to: home
    id: home

And use that with the condition time to decide if to set the temp.

  - condition: time
    after: '17:00:00'
    before: '22:00:00'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun

Looking at this made me decide to redo my automation into 1, will get right on it when i’m home.
There is prob a much cleaner way todo this :smiley: someone will post if so :wink:

Thanks, will look at it. I changed for testing the time of 5 PM to an actual time + 2 min and it works :slightly_smiling_face:

Edit:
Changed the automation to:

alias: 'Thermostaat: Wake-up AM and Evening PM'
description: ''
trigger:
  - platform: time
    at: '08:00:00'
    id: wake-up
  - platform: time
    at: '17:00:00'
    id: evening
  - platform: state
    entity_id: group.everyone
    from: home
    to: not_home
    id: not_home
  - platform: state
    entity_id: group.everyone
    to: home
    id: home
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: group.everyone
            state: not_home
          - condition: trigger
            id: not_home
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 13
            target:
              entity_id: climate.honeywell
      - conditions:
          - condition: trigger
            id: home
          - condition: time
            before: '17:00:00'
            after: '08:00:00'
            weekday:
              - sun
              - sat
              - fri
              - thu
              - wed
              - tue
              - mon
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 17
            target:
              entity_id: climate.honeywell
      - conditions:
          - condition: trigger
            id: home
          - condition: time
            before: '22:00:00'
            after: '17:00:00'
            weekday:
              - sun
              - sat
              - fri
              - thu
              - wed
              - tue
              - mon
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 18
            target:
              entity_id: climate.honeywell
    default: []
mode: single

I’m going to take the dogs for a walk and take my iphone with me to see if this works. :ok_hand:

It has worked perfectly well so far.