Automation with mode queued

Hey,
i like to run a automation as long as the condition is true, in my case it is a temperature over 60°C. Therefore i like to try it with the queued mode for the automation.
This is my yaml script.

alias: Thermische Desinfektion
description: ""
- mode: queued
  max: 2
  triggers:
    - trigger: numeric_state
      entity_id:
        - sensor.tempmessung_temp_6
      above: 60
  conditions: []
  actions:
    - action: switch.turn_on
      metadata: {}
      data: {}
      target:
        entity_id: switch.z_pumpe_switch1

I cant save the script, the displayed message looks like this:

Message malformed: extra keys not allowed @ data['-mode']

What do i wrong here ?
I think i made the yaml code like in the docs.

Best regards and a nice weekend
Kai

Try…

description: ""
mode: queued
triggers:
  - trigger: numeric_state

Having said that, I think the automation as you have it will turn on the switch when the temperature goes from 60 to 61 and never turn it off - is that what you want?

A trigger is not a condition - it starts the automation when the required change of state happens and that’s all. In this case it will fire again when the temperature drops below 60 and rises to 61 once more… and the switch will still not turn off. :grin:

Thank you for your replay.

The normal water temperature is 55°C, only once a week at night the temperature will rise to around 70°C (only at the top of the heater).

If thats is happening the pump should start at 60°C.
It is a very small circulation pump, so it takes a while to pump the water back to the heater.

At normal situation we switch that pump on and off with this automation:

alias: Z-Pumpe Timer
description: ""
mode: single
triggers:
  - type: turned_on
    device_id: 6b2afc6f66464831576b3e420a9dcc34
    entity_id: ad556791d2c3aa6a925456ba7abffc7f
    domain: switch
    id: zpumpe_on
    trigger: device
  - event_type: timer.finished
    event_data:
      entity_id: timer.z_pumpe_timer
    id: zpumpe_off
    trigger: event
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - zpumpe_on
        sequence:
          - data: {}
            target:
              entity_id: timer.z_pumpe_timer
            action: timer.start
      - conditions:
          - condition: trigger
            id:
              - zpumpe_off
        sequence:
          - data: {}
            target:
              entity_id: switch.z_pumpe_switch1
            action: switch.turn_off

The timer is set to 30 min.

My Plan with the queued automation is to run the pump until the tempreture turns under 60°C.

Best regards
Kai

How about two triggers?

description: ""
mode: single
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.tempmessung_temp_6
    above: 60
    id: above
  - trigger: numeric_state
    entity_id:
      - sensor.tempmessung_temp_6
    below: 60
    id: below
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - above
        sequence:
          - action: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.z_pumpe_switch1
      - conditions:
          - condition: trigger
            id:
              - below
        sequence:
          - action: switch.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: switch.z_pumpe_switch1

Yeah, why not.
I will try it tomorrow.
Thank you for your answer.

I have one more question, if i made it like this:

description: ""
mode: queued
triggers:
  - trigger: numeric_state

where do i write down the

max: 2

argument ? Directly under the it, like ?

description: ""
mode: queued
max: 2
triggers:
  - trigger: numeric_state

Best regards
Kai

I think that goes right at the end.

description: ""
mode: queued
triggers:
  - trigger: numeric_state

etc.
etc.

max: 2

Based on what you have posted, I don’t see the point in using the queued mode. In fact, it might actually be contraindicated… if the temperature is bouncing around the setpoint, you don’t want to be turning the pump on and off over and over quickly. Normally it would be preferred to add a duration to your trigger, so that the pump is only powered when the temperature has been across the threshold stably.

description: ""
mode: single
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.tempmessung_temp_6
    above: 60
    for: "00:30:00"
    id: above
  - trigger: numeric_state
    entity_id:
      - sensor.tempmessung_temp_6
    below: 60
    for: "00:30:00"
    id: below
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - above
        sequence:
          - action: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.z_pumpe_switch1
      - conditions:
          - condition: trigger
            id:
              - below
        sequence:
          - action: switch.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: switch.z_pumpe_switch1
Compact version using templating
description: ""
mode: single
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.tempmessung_temp_6
    above: 60
    for: "00:30:00"
    id: "on"
  - trigger: numeric_state
    entity_id:
      - sensor.tempmessung_temp_6
    below: 60
    for: "00:30:00"
    id: "off"
conditions: []
actions:
  - action: "switch.turn_{{ trigger.id }}"
    metadata: {}
    data: {}
    target:
      entity_id: switch.z_pumpe_switch1
3 Likes