More than one action in an automation with delay in between

I’m a bit stumped here. I have an automation that I need to add another action to, with a delay between. Can somebody please tell me where I went wrong? This is the original:

- alias: Termostater til 5 grader
  action:
    data_template:
      node_id: '{{ trigger.payload }}'
      parameter: 10
      value: 50
  - service: zwave.set_config_parameter
  condition: []
  id: '1524675052575'
  trigger:
    platform: mqtt
    topic: ZWaveTermostatAv

What I want to get to, is this:

- alias: Termostater til 5 grader
  action:
    data_template:
      node_id: '{{ trigger.payload }}'
      parameter: 10
      value: 50
  - service: zwave.set_config_parameter
    data_template:
      node_id: '{{ trigger.payload }}'
      parameter: 2
      value: 'Heat'
  - service: zwave.set_config_parameter
  - delay: ‘00:00:05’
  condition: []
  id: '1524675052575'
  trigger:
    platform: mqtt
    topic: ZWaveTermostatAv

Even adding the delay with nothing more gives me errors:

Configuration invalid

Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block mapping in “/home/homeassistant/.homeassistant/automations.yaml”, line 110, column 3 expected , but found ‘-’

I guess it’s the dashes, I have never gotten a handle of those. Most of my automations do not have them at all, since they are only one action each. But I have read that I need to use them with more actions in one automation.

Here’s a delay in one of my automations.

  action:
  - data:
      entity_id: cover.big_door
    service: cover.open_cover
  - delay: 00:00:40

Notice the difference in formatting.

Change the quotes around your delay time to not be fancy ones:

 delay: ‘00:00:05’

Thanks! That lead me to this, which works with the delay:

  • alias: Termostater til 30 grader
    action:
    • data_template:
      node_id: ‘{{ trigger.payload }}’
      parameter: 10
      value: 300
      service: zwave.set_config_parameter
    • delay: 00:00:05
      condition:
      id: ‘1524674475038’
      trigger:
      platform: mqtt
      topic: ZWaveTermostatPaa

I SERIOUSLY hate the code tagging here, it’s totally hit or miss…

It’s really not.

three backticks, new line, paste code, new line, three backticks.

2 Likes

really? I’m using the code mark in the toolbar, I didn’t know about that one…

It really isn’t.

Put three consecutive back-quotes ``` on a separate line before your code.
Put three consecutive back-quotes on a separate line after your code.

Was the automation created using the automation editor? It looks like it came out of a blender.

The usual order of presentation is trigger, condition, action but this one has them reversed. It’s like reading a novel backwards.

1 Like

Yeah, it works. And I know it’s backwards, no idea why it’s like that, though. It’s a year since that one was made. Edit: And no, the editor is useless for me. It messes up Norwegian characters in automations.

But this seems to work too:

  trigger:
    platform: mqtt
    topic: ZWaveTermostatAv
  condition: []
  action:
  - data_template:
      node_id: '{{ trigger.payload }}'
      parameter: 10
      value: 50
    service: zwave.set_config_parameter
  - delay: 00:00:05
  - data_template:
      node_id: '{{ trigger.payload }}'
      parameter: 1
      value: 'Heat'
    service: zwave.set_config_parameter
  id: '1524675052575''

No, it doesn’t… It won’t send to the thermostate because it can’t use “trigger.payload” in the second action. I don’t know this language at all, can I set the trigger.payload in the first data template to a variable in any way?

Correct me if I’m wrong in this little warning but… I have seen automations with multiple sequence events not proceed to the second event if the first one fails. It appears that upon any event failure in the sequence will cause the entire automation to puke.

That’s not true. I just tested this example and confirmed the second instance of trigger.payload works as expected.

- alias: 'variable tester'
  trigger:
    platform: mqtt
    topic: test
  action:
  - service: light.turn_on
    data_template:
      entity_id: '{{ trigger.payload }}'
  - delay: 00:00:05
  - service: light.turn_off
    data_template:
      entity_id: '{{ trigger.payload }}'

123, You seem to be right. :frowning: Because I see this in my log now (didn’t think to look there before):

Error while executing automation automation.termostater_til_5_grader. Service not found for call_service at pos 1: (ServiceNotFound(…), ‘Service zwave.set_config_parameter not found’)

if ever you run into troubles with delay, use

delay:
  seconds: 5

or minutes etc etc of course. Has more than 1 issue on this community solve with that, unexplainably maybe, but voila.

yess. completely right! and please use 2 spaces before the dashes. Makes it less prone to indenting errors and read so much better (and use multiline to prevent quoting issues…):

- alias: 'variable tester'
  trigger:
    platform: mqtt
    topic: test
  condition: []
  action:
    - service: light.turn_on
      data_template:
        entity_id: >
          {{ trigger.payload }}
    - delay: 
        seconds: 5
    - service: light.turn_off
      data_template:
        entity_id: >
         {{ trigger.payload }}

OK, thanks! So…any idea what it isn’t working with setting the second config option when it does set the first one?

The error message refers to an automation called termostater_til_5_grader.

Error while executing automation automation.termostater_til_5_grader. Service not found for call_service at pos 1: (ServiceNotFound(…), ‘Service zwave.set_config_parameter not found’)

Is that the automation you posted here or another one? The one you posted here doesn’t have that name.

Sorry, I’m working on both at the same time, they are two sides of the same action. But I have gotten rid of the error, it just doesn’t seem to do anything. Is it possible that the correct command isn’t the set config parameter, but something else? And where would I find that?

Edit: I can set the operation mode from the dashboard. And from the Z-Wave Control Panel.

Found it, with help (of course). It was very logical… :rofl: Temperature uses zwave.set_config_parameter based on the node_id of the device, while mode uses climate.set_operation_mode based on the name of the device.