Shelly i3 triggers automations when becoming available or detected

Good day,
I noticed my lights started toggling in my kitchen without explanation. It seems the problem is one of my two Shelly i3 in there. It regularly goes between Unavailable and Detected in HA. Every time it is detected, it triggers the automation to toggle the lights. I believe the issue is due to wifi signal (WiFi RSSI: -84 dBm). Outside of fixing the wifi issues, is there a known way to stop it from triggering every time it is detected again?

Share your automation here so we can propose something…

But usually when this happens it is related to not having selected the “from” field in the trigger. When the device recovers the wifi, it’s state changes from unknown to off or from unknown to on, and this is sufficient to trigger the automation unless you have the from field used.

Something like this:

alias: New Kitchen Light Switches - Chand
description: ""
trigger:
  - type: powered
    platform: device
    device_id: 25ce
    entity_id: binary_sensor.shellyix3_channel_3_input
    domain: binary_sensor
  - type: not_powered
    platform: device
    device_id: 9ae9
    entity_id: binary_sensor.shellyix3_channel_3_input
    domain: binary_sensor
 condition: []
action:
  - type: toggle
    device_id: 3a550
    entity_id: switch.kitchen_chandelier
    domain: switch
mode: single

Mine has pretty thin options as it has power or not powered, both of which should toggle it for me.

The only available triggers on the i3 are inputs powered or not powered (1, 2, 3 inputs) and Reboot Has Been Pressed.

Try this:

alias: New Kitchen Light Switches - Chand
description: ""
trigger:
  - platform: state
    entity_id: binary_sensor.shellyix3_channel_3_input
    from:
      - "on"
      - "off"
    to:
      - "on"
      - "off"
condition: []
action:
  - type: toggle
    device_id: 3a550
    entity_id: switch.kitchen_chandelier
    domain: switch
mode: single

This will trigger only when it changes from “on” to “off” or from “off” to “on”, so it ignores the “unknown” states happening when the wifi fails.

I use a Blueprint doing exactly what you are trying to do:
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.
This Blueprint will control a light, but yoy can easily create a helper to have your switch as a light. Or I can edit the Blueprint if you want use that.

Hey Edward,

Thanks. I am just getting back to this after being out of the country for an extended time. Having some issues as the state trigger does not seem to work…

From the entity log, it seems to have three possible states:
Detected - i.e., turned on
Cleared (no detected) - i.e., turned off
Became unavailable - i.e., lost contact with network due to whatever reason

The problem being that when Became Unavailable reverts to Detected or Cleared, then the lights switch. I think what you wrote was close, but not quite working. I am also dealing with old Z-wave on the lights and it is just another joy when it has issues.

Thoughts?