Heating Automation Improvement Help

Hi,
Below is my current Automation for my heating. Whilst this may look a bit long winded, ultimately it works quite well. However, I’m looking to make some improvements specifically around adjusting the temperature according to whether someone is home or not. As you can see, at the moment the temperature is set to 20degC based on time. However, I’d like to keep the times but add a condition such that if someone is home the temperature set point will go to 20degC but if not, it will only be 18degC.

The issue I seem to have is to get the temperature set point to change at any point in time according to a person’s location.

eg. The Heating is set to come on between 1700 & 2100. If at 1700, there’s no one in the house, the temp is set to 18degC. If at 1730 I arrive home from work, the heating (set point) rises to 20degC. If I decide to then go out again at 1900, the heating should revert to 18degC

Could someone point me in the direction of the best way to right this as an automation??

`- alias: Raise Living Room thermostat target temperature Morning
  trigger:
  - platform: time
    at: 07:30:00
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: 06:45:00
    before: 08:30:00
  action:
    service: climate.set_temperature
    entity_id: climate.living_room
    data:
      temperature: 20
  id: 996b63926322423ea85a5aeb889e0e6f
- alias: Lower Living Room thermostat target temperature Morning
  trigger:
  - platform: time
    at: 08:30:00
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: 08:30:00
    before: '18:00:00'
  action:
    service: climate.set_temperature
    entity_id: climate.living_room
    data:
      temperature: 16
  id: a2794a1e8b2744ac85646f7d2d3dcc42
- alias: Raise Living Room thermostat target temperature evening
  trigger:
  - platform: time
    at: '18:00:00'
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: '18:00:00'
    before: '21:30:00'
  action:
    service: climate.set_temperature
    entity_id: climate.living_room
    data:
      temperature: 20
  id: 30b46af77e7e4addba3b512921d2b973
- alias: Lower Living Room thermostat target temperature evening
  trigger:
  - platform: time
    at: '21:30:00'
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: '21:30:00'
    before: 07:00:00
  action:
    service: climate.set_temperature
    entity_id: climate.living_room
    data:
      temperature: 16
  id: e3543aa9eb85409d9eb4ccdb25c9a3cc
- alias: Raise Kitchen thermostat target temperature Morning
  trigger:
  - platform: time
    at: 06:45:00
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: 06:45:00
    before: 09:00:00
  action:
    service: climate.set_temperature
    entity_id: climate.kitchen
    data:
      temperature: 20
  id: 996b63926322423ea85a5aeb889e0e6e
- alias: Lower Kitchen thermostat target temperature Morning
  trigger:
  - platform: time
    at: 09:00:00
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: 09:00:00
    before: '17:00:00'
  action:
    service: climate.set_temperature
    entity_id: climate.kitchen
    data:
      temperature: 16
  id: a2794a1e8b2744ac85646f7d2d3dcc43
- alias: Raise Kitchen thermostat target temperature evening
  trigger:
  - platform: time
    at: '17:00:00'
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: '17:00:00'
    before: '21:30:00'
  action:
    service: climate.set_temperature
    entity_id: climate.kitchen
    data:
      temperature: 20
  id: 30b46af77e7e4addba3b512921d2b972
- alias: Lower Kitchen thermostat target temperature evening
  trigger:
  - platform: time
    at: '21:30:00'
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: '21:30:00'
    before: 06:45:00
  action:
    service: climate.set_temperature
    entity_id: climate.kitchen
    data:
      temperature: 16
  id: e3543aa9eb85409d9eb4ccdb25c9a3cd
- alias: Raise TV Room thermostat target temperature Morning
  trigger:
  - platform: time
    at: 07:30:00
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: 07:30:00
    before: 09:00:00
  action:
    service: climate.set_temperature
    entity_id: climate.tv_room
    data:
      temperature: 20
  id: 996b63926322423ea85a5aeb889e0e6g
- alias: Lower TV Room thermostat target temperature Morning
  trigger:
  - platform: time
    at: 09:00:00
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: 09:00:00
    before: '17:00:00'
  action:
    service: climate.set_temperature
    entity_id: climate.tv_room
    data:
      temperature: 16
  id: a2794a1e8b2744ac85646f7d2d3dcc41
- alias: Raise TV Room thermostat target temperature evening
  trigger:
  - platform: time
    at: '17:30:00'
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: '17:30:00'
    before: '21:30:00'
  action:
    service: climate.set_temperature
    entity_id: climate.tv_room
    data:
      temperature: 20
  id: 30b46af77e7e4addba3b512921d2b975
- alias: Lower TV Room thermostat target temperature evening
  trigger:
  - platform: time
    at: '21:30:00'
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: '21:30:00'
    before: 07:00:00
  action:
    service: climate.set_temperature
    entity_id: climate.tv_room
    data:
      temperature: 16
  id: e3543aa9eb85409d9eb4ccdb25c9a3ce
- alias: Raise Upstairs thermostat target temperature Morning
  trigger:
  - platform: time
    at: 06:00:00
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: 06:00:00
    before: 08:00:00
  action:
    service: climate.set_temperature
    entity_id: climate.upstairs
    data:
      temperature: 20
  id: c5bd9d3c6245480ab6c5bc2716f28ce5
- alias: Lower Upstairs thermostat target temperature Morning
  trigger:
  - platform: time
    at: 08:00:00
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: 08:00:00
    before: '18:30:00'
  action:
    service: climate.set_temperature
    entity_id: climate.upstairs
    data:
      temperature: 16
  id: 2a0edef6240f420684cc279313489b1e
- alias: Raise Upstairs thermostat target temperature evening
  trigger:
  - platform: time
    at: '18:30:00'
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: '18:30:00'
    before: '21:00:00'
  action:
    service: climate.set_temperature
    entity_id: climate.upstairs
    data:
      temperature: 20
  id: 8326204c1fd6497ca1d20bc050424b99
- alias: Lower Upstairs thermostat target temperature evening
  trigger:
  - platform: time
    at: '21:00:00'
  - platform: homeassistant
    event: start
  condition:
    condition: time
    after: '21:00:00'
    before: 06:00:00
  action:
    service: climate.set_temperature
    entity_id: climate.upstairs
    data:
      temperature: 16
  id: 7eb84da45e454825b36e9268f4d34270`

