Multiple script from automation

I want to run multiple scripts from an automation, sequentially

I now have this

- alias: schedule heating
  initial_state: on
  trigger:
    - platform: state
      entity_id: binary_sensor.window_door_sensor
      from: "on"
      to: "off"
  action:
    - service: script.radiatorschedule
      data: {}
    - service: script.checksensors
      data: {}

the 2nd script is never run. What do I do wrong here?

What does the automation trace show?

I think this is what you are looking for?

Unexpected value for condition: '[{'condition': 'state', 'entity_id': 'binary_sensor.windows_sensor_kitchen', 'state': 'on'}]'. Expected and, device, not, numeric_state, or, state, sun, template, time, trigger, zone, a list of conditions or a valid template @ data['sequence'][1]. Got {'service': 'climate.turn_off', 'entity_id': 'climate.2_keuken', 'condition': [{'condition': 'state', 'entity_id': 'binary_sensor.windows_sensor_kitchen', 'state': 'on'}]}

looks like you have an error in the first script…

Unexpected value for condition: ‘[{‘condition’: ‘state’, ‘entity_id’: ‘binary_sensor.windows_sensor_kitchen’, ‘state’: ‘on’}]’. Expected and, device, not, numeric_state, or, state, sun, template, time, trigger, zone, a list of conditions or a valid template @ data[‘sequence’][1]. Got {‘service’: ‘climate.turn_off’, ‘entity_id’: ‘climate.2_keuken’, ‘condition’: [{‘condition’: ‘state’, ‘entity_id’: ‘binary_sensor.windows_sensor_kitchen’, ‘state’: ‘on’}]}

looking at the error, it looks like you have a service call (climate.turn_off) in a condition block. might be a tab/indent issue? can’t really tell b/c we can’t see the code.

The error I am getting is

The automation "schedule heating" (automation.schedule_heating) has an action that calls an unknown service: script.checksensors.

This is my script

checksensors:
  alias: Radiator.Checksensors
  repeat: 
    for_each: 
      - sensor: binary_sensor.window_sensor_living
        valve: climate.1_woonkamer
      - sensor: binary_sensor.windows_sensor_kitchen
        valve: climate.2_keuken
    sequence:
      - service: climate.turn_off
        entity_id: repeat.item.valve
        condition:
          - condition: state
            entity_id: repeat.item.sensor
            state: 'on'

This isn’t valid code. the indent’s wrong, it’s missing the sequence, that’s now how you do a foreach. that’s not how you reference repeat items, and i don’t know what you’re doing on the condition of the servic. trying to do an if? may not be necessary since you’re turning off something that’s off, but still…

looks like you may early in learning the yaml level programming? why not do this in the ui? almost every mistake would have been caught for you in the ui. the below might be closer to what you are trying to do, but not sure.

alias: Radiator.Checksensors
sequence:
  - repeat:
      for_each:
        - climate.1_woonkamer
        - climate.2_keuken
      sequence:
        - service: climate.turn_off
          entity_id: {{ repeat.item }} 

Yes, I do not work with Yaml that much. However creating it from the UI does not help, still getting errors
But I will keep on trying!

The UI will certainly help. It won’t magically solve all but it would have caught most of the errors you had (not all).

but start from what I gave you. Put it in via the UI… What errors are you still getting? You need to update your calling automation to call this but then you certainly should not get the unknown service error anymore…

So I ended up with writing an automation with an action with 3 conditions, all of which are checked and run a service if needed.