Light is turning off every day at 6PM and 5AM without any action

I built a CO2 sensor with ESP Home that signals the air quality through different colors on an LED strip (green/yellow/red). Now I have the phenomenon that the LEDs are turned off every day at 5:00 AM (Status LED / NeoPixel Light) even though there is no configuration for this. However, I turn off my Wi-Fi at night, which is reactivated at 5:00 AM. But I can’t find any reason why the LEDs are turned off after the Wi-Fi is turned back on. The turning off of the LEDs is shown in the logbook.

Does anyone have any idea what could be causing this? I would greatly appreciate any feedback.

Likely a reboot from the wifi coming back up, but without the (correctly-formatted) ESPHome config, we’re guessing.

I have no idea. This is my config:

esphome:
  name: co2-sensor-2

esp8266:
  board: d1_mini

# Enable logging
logger:


# Enable Home Assistant API
api:
  encryption:
    key: xxx

  services:
    - service: recalibrate_scdx_co2
      variables:
        actual_co2: int
      then:
        - scd30.force_recalibration_with_reference:
            value: !lambda 'return actual_co2;'    

external_components:
  - source: github://bekriebel/esphome@scd30_force_calibration_with_reference
    components: [ scd30 ]

# Example configuration entry
switch:
  - platform: restart
    name: "co2-sensor-2 Restart"

ota:
  platform: esphome
  password: "db19f7bad7a0214cd0aa0846ed9211e0"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Co2-Sensor-2 Fallback Hotspot"
    password: "mgH7mhfIK4G8"

# Example configuration entry for ESP32
i2c:
  sda: GPIO4
  scl: GPIO5
  scan: true
  id: bus_a

# Example configuration entry
sensor:
  - platform: scd30
    co2:
      name: "co2-Sensor-2"
      on_value_range: # Schwellwerte für die Ampel
        - below: 1000
          then:
            - light.turn_on:
                id: co2_status_led
                brightness: 30%
                red: 0%
                green: 100%
                blue: 0%
        - above: 1000
          below: 1400
          then:
            - light.turn_on:
                id: co2_status_led
                brightness: 30%
                red: 100%
                green: 80%
                blue: 0%
        - above: 1400
          then:
            - light.turn_on:
                id: co2_status_led
                brightness: 35%
                red: 100%
                green: 0%
                blue: 10%
    update_interval: 10s
    temperature:
      name: "co2-Sensor-2 Temperatur"
      accuracy_decimals: 1
    humidity:
      name: "co2-Sensor-2 Luftfeuchtigkeit"
      accuracy_decimals: 1
    automatic_self_calibration: off
    temperature_offset: 1.5 °C
    address: 0x61
    altitude_compensation: 105m

# Example configuration entry
light:
  - platform: neopixelbus
    type: GRB
    variant: WS2812X
    pin: GPIO3
    num_leds: 10
      
    name: "NeoPixel Light"
    id: co2_status_led
  - platform: partition
    name: "CO2 Status LED"
    id: section1
    segments:
      - id: co2_status_led
        from: 0
        to: 9
captive_portal:

Try disabling the reboot and AP timeouts:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  reboot_timeout: 0s

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Co2-Sensor-2 Fallback Hotspot"
    password: "mgH7mhfIK4G8"
    ap_timeout: 0s

and remove the final captive_portal line (docs).

If that doesn’t work, try not turning your wifi off overnight and confirm that the device works as expected.

Thank you! I will try that a give feedback later.

Today the LED Stripe turns off again. This is the log of the sensor from today.

6. Dezember 2024

co2-sensor-2 was located at home
05:01:06 - 3 hours ago

co2-sensor-2 Restart
05:00:45 - 3 hours ago

CO2 Status LED shut off
05:00:45 - 3 hours ago

NeoPixel Light shut off
05:00:45 - 3 hours ago

Really strange. This is my new code:

esphome:
  name: co2-sensor-2

esp8266:
  board: d1_mini

# Enable logging
logger:


# Enable Home Assistant API
api:
  encryption:
    key: "F4YoGDdBD3Pl/LaccgudlQl0q6IJQlOHgmFlGq08MrU="

  services:
    - service: recalibrate_scdx_co2
      variables:
        actual_co2: int
      then:
        - scd30.force_recalibration_with_reference:
            value: !lambda 'return actual_co2;'    

external_components:
  - source: github://bekriebel/esphome@scd30_force_calibration_with_reference
    components: [ scd30 ]

# Example configuration entry
switch:
  - platform: restart
    name: "co2-sensor-2 Restart"

ota:
  platform: esphome
  password: "db19f7bad7a0214cd0aa0846ed9211e0"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  reboot_timeout: 0s

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Co2-Sensor-2 Fallback Hotspot"
    password: "mgH7mhfIK4G8"
    ap_timeout: 0s

