Default power on behaviour - on_boot vs restore_mode

Hi All,

I’m having trouble with some Mirabella Genio lights (Tuya based?) that I have OTA flashed with ESPHome.

The behaviour that I would like to replicate is the default behaviour of most smart bulbs:

When I turn the light on at the wall, I would like it to immediately come on to full brightness, as if it had no smarts at all. Once it’s on and connected to the network, any automations and control would obviously work.

I have attempted to use the example given in the ESPHome cookbook:
https://esphome.io/cookbook/mirabella-genio-bulb.html

but this doesn’t make the bulb come on immediately - it actually doesn’t come on at all.

I can fiddle with the on_boot priority to make it work, but only if I adjust it to come on after wifi is initialised (priority -10), which is too slow.

Any higher priority doesn’t work - some priorities cause a very brief flicker on and then it stays off.

I think I’d like to use something more akin to restore_mode as applied to the GPIO Switch platform, but I don’t think this can be applied to a light platform through a PWM GPIO

anyone got any advice?

1 Like

I’m also having the same issue and would be keen to hear any suggestions.

This worked for me, of course add your wifi and other stuff in there.

 esphome:
  name: outside_light
  platform: ESP8266
  board: esp01_1m
 
# Ensure the light turns on by default if the physical switch is actuated.
  on_boot:
    priority: 30
    then:
      - light.turn_on:
          id: light
          brightness: 100%
 
light:
  - platform: monochromatic
    name: "Outside Light"
    id: light
    output: output_component1

output:
  - platform: esp8266_pwm
    id: output_component1
    pin: GPIO13
1 Like

Thanks for that. This works, although it’s a little slower than I’d like it to be.

I Think there might be some funny hardware startup transient states that it goes through on power up - I’ll try to get an oscilloscope on it to check

For anyone reaching this:
Adding restore_mode: ALWAYS_ON makes the power-on instantaneous.

Also, I added a soft power-off that fades the light over the next 30 seconds. Here’s the modified example:

 esphome:
  name: outside_light
  platform: ESP8266
  board: esp01_1m
 
# Now the light turns on if the physical switch is actuated, and fades to OFF over 30s.
  on_boot:
    then:
      - light.turn_off:
          id: light
          transition_length: 30s
 
light:
  - platform: monochromatic
    name: "Outside Light"
    id: light
    output: output_component1
    restore_mode: ALWAYS_ON

output:
  - platform: esp8266_pwm
    id: output_component1
    pin: GPIO13

This prevents the lights from staying ON after a power outage, while giving some illumination in case you happen to flip the switch :slight_smile:

1 Like