Returning to previous set temperature with automation?

The outside temperature is varying lately, I keep going between 22-23-24C inside. If I’m coming from outside 24 is too hot but 22 is good. If I’m in all day 24 is good.

The automation I have now is to set it to 24C when I get home. Can I use input number to set a temperature that it uses instead? Maybe if it detects a thermostat change, save it to a input number and then the automation chooses that one when I come home?
I found this one but I don’t know where to start.

When asking for this kind of help it’s always helpful if you post your existing automation. That will give us the details we need to make suggestions (e.g., entity_id’s, what services you’re using, etc.) Not all climate entities work the same.

But, yes, what you’re asking to do is definitely possible. And I can suggest how to do it after you post your existing automation.

Having said that, it sounds like maybe what you might really want is to set the temp to 22 when you first come home, then raise it to 23 after you’ve been home for a while, then to 24 again later.

Do you also have an automation that lowers the set point when you leave? If so, can you post that, too? If not, would you want something like that?

Running Hassio with HACS.
Climate:
climate.bedroom
climate.living_room

sensors:
sensor.bedroom_temperature
sensor.livingroom_temperature

Automations:

- id: '1576530288153'
  alias: Temp leaving home - 1 hour
  description: Set temperature to away if I'm gone for more than 1 hour.
  trigger:
  - entity_id: person.per_kristian
    for: 01:00:00
    from: home
    platform: state
    to: not_home
  condition: []
  action:
  - data:
      temperature: 19
    entity_id: climate.living_room
    service: climate.set_temperature
  - data:
      temperature: 17
    entity_id: climate.bedroom
    service: climate.set_temperature
- id: '1576530853517'
  alias: Temp coming home
  description: Increase inside temperature when I get home.
  trigger:
  - entity_id: person.per_kristian
    from: not_home
    platform: state
    to: home
  condition: []
  action:
  - data:
      temperature: 23
    entity_id: climate.living_room
    service: climate.set_temperature
  - data:
      temperature: 19
    entity_id: climate.bedroom
    service: climate.set_temperature

Also I have two template sensors that knows what themperature I set.
sensor.livingroom_set_temperature
sensor.bedroom_set_temperature

Thanks. So effectively what you want is to record the current set temperatures for the two climate entities before setting them down when you leave, and set the temperatures back to those recorded values when you get home. Is that right? If so…

- id: '1576530288153'
  alias: Temp leaving home - 1 hour
  description: Set temperature to away if I'm gone for more than 1 hour.
  trigger:
  - entity_id: person.per_kristian
    for: 01:00:00
    platform: state
    to: not_home
  condition: []
  action:
  - service: input_number.set_value
    entity_id: input_number.living_room
    data_template:
      value: "{{ states('sensor.livingroom_set_temperature') }}"
  - service: input_number.set_value
    entity_id: input_number.bedroom
    data_template:
      value: "{{ states('sensor.bedroom_set_temperature') }}"
  - data:
      temperature: 19
    entity_id: climate.living_room
    service: climate.set_temperature
  - data:
      temperature: 17
    entity_id: climate.bedroom
    service: climate.set_temperature
- id: '1576530853517'
  alias: Temp coming home
  description: Increase inside temperature when I get home.
  trigger:
  - entity_id: person.per_kristian
    from: not_home
    platform: state
    to: home
  condition: []
  action:
  - data_template:
      temperature: "{{ states('input_number.living_room') }}"
    entity_id: climate.living_room
    service: climate.set_temperature
  - data_template:
      temperature: "{{ states('input_number.bedroom') }}"
    entity_id: climate.bedroom
    service: climate.set_temperature

If that’s not quite what you want let me know what I got wrong and I can adjust accordingly.

Looks right, thank you :slight_smile:
So the actions are run in the order they’re in? input number first and then change temperature?

Yes. And most things you can invoke will run to completion before the next step in the action sequence will start. I say most because there are exceptions. E.g., if you start a script, and that script has a delay or wait_template that waits, the script will suspend and “return” to the “caller.” There may be some other examples, but for this, the saving will definitely complete before the climate entities change.

If you are using the latest version of Home Assistant (0.103) it has a feature to store the current state of entities in a temporary scene and then using that scene later to restore the entities to their previous state.

