Light turn on after rebooting HA

Hello, it is few weeks that sometime when I reboot HASS, some specific light turn on.
I dig into the log and I noticed that only the light attached with a shelly 1 switch have this behaviour.
I changed the internal settings of the shelly to be a detachable switch so when a user presses the physical button nothing happens, it just changes the internal state of the shelly. Then I exploited this to create an automation so whenever a user presses the physical button it can turn on the light or do whatever the automation said to do.
So I created this automation:

alias: Shelly luce camera input
description: Accende e spegne il gruppo camera basandosi sul detached switch mode di Shelly
trigger:
  - platform: state
    entity_id:
      - binary_sensor.bedroom_switch_outlet_input
    from: null
    to: null
condition:
  - condition: not
    conditions:
      - condition: state
        entity_id: binary_sensor.bedroom_switch_outlet_input
        state: unavailable
action:
  - if:
      - condition: state
        state: "on"
        entity_id: light.bedroom_lights_headboard_group
    then:
      - service: light.turn_off
        data: {}
        target:
          entity_id: light.bedroom_lights_headboard_group
    else:
      - if:
          - condition: state
            state: "off"
            entity_id: light.bedroom_lights_headboard_group
        then:
          - service: light.turn_on
            data:
              kelvin: 6500
              brightness_pct: 100
            target:
              entity_id: light.bedroom_lights_headboard_group
mode: single

This is the log I grab few mins ago


Does somebody use shelly and noticed the same behaviour? Is really annoying and it turns on almost the whole house and I cant understand why

up?

Can somebody help?
It happens a lot lately that during the night the lights turn on… I also noticed that when my internet connection goes offline and then come back it happens…
Its the automation but dont know how to fix

Try this version:

alias: Shelly luce camera input
description: Accende e spegne il gruppo camera basandosi sul detached switch mode di Shelly
trigger:
  - id: '100'
    platform: state
    entity_id:
      - binary_sensor.bedroom_switch_outlet_input
    not_from: 'unavailable'
    to: 'on' 
  - id: '0'
    platform: state
    entity_id:
      - binary_sensor.bedroom_switch_outlet_input
    not_from: 'unavailable'
    to: 'off' 
condition: []
action:
  - service: light.turn_on
    data:
      kelvin: 6500
      brightness_pct: '{{ trigger.id }}'
    target:
      entity_id: light.bedroom_lights_headboard_group
mode: single
1 Like

what is id 100 and id 0?
EDIT: ok I get it, lets see if it works :slight_smile:

Thank you.
It doesnt wake me up at night anymore

1 Like

I noticed an error. If I turn off the light from the app and then press the physical switch It won’t turn on and I have to press it again to turn it on.
How can it be fixed?

The Home Assistant app?

What is the state of binary_sensor.bedroom_switch_outlet_input when you press the physical switch?

It switches between clear and detected but when turn on/off the light from the HA app it doesnt switch the status of the bedroom_switch_outlet_input
I explain myself a bit bad sorry :slight_smile:

Do you think that behavior might have something to do with this?

No its related to the automation because its check the value of the switch and not if the light is on or off like it was before in my automation.
if light on and switch changes state light goes off and viceversa. But Im not sure how to do that.
Maybe something like that?

action:
  - choose:
      - conditions:
          - condition: state
            entity_id: light.bathroom_lights_group
            state: "off"
        sequence:
          - service: light.turn_on
            data:
              kelvin: 3000
              brightness_pct: "{{ trigger.id }}"
            target:
              entity_id: light.bathroom_lights_group
      - conditions:
          - condition: state
            entity_id: light.bathroom_lights_group
            state: "on"
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.bathroom_lights_group
            data: {}

but im not good at yaml so Im not sure it is right

Did it fix the problem?

Nope it doesnt

Why it is so hard to setup yaml :frowning:
Im gonna try again using editor and removing the id section you used to set the brightness