# Example configuration entry for ESP32
i2c:
  sda: GPIO4
  scl: GPIO5
  scan: true
  id: bus_a

# Example configuration entry
sensor:
  - platform: scd30
    co2:
      name: "co2-Sensor-2"
      on_value_range: # Schwellwerte für die Ampel
        - below: 1000
          then:
            - light.turn_on:
                id: co2_status_led
                brightness: 25%
                red: 0%
                green: 100%
                blue: 0%
        - above: 1000
          below: 1400
          then:
            - light.turn_on:
                id: co2_status_led
                brightness: 25%
                red: 100%
                green: 80%
                blue: 0%
        - above: 1400
          then:
            - light.turn_on:
                id: co2_status_led
                brightness: 30%
                red: 100%
                green: 0%
                blue: 10%
    update_interval: 10s
    temperature:
      name: "co2-Sensor-2 Temperatur"
      accuracy_decimals: 1
    humidity:
      name: "co2-Sensor-2 Luftfeuchtigkeit"
      accuracy_decimals: 1
    automatic_self_calibration: off
    temperature_offset: 1.5 °C
    address: 0x61
    altitude_compensation: 105m

# Example configuration entry
light:
  - platform: neopixelbus
    type: GRB
    variant: WS2812X
    pin: GPIO3
    num_leds: 10
      
    name: "NeoPixel Light"
    id: co2_status_led
  - platform: partition
    name: "CO2 Status LED"
    id: section1
    segments:
      - id: co2_status_led
        from: 0
        to: 9

Try adding reboot_timeout to your api section see the docs here

api:
  encryption:
    key: "F4YoGDdBD3Pl/LaccgudlQl0q6IJQlOHgmFlGq08MrU="
  reboot_timeout: 0s

I think I’d actually set it to something like 12 hours, or longer than your Wi-Fi off period, I have never tried setting it that long though.

Thanks for your reply. I will try it and give an update later.

Unfortunately the same situation. This ist my actual confifg. I have also disabled the wifi fall back.

esphome:
  name: co2-sensor-2

esp8266:
  board: d1_mini

# Enable logging
logger:


# Enable Home Assistant API
api:
  encryption:
    key: "F4YoGDdBD3Pl/LaccgudlQl0q6IJQlOHgmFlGq08MrU="

  services:
    - service: recalibrate_scdx_co2
      variables:
        actual_co2: int
      then:
        - scd30.force_recalibration_with_reference:
            value: !lambda 'return actual_co2;'    

external_components:
  - source: github://bekriebel/esphome@scd30_force_calibration_with_reference
    components: [ scd30 ]

# Example configuration entry
switch:
  - platform: restart
    name: "co2-sensor-2 Restart"

ota:
  platform: esphome
  password: "db19f7bad7a0214cd0aa0846ed9211e0"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  reboot_timeout: 9h

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  #ap:
    #ssid: "Co2-Sensor-2 Fallback Hotspot"
    #password: "mgH7mhfIK4G8"
    #ap_timeout: 9h

# Example configuration entry for ESP32
i2c:
  sda: GPIO4
  scl: GPIO5
  scan: true
  id: bus_a

# Example configuration entry
sensor:
  - platform: scd30
    co2:
      name: "co2-Sensor-2"
      on_value_range: # Schwellwerte für die Ampel
        - below: 1000
          then:
            - light.turn_on:
                id: co2_status_led
                brightness: 25%
                red: 0%
                green: 100%
                blue: 0%
        - above: 1000
          below: 1400
          then:
            - light.turn_on:
                id: co2_status_led
                brightness: 25%
                red: 100%
                green: 80%
                blue: 0%
        - above: 1400
          then:
            - light.turn_on:
                id: co2_status_led
                brightness: 30%
                red: 100%
                green: 0%
                blue: 10%
    update_interval: 10s
    temperature:
      name: "co2-Sensor-2 Temperatur"
      accuracy_decimals: 1
    humidity:
      name: "co2-Sensor-2 Luftfeuchtigkeit"
      accuracy_decimals: 1
    automatic_self_calibration: off
    temperature_offset: 1.5 °C
    address: 0x61
    altitude_compensation: 105m

# Example configuration entry
light:
  - platform: neopixelbus
    type: GRB
    variant: WS2812X
    pin: GPIO3
    num_leds: 10
      
    name: "NeoPixel Light"
    id: co2_status_led
  - platform: partition
    name: "CO2 Status LED"
    id: section1
    segments:
      - id: co2_status_led
        from: 0
        to: 9

Your config above doesn’t have the reboot_timeout: 0s in the api section, my guess is you will need it in both.

Thank you for your notice. I have just added it and will now see what happens tomoorrow.