Shelly detached turning light by itself

Hello community,
I am completely new to the topic of Home Assistant. So if I’m forgetting any important information, please let me know.

For a few days now, I have had the problem that my Shelly switches trigger the automation for the light on their own. The Shelly 1 pm mini is running in detached mode and switches the light via the following automation:

alias: Smart light
description:
triggers:

  • entity_id:
    • binary_sensor.lichtschalter_eg_arbeitszimmer_input_0_input
      trigger: state
      conditions:
      actions:
  • action: light.toggle
    metadata: {}
    data: {}
    target:
    entity_id: light.deckenleuchte_eg_arbeitszimmer
    mode: single

The logbook shows that the Shelly is temporarily unavailable. After it is available again, the light switches.
My guess: The automation switches on every status change and not just on and off. Shortly before this happens, the router does a channel scan and sets the channels for the WLAN. So the Shelly briefly has no wifi and therefore switches the light?
How can this be avoided? Unfortunately I could not find a suitable entry.

Hi there. In order for us to be able to see your automation the right way you need to formt it using </> in the editor. The indenting and such is important, and it gets mangled if you just paste the code.

To get at what we can see: since you did not specify a from or to it does indeed trigger on any state change. It is best to listen fro changes from off to on and the other way around.

1 Like

What @Edwin_D said above. Post your correctly-formatted yaml.

Your trigger section should be something like this (note that this is only possible to set in yaml format, not in the UI)

triggers:
  - trigger: state
    entity_id:
      - binary_sensor.lichtschalter_eg_arbeitszimmer_input_0_input
    not_to: 
      - unavailable 
      - unknown 

PS - I would disable that automatic channel scan on your router - it’ll will cause you nothing but headaches