Climate service automation - better way to do things?

Newbie here, still very much trying to learn.

I’m trying to set my AC (controlled via sensibo) onto a simple schedule. I tried using the automation editor, and after much banging on it, here’s what it produced:

    - id: '1539270728648'
      alias: Master Bedroom AC On
      trigger:
      - at: '11:00:00'
        platform: time
      condition: []
      action:
      - data:
          entity_id:
          - climate.master_bedroom_
        service: climate.turn_on
      - data:
          - entity_id:
            - climate.master_bedroom_
          - operation_mode:
            - cool
        service: climate.set_operation_mode
      - data:
          - entity_id:
            - climate.master_bedroom_
          - swing_mode:
            - stopped
        service: climate.set_swing_mode
      - data:
          - entity_id:
            - climate.master_bedroom_
          - fan_mode:
            - auto
        service: climate.set_fan_mode
      - data:
          - entity_id:
            - climate.master_bedroom_
          - temperature:
            - 73
        service: climate.set_temperature
    - id: '1539270797890'
      alias: Master Bedroom AC Off
      trigger:
      - at: '19:30:00'
        platform: time
      condition: []
      action:
      - service: automation.turn_off
        data:
          entity_id:
          - climate.master_bedroom_

Is this the right approach? Do I really need two separate automations, one to turn on, one to turn off? Is there a better way to set such a schedule? This isn’t too bad, but I’m planning on a true 7-day schedule, with 4 events on some days (turn on twice, turn off twice), for 8 different A/Cs, which would mean a huge number of automations.

Second, do I really need to do 5 separate service calls to put the unit in the right mode? Is there any way I can just feed all the parameters to the turn_on service or something? If there’s an easier way to do it, I’ve not found it so far.

Thanks!

ETA: It also mildly irks me that the automation editor puts “data” before “service”. I think it doesn’t matter? Just looks less tidy this way. I’d prefer to it the way the script syntax page shows:

      - service: notify.notify
        data:
          message: 'Turned on the ceiling light!'

But when I tried it this way, the editor couldn’t understand it…

I would take a look at this project and set up the schedule via Google Calendar or something similar:

1 Like

Also, I’m not sure if there’s a way to get around the 5 service calls, but you can at least put them all into a script and pass the parameters to that for reuse in other automations.

1 Like

I do see some oddness in your automation. You shouldn’t have dashes before each item inside data.

As for the order, data will always appear before service because d comes before s. One thing you’ll learn about the automation editor is that it sorts everything like a computer would sort things. Alphabetical. I think a change was made recently though to organize the top level of automations so that they now read alias, trigger, condtion, then action. That used to be in alphabetical order too, and it terrible to read.

I suggest getting used to editing yaml yourself through a text editor. Make sure you read up on yaml and whitespace for the yaml. Don’t mix tabs and spaces and make sure your section keys/labels are all lowercase.

1 Like