Turn off heating when kids leave the door open confusion

Struggling with this, basically found an almost perfect example of what I want to do initially in the documentation -

Created new autromation and adjusted for my devices, but it just will not save.

image

I really can’t see where the problem in my codes is. It looks identical to the example to me

- id: backdoor_opened_automation
- alias: "Backdoor opened"
  trigger:
    - platform: state
      entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
      from: "off"
      to: "on"
  condition: []
  action:
    - service: scene.create
      data:
        scene_id: temp_before
        snapshot_entities: climate.home_thermostat
    - service: climate.set_temperature
      target:
        entity_id: climate.home_thermostat
      data:
        temperature: "15"
- alias: "Backdoor closed"
  trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    from: "on"
    to: "off"
  condition: []
  action:
  - service: scene.turn_on
    target:
      entity_id: scene.temp_before

IF i strip out the entire ‘Backdoor Closed’ section, remove the dash from the first -alias and just have an automation for the opening, i can save it and it works. Also if i create a second automation formatted the same (without the - in front of alias) that also saves and works. Giving me 2 automations, one for open and one for closing.

Am i being stupid and they are supposed to be 2 separate automations ? The documentation doesnt suggest that and shows it all in one.

THis is an example of just the opening automation in a state that works and allows me to save it

alias: Backdoor opened Turn Of Heating (record current heating value)
trigger:
  - platform: state
    entity_id:
      - binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    from: 'off'
    to: 'on'
    for:
      hours: 0
      minutes: 3
      seconds: 30
condition: []
action:
  - service: scene.create
    data:
      scene_id: temp_before
      snapshot_entities: climate.home_thermostat
  - service: climate.set_temperature
    target:
      entity_id: climate.home_thermostat
    data:
      temperature: '15'

The convention in the docs is that yaml examples should be formatted as if they are being entered in the configuration.yaml file. The example that you posted from the docs represents two seperate automations.

When you are using the ‘edit in yaml’ feature of the UI automation editor, the configuration looks a little different because the entry represents a single automation. You should create two automations or combine them using a Choose action as follows:

alias: "Backdoor opened and closed"
trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    from: "off"
    to: "on"
    id: open
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    from: "on"
    to: "off"
    id: close
condition: []
action:
  - choose:
    - conditions:
        - condition: trigger
          id: open
      sequence:
        - service: scene.create
          data:
            scene_id: temp_before
            snapshot_entities: climate.home_thermostat
        - service: climate.set_temperature
          target:
            entity_id: climate.home_thermostat
          data:
            temperature: "15"
    - conditions:
        - condition: trigger
          id: close
      sequence:
        - service: scene.turn_on
          target:
            entity_id: scene.temp_before
1 Like

This one reply has answered so much for me!

Thanks for clearing that up , I had no idea that all the examples posted in the docs were meant for the configuration file, no wonder ive been struggling to get some of them to work and have to mess around so much with formatting.

I like the logic you posted in the example, really easy to understand. Ive currently got to separate automations created, but im going to have a play with putting in config file and your version as well , just for a bit more practice.

Thanks for clearing so much up @Didgeridrew