Make a verification that a action in a automation executed

Hi! I’m a total newbie on Home Assistant. I managed to do lot’s with it, but I’m struggling with a problem.
I apologize right now, but not only English is not my native language, it’s easy to get confused when trying to explain in written words what I am trying to do.
So, I have an automation that runs at a specific time, and that automation turns off some lights in the house.
Due to my Wifi not being very reliable, at least that’s what I think the reason is, sometimes, not very often, some lights don’t get turned off.
So I started to see of a way to get a message if any of the lights stayed on after the automation executed.
I was looking to something like this example, I thought it was exactly what I needed. But I fail to get it to work:

https://community.home-assistant.io/t/adding-a-verification-step-to-ensure-that-an-automation-has-fired-correctly/359834

Then I thought I should go the simple way, I created another automation, that runs few minutes after the one I mentioned, and what it does is so simple I don’t understand why it’s not working. I make 4 If conditions checking the lights one by one, if any of them is on, I send a message.
Problem is, for example, if light number 2 in the test is on I get a message and the automation does not test the others, number 3 and 4…
I thought the mode option was the solution, but from reading the documentation I think it’s not because it only reschedules or restarts the automation.

Here is the code for the automation:

alias: Check Lights Out
description: Cheks if all lights really went off
trigger:
  - platform: time
    at: "00:01:00"
condition: []
action:
  - if:
      - condition: device
        type: is_on
        device_id: 42e07ffd683289694123b80fd640ebee
        entity_id: ab37a1d6f5a7b6fcf9f25fafcd70d26e
        domain: switch
    then:
      - service: notify.mobile_app_x52x
        data:
          message: Luz Abrigo Exterior não apagou!!
  - if:
      - condition: device
        type: is_on
        device_id: 100d9fffe8e5b879144f977bc1358b00
        entity_id: 9a03dcce7febb7be69677245e1fe5008
        domain: switch
    then:
      - service: notify.mobile_app_x52x
        data:
          message: Luz perimetro não apagou!!
  - if:
      - condition: device
        type: is_on
        device_id: a79b1683f2b256b37bf88bb4cb9c65ae
        entity_id: b88bf1331b8e25864ea984e40ee4cf94
        domain: switch
    then:
      - service: notify.mobile_app_x52x
        data:
          message: "Luz alpendre canto não apagou!! "
  - if:
      - condition: device
        type: is_on
        device_id: 39c9f9bb6c2af0e71c9bc4d4f0e438eb
        entity_id: a5bc85045cc0635dab63343e340e07ad
        domain: switch
    then:
      - service: notify.mobile_app_x52x
        data:
          message: Luz alpendre janela não apagou!!
mode: single

Can anyone help me? Thank in advance!

I believe your ‘unreliable’ wifi will cause the same issue with identifying what is left on as it does with turning it off.

If that is really the issue, then no way around it.

But, I have to ask … why is your wifi unreliable? Is it your router? Or what. Because, current wifi hardware is pretty darn reliable.

Apart from your Wifi problems, you could use parallel:


action:
  - parallel:
      - if:
        then:
      - if:
        then:

Or use match: any as condition:


condition:
  condition: state
  entity_id:
    - switch.a
    - switch.b
    - switch.c
  match: any
  state: "on"

action:
  service: notify.xy

I wouldn’t use devices but entities.

Yeah, I think it is the router. It’s one provided by the company that I rent internet access. I’m going to change it, just not right now.

Thank you very much. I will try both your advices and give feedback.

Told you I was a newbie. 4 if statements, what an error…

Ha. Sorry. I did not even look at your code.

Just answered from the description.

Thank you for trying to help.

After trying to do some adjustment to get clear notifications of what light stayed on, I went for the parallel if.

Worked like a charm!

Thank you.

It’s possible to compute the name of the switches that are on:


condition:
  condition: state
  entity_id:
    - switch.a
    - switch.b
    - switch.c
  match: any
  state: "on"

action:
- service: notify.mobile_app_x52x
  data:
    message: |-
      {% set switches = [states.switch.a, states.switch.b, states.switch.c]|selectattr('state', 'eq', 'on')|map(attribute='name')|list %}
      {{' and '.join((switches|join(', ')).rsplit(', ', 1)) }}{{ ' are' if switches |count > 1 else ' is' }} still on!