Switch device OFF - repeat command

Hello,

I would like to ask you for help with one automation. I created irrigation system automation, and it is working as I want, but I have one problem with that.
All 8 Z-wave relays, which controlling valves have week signal and sometimes, it happens to me, that after defined time, HA switch relays OFF, but command does not arrive. Frequency once per month approx… If this happens, I just switch it OFF manually. Unfortunately, irrigation system than run for example 2h more.

Is there a chance to detect, that relay did not receive command to switch OFF and repeat command?

Or more simple, try one more time OFF command to be sure?

My automation is below:

alias: Závlaha sprinklery
description: ""
mode: single
triggers:
  - id: "1"
    at: input_datetime.zavlaha_sprinklery_hlavni_plocha_start
    trigger: time
  - id: "2"
    at: input_datetime.zavlaha_sprinklery_hlavni_plocha_konec
    trigger: time
  - id: "3"
    at: input_datetime.zavlaha_sprinklery_vedlejsi_plocha_start
    trigger: time
  - id: "4"
    at: input_datetime.zavlaha_sprinklery_vedlejsi_plocha_konec
    trigger: time
conditions:
  - condition: state
    entity_id: input_boolean.aktualne_dest
    state: "off"
actions:
  - if:
      - condition: trigger
        id:
          - "1"
    then:
      - target:
          entity_id: switch.zavlaha_smartswitch_1_zwave_2
        data: {}
        action: switch.turn_on
  - if:
      - condition: trigger
        id:
          - "2"
    then:
      - target:
          entity_id: switch.zavlaha_smartswitch_1_zwave_2
        data: {}
        action: switch.turn_off
  - if:
      - condition: trigger
        id:
          - "3"
    then:
      - target:
          entity_id: switch.zavlaha_smartswitch_3_zwave
        data: {}
        action: switch.turn_on
  - if:
      - condition: trigger
        id:
          - "4"
    then:
      - target:
          entity_id: switch.zavlaha_smartswitch_3_zwave
        data: {}
        action: switch.turn_off

i edit your code to add delay and conditions to check if is On
take a look

alias: Závlaha sprinklery
mode: single
trigger:
  - id: "1"
    at: input_datetime.zavlaha_sprinklery_hlavni_plocha_start
    platform: time
  - id: "2"
    at: input_datetime.zavlaha_sprinklery_hlavni_plocha_konec
    platform: time
  - id: "3"
    at: input_datetime.zavlaha_sprinklery_vedlejsi_plocha_start
    platform: time
  - id: "4"
    at: input_datetime.zavlaha_sprinklery_vedlejsi_plocha_konec
    platform: time
condition:
  - condition: state
    entity_id: input_boolean.aktualne_dest
    state: "off"
action:
  - choose:
      - conditions:
          - condition: trigger
            id: "1"
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.zavlaha_smartswitch_1_zwave_2

      - conditions:
          - condition: trigger
            id: "2"
        sequence:
          - service: switch.turn_off
            target:
              entity_id: switch.zavlaha_smartswitch_1_zwave_2
          - delay: "00:00:05"  # Wait 5 seconds
          - condition: state
            entity_id: switch.zavlaha_smartswitch_1_zwave_2
            state: "on"
          - service: switch.turn_off
            target:
              entity_id: switch.zavlaha_smartswitch_1_zwave_2

      - conditions:
          - condition: trigger
            id: "3"
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.zavlaha_smartswitch_3_zwave

      - conditions:
          - condition: trigger
            id: "4"
        sequence:
          - service: switch.turn_off
            target:
              entity_id: switch.zavlaha_smartswitch_3_zwave
          - delay: "00:00:05"
          - condition: state
            entity_id: switch.zavlaha_smartswitch_3_zwave
            state: "on"
          - service: switch.turn_off
            target:
              entity_id: switch.zavlaha_smartswitch_3_zwave

this will Retry the off command after a short delay if the relay is still on

1 Like

I do that for all control commands. Meaning send command, wait with a timeout for the change to be reflected back and retry up to three times with increasing delays. I did this via autogenerating scripts.

There is a custom component that does this and at some point I’ll discard those scripts and move over. Interestingly the use case they talk about is an irrigation system not turning off.

1 Like

nice didnt know about this one, thanks will make my life easier :slight_smile:

Thank you, was not aware of this. Will try.

Thank you very much I will test that.

OMG! You learn new things every day!! This is needed, previously I used an automation with a delay!

You can also try waiting a bit, then pining the node, then waiting, then checking the status. The ping (if it gets through the network) should update the status. The problem with just waiting 5 seconds is that unless the device decides to send a new status update during that time I’m not sure why it would update the status.

-David