- id: '1576530288153'
  alias: Temp leaving home - 1 hour
  description: Set temperature to away if I'm gone for more than 1 hour.
  trigger:
  - entity_id: person.per_kristian
    for: 01:00:00
    platform: state
    to: not_home
  condition: []
  action:
  - service: scene.create
    data:
      scene_id: before_leaving
      snapshot_entities:
      - climate.living_room
      - climate.bedroom
  - service: climate.set_temperature
    data:
      entity_id: climate.living_room
      temperature: 19
  - service: climate.set_temperature
    data:
      entity_id: climate.bedroom
      temperature: 17

- id: '1576530853517'
  alias: Temp coming home
  description: Increase inside temperature when I get home.
  trigger:
  - entity_id: person.per_kristian
    from: not_home
    platform: state
    to: home
  condition: []
  action:
  - service: scene.turn_on
    data:
      entity_id: scene.before_leaving
1 Like

Are you sure that works with climate entities?

EDIT: Never mind. It does look like the climate domain supports this. Nice!

EDIT 2: I’m going to have to think about whether or not I want to use this instead of the more manual method (of using input_numbers, etc.) The problem with dynamic scenes is (as I understand it), they disappear when HA restarts. If HA restarts while you’re away, the previous state will be lost. This doesn’t happen with input_XXX, which saves their state over restarts. And if the automation is written correctly to account for restarts, …

This is something that would be extremely useful for me, especially with the colder weather coming in right now. My automation is a little different though and currently looks like this:

- id: '1575231618454'
  alias: Thermostat - We're Not Home
  description: ''
  trigger:
  - entity_id: group.parents
    platform: state
    to: not_home
  condition: []
  action:
  - alias: ''
    data:
      entity_id: climate.thermostat
      preset_mode: away
    service: climate.set_preset_mode
- id: '1575233619529'
  alias: Thermostat - We're Home
  description: ''
  trigger:
  - entity_id: group.parents
    platform: state
    to: home
  condition: []
  action:
  - data:
      entity_id: climate.thermostat
      preset_mode: none
    service: climate.set_preset_mode
  - data:
      entity_id: climate.thermostat
      temperature: 19.5
    service: climate.set_temperature

Would changing it to this work:

- id: '1575231618454'
  alias: Thermostat - We're Not Home
  description: ''
  trigger:
  - entity_id: group.parents
    platform: state
    to: not_home
  condition: []
  action:
  - service: scene.create
    data:
      scene_id: before_leaving
      snapshot_entities:
      - climate.thermostat
    data:
      entity_id: climate.thermostat
      preset_mode: away
    service: climate.set_preset_mode

- id: '1575233619529'
  alias: Thermostat - We're Home
  description: ''
  trigger:
  - entity_id: group.parents
    platform: state
    to: home
  condition: []
  action:
  - data:
      entity_id: climate.thermostat
      preset_mode: none
    service: climate.set_preset_mode
  - service: scene.turn_on
    data:
      entity_id: scene.before_leaving

For some reason, my one above does not validate?

Try:

- id: '1575231618454'
  alias: Thermostat - We're Not Home
  description: ''
  trigger:
  - entity_id: group.parents
    platform: state
    to: not_home
  condition: []
  action:
  - service: scene.create
    data:
      scene_id: before_leaving
      snapshot_entities:
      - climate.thermostat
  - data:
      entity_id: climate.thermostat
      preset_mode: away
    service: climate.set_preset_mode

- id: '1575233619529'
  alias: Thermostat - We're Home
  description: ''
  trigger:
  - entity_id: group.parents
    platform: state
    to: home
  condition: []
  action:
  - service: scene.turn_on
    data:
      entity_id: scene.before_leaving
1 Like

pnbruckner, thank for that but there is a problem as the thermostat does not go into ‘away’ 'mode when group.parents are not_home.

Do you mean when group.parents changes to not_home?

Are there any errors? Does the log show the automation triggering? If you manually trigger the automation does it change to away mode?

Yes, when group.parents changes to not_home, climate.thermostat is not changing to preset_mode: away

Manually triggered in automations:
Screenshot from 2019-12-18 20-23-53

Thermostat:
Screenshot from 2019-12-18 20-24-20

There’s a log error:

Error while executing automation automation.thermostat_we_re_not_home_retain_settings. Service not found for call_service at pos 1: Unable to find service scene/create

And what version of HA are you running? That feature was only added very recently. You probably need to upgrade.

Screenshot from 2019-12-18 20-40-29

Do you have:

scene:

in your configuration?

Do you mean in configuration.yaml? I do not have scene: in there. Is this something I need to add and if so, what entries should be under it?