After general power off lights are on :-(

I have a lights connected to home assistang by wifi . The issue that i have is that when there is a general shutdown, the light being in the off state, when the light comes back it turns on.
Any idea for home assistant to maintain/remain its state before the general shutdown of the light?

thanks!

up!
any update?

no info or help?

What lights ? If tasmota check poweronstate

Hi @francisp I have the issue with two light that are:

  • Xiaomi Philips Lamp
  • Xiaomi Philips Downlight

the lights are connected to my wifi and static ip has been assigned.

here the setup:

light:

  • platform: xiaomi_miio
    name: Xiaomi Philips Lamp
    host: 1x2.1xx.x.2x0
    token: ac96----------------9229
    model: philips.light.bulb

  • platform: xiaomi_miio
    name: Xiaomi Philips Downlight
    host: 1x2.1xx.x.2x0
    token: b5e8--------------64e
    model: philips.light.downlight

Could be that is intended behavior of these lights, in case a dumb switch is used.

@francisp, yes, could be, in fact if you don’t control the light with home assistant you can have a “dumb switch” and on / off the light, as normal light so the behavior is absolutely normal.
the smart here is try to control this normal behavior in home assistant and turn on or off the light in base to the old state after power outage for instance.

Those are not running Tasmota or any other custom firmware, so I think you can’t change their behaviour.

What you can do is configure an automation that turns everything back off when HA starts up, but it may take a while, since WiFi and everything needs to come back first.

@Valentino_Stillhardt yes, this is the only option that i can see, but i have multiple use causes that can do that a simple automation doesnt work well, for instance , at night i have one of this light on and i have in this moment a power outage, when home assistant come back will apply the automation to turn off the light without control that one of this light was in state on after the power outage.
:-/

You could also use Yeelight app (or mi home app) to set the power on state. You can choose from on, off or same as before the power cut

1 Like

@makai

    Xiaomi Philips Lamp
    Xiaomi Philips Downlight

are not Yeelight components

So it may be ok with Mi Home app?

After a power outage, the bulbs turn on on their own, but the automation below monitors this event and turns them off:

- alias: Auto turning off the lights
  trigger:
    - platform: event
      event_type: state_changed
  condition:
    - condition: template
      value_template: "{{ trigger.event.data.entity_id.split('.')[0] == 'light' }}"
    - condition: template
      value_template: "{{ trigger.event.data.new_state.state == 'on' }}"
    - condition: template
      value_template: "{{ trigger.event.data.new_state.context.parent_id is none }}"
    - condition: template
      value_template: "{{ trigger.event.data.new_state.context.user_id is none }}"
  action:
    - service: light.turn_off
      data_template:
        entity_id: "{{ trigger.event.data.entity_id }}"
1 Like

thanks @Otnow , will be tested in next power outage :stuck_out_tongue:

@otnow
it doesn’t seem to be working. When I switch on a light of my lamp, coming from a normal off state, it is automatically switched off by this automation.
here you have the image:

Capture

@takezo How did you turn on the lamp: from HA or an electric switch?

@Otnow pressing the lamp button.

@takezo Button in Home Assistant?

@Otnow you mean to turn it on from the Home Assistant button?
in this way it works well and remains on.

@takezo

The automation I proposed automatically turns off the lamp only if it was not turned on by the user using a button in the Home Assisatnt interface ( trigger.event.data.new_state.context.user_id is none ) or if it was not turned on by some other automation ( trigger.event.data.new_state.context.parent_id is none ).

In other words, a lamp that does not remember its last state after a power outage must be constantly connected to the mains and turned on / off only by software, and not using a physical switch, because this de-energizes it when it is turned off, which is tantamount to a general power outage.