Switch off command autoamtion doesn't work

any idea why the last off command doesn’t apply- it is my irrigation system ?

alias: Hashkaya
description: ''
trigger:
  - platform: time
    at: '06:00:00'
condition:
  - condition: time
    before: '00:00:00'
    weekday:
      - sun
      - tue
      - thu
    after: '00:00:00'
action:
  - type: turn_on
    device_id: d202923372849746f0ab3c3247cd6de4
    entity_id: light.watering_system_on_off_2
    domain: light
  - delay:
      hours: 0
      minutes: 20
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: d202923372849746f0ab3c3247cd6de4
    entity_id: light.watering_system_on_off_2
    domain: light
  - type: turn_on
    device_id: d202923372849746f0ab3c3247cd6de4
    entity_id: light.watering_system_on_off_3
    domain: light
  - delay:
      hours: 0
      minutes: 20
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: d202923372849746f0ab3c3247cd6de4
    entity_id: light.watering_system_on_off_3
    domain: light
  - type: turn_on
    device_id: d202923372849746f0ab3c3247cd6de4
    entity_id: light.watering_system_on_off_4
    domain: light
  - type: turn_on
    device_id: 850607c94f1c3f1e98efdc20e7d06c05
    entity_id: light.t3_water_system_on_off
    domain: light
  - delay:
      hours: 0
      minutes: 20
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: d202923372849746f0ab3c3247cd6de4
    entity_id: light.watering_system_on_off_4
    domain: light
  - type: turn_off
    device_id: 850607c94f1c3f1e98efdc20e7d06c05
    entity_id: light.t3_water_system_on_off
    domain: light
mode: single

connected to this switch

Which integration is used for your irrigation system?

Typically, an irrigation system’s valves are represented as switch entities but yours are modeled as light entities. I’m curious to know why.

it’s a zigbee Link
the first two switches turns off, only the last part of the automation, stays on

When you say “last part” do you mean the two Device Actions after the delay fail to work?

  - delay:
      hours: 0
      minutes: 20
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: d202923372849746f0ab3c3247cd6de4
    entity_id: light.watering_system_on_off_4
    domain: light
  - type: turn_off
    device_id: 850607c94f1c3f1e98efdc20e7d06c05
    entity_id: light.t3_water_system_on_off
    domain: light

Or do you mean only the last Device Action fails to work?

this dosn’t work

  - type: turn_off
    device_id: d202923372849746f0ab3c3247cd6de4
    entity_id: light.watering_system_on_off_4
    domain: light
  - type: turn_off
    device_id: 850607c94f1c3f1e98efdc20e7d06c05
    entity_id: light.t3_water_system_on_off
    domain: light
mode: single

“last part”: two devices stays on and dosn’t turn off:

While the automation’s delay statement is counting down 20 minutes, Home Assistant must not be restarted, no automations should be reloaded and if you use the Automation Editor you must not create/modify any automations. If you do any of those things, it cancels all automations that are in progress and reloads all of them. That means the automation’s delay is cancelled and it never gets to execute the last two Device Actions.

1 Like

checked again. that is not the problem :weary:

Check the automation’s trace to determine if it actually executes the last two Device Actions.

If it does execute them, but the physical devices fail to turn off, there’s a problem with the transmission of the “turn off” command to the devices (might be a Zigbee integration/communication issue).

Anyway, the trace will provide you with clues.

I believe the condition is wrong.
The trigger (time) has a start at 06:00… and everything next is supposed to act on that condition which is is placed between 0:00 and 0:00.
You should use Trigger ID’s. If something is on, than do this. If it’s off, do that… etc.

The automation is well beyond the condition and already executing its action. All Device Actions are successful except the last two. How do you figure the condition is responsible for that?

You’re right. The actions are already beyond the condition.
But a condition based on time stating before 0:00 and after 0:00 always make wonder what would happen. I would never use a condition like that.

I have a bunch of zigbee switches (also present themselves as lights) and have found it necessary to place a delay between commands like:

          sequence:
            - service: light.turn_on
              target:
                entity_id:
                  - light.tz3000_excgg5kb_ts0004_f9584e43_on_off
            - delay: 2
            - service: light.turn_on
              target:
                entity_id:
                  - light.tz3000_excgg5kb_ts0004_f9584e43_on_off_2
            - delay: 2
            - service: light.turn_off
              target:
                entity_id:
                  - light.tz3000_excgg5kb_ts0004_f9584e43_on_off_3
            - delay: 2
            - service: light.turn_off
              target:
                entity_id:
                  - light.tz3000_excgg5kb_ts0004_f9584e43_on_off_4

Not sure I understand why but it is now reliable.

After migrating from virtual box to a dedicated x86-64 machine i had the same problem with my automations. adding a delay also helped for me… strange though… it was just the switch.turn_off commands that were afected. turning off lights was working fine.