Again, as you can see this is quite long winded, so if you can suggest a way of streamlining this, that’d be appreciated too :slight_smile:

I sounds as if the only automations affected are for the evening schedules so let’s take those one room at a time and then you can adjust the others based on that.

you should create a group of your “person” entities (or whatever it is you use for tracking you home or not).

The group should home if anyone is home and not home only if no one is home.

then you can use that group as a trigger and a condition in the automations.

- alias: Raise Living Room thermostat target temperature evening
  trigger:
  - platform: time
    at: '18:00:00'
  - platform: homeassistant
    event: start
  - platform: state
    entity_id: group.your_person_group
    to: home
  condition:
  - condition: time
    after: '18:00:00'
    before: '21:30:00'
  - condition: state
    entity_id: group.your_person_group
    state: home
  action:
    service: climate.set_temperature
    entity_id: climate.living_room
    data:
      temperature: 20
  id: 30b46af77e7e4addba3b512921d2b973

- alias: Lower Living Room thermostat target temperature evening
  trigger:
  - platform: time
    at: '21:30:00'
  - platform: homeassistant
    event: start
  - platform: state
    entity_id: group.your_person_group
    to: not_home
  condition:
  - condition: time
    after: '21:30:00'
    before: 07:00:00
  - condition: state
    entity_id: group.your_person_group
    state: not_home
  action:
    service: climate.set_temperature
    entity_id: climate.living_room
    data:
      temperature: 16
  id: e3543aa9eb85409d9eb4ccdb25c9a3cc

as for streamlining you could possibly put it all into one automation and do everything with “choose:” and templates but it doesn’t necessarily make it better.

the trade-off is shorter but less easily readable.

Hi Finity, Thanks for the response.

I don’t think that solves my problem. If I understand your Yaml correctly, the automation would only trigger at 1800 and if I am at home. If I am not at home, it wouldn’t trigger at all.

I could set another entry to trigger at 1800 whilst I am away (to heat to the lower temp) but how would it trigger to the higher temperature once I do arrive home?

I think the Automation needs to be continually monitoring my presence and triggering accordingly within the set times.

No, it will trigger at 1800 only if you are at home.

OR

if you get home and it’s past 1800 and before 2130.

triggers are always “or”.

Hi Finity, my apologies. I didn’t realise that Automations are always ‘or’.

I’ve tested it now and it seems to function as I want, just some fine tuning to do to the overall automation and it should be good.

Thanks again