KaufHA / kauf-rgbww-bulbs

Files for the KAUF RGBWW Smart Bulbs
43 stars 19 forks source link

Bulb reboots randomly and sometimes changes to the default green #69

Open lexi-the-cute opened 2 months ago

lexi-the-cute commented 2 months ago

I've been trying to figure out why it keeps resetting and attempting to resolve it. It does seem to happen less often when not using the DDP / WLED effect

this is my ESPHome config

# Device Unique Settings (requires either the kauf config linked below or passing the vars ourselves)
substitutions:
  name: lexi-room-bulb-1
  friendly_name: "Lexi's Room Bulb 1"
  ssid: "Lexi's Room Bulb 1 Hotspot"
  sub_max_power: '1.0'
  light_restore_mode: ALWAYS_ON
  mqtt_prefix: iot/$name

# Grab Recommended Kauf Config
# https://github.com/KaufHA/kauf-rgbww-bulbs/blob/main/kauf-bulb.yaml
packages:
  Kauf.RGBWW: github://KaufHA/kauf-rgbww-bulbs/kauf-bulb.yaml

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_encryption_key

# MQTT Server
mqtt:
  broker: !secret mqtt_broker
  topic_prefix: $mqtt_prefix
  reboot_timeout: 0s
  username: lexi
  password: !secret lexi_mqtt_password

# Set OTA Password
ota:
  - platform: esphome
    password: !secret ota_password

# Connect to Wifi or Fallback to Hotspot
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: $ssid
    password: !secret hotspot_fallback_password

# Component to report useful stats on startup
debug:

# Sensor configured to read text information from the debug component
text_sensor:
  - platform: debug
    device:
      name: "Device Info"
    reset_reason:
      name: "Reset Reason"

# Sensor configured to read number information from the debug component
sensor:
  - platform: debug
    free:
      name: "Heap Free"
    fragmentation:
      name: "Heap Fragmentation"
    block:
      name: "Heap Max Block"
    loop_time:
      name: "Loop Time"

# Sets logger to debug verbosity (the default)
logger:
  level: debug

MQTT is locked down so you have to be authenticated to read or write to the topics, homeassistant/#, esphome/#, and iot/#. the iot topic is where i have my bulb prefixed to with the command topic being iot/lexi-room-bulb-1/light/lexi_s_room_bulb_1/command

This is the latest device info from the debug component above

2024.8.3|Flash: 1024kB Speed:40MHz Mode:DOUT|Chip: 0x00303190|SDK: 2.2.2-dev(38a443e)|Core: 3.1.2|Boot: 31|Mode: 1|CPU: 80|Flash: 0x00146085|Reset: External System|External System 

Screenshot_20240910_195456

When I still had DDP enabled, it was causing segfaults. I'm currently trying to get QEMU running with ESP8266 (and also will be messing with ESP32, but that's more for wanting to create my own devices in the semi-distant future to do custom things) so I can get a more in depth look as to the cause of the random reboots

The reboots happen anywhere from a few minutes to few hours. This issue has stuck around through multiple builds and changes of the ESPHome config, so it isn't likely to just be a bad build, but something else. Potentially corrupted data outside of the firmware, but I currently have no way to check that

lexi-the-cute commented 2 months ago

This is the exact bulb I bought https://a.co/d/6JRLZgg

lexi-the-cute commented 2 months ago

It just rebooted again while I was closing the issue (with the default green)

Device Info:

2024.8.3|Flash: 1024kB Speed:40MHz Mode:DOUT|Chip: 0x00303190|SDK: 2.2.2-dev(38a443e)|Core: 3.1.2|Boot: 31|Mode: 1|CPU: 80|Flash: 0x00146085|Reset: External System|External System

Screenshot_20240910_200955

lexi-the-cute commented 2 months ago

What's frustrating is, I bought 2 bulbs at once. One bulb just stopped working entirely out of the blue and this one has this problem. Hopefully the replacement for the completely broken bulb works fine and that it's just a bad batch

lexi-the-cute commented 2 months ago

it may have been light_restore_mode: ALWAYS_ON. will have to do further tests

lexi-the-cute commented 2 months ago

i think the first two bulbs were just a bad batch. bulb 1 is still misbehaving, but bulb 2's replacement seems fine

lexi-the-cute commented 2 months ago

looks like disabling light_restore_mode: ALWAYS_ON just masks the issue. the home assistant logs shows that the bulb still reboots itself due to "External System" even when it visually doesn't look like it changes. the replacement bulb for the one that just straight up died doesn't appear to be having any issues according to the home assistant logs. looks like i just got 2 bad bulbs in the same order. leading me to think the bulbs were not designed well when it was just really bad luck

lexi-the-cute commented 2 months ago

sigh

Screenshot_20240913_234743 Screenshot_20240913_234748 Screenshot_20240913_235035 Screenshot_20240913_235046

lexi-the-cute commented 2 months ago

in my attempt to debug this in QEMU, i attempted to convert this over from ESP8266 Wi-Fi to ESP32 Ethernet and came up with this cursed config. it fails to compile due to expecting the header file for ESP8266 Wi-Fi

# Device Unique Settings (requires either the kauf config linked below or passing the vars ourselves)
substitutions:
  name: lexi-kauf-qemu-1
  friendly_name: "Lexi's Kauf QEMU 1"
  ssid: "Lexi's Kauf QEMU 1 Hotspot"
  sub_max_power: '1.0'
  #light_restore_mode: ALWAYS_ON
  mqtt_prefix: iot/$name
  forwarded_address: 192.168.2.122  # Used for port forwarding

# Grab Recommended Kauf Config
# https://github.com/KaufHA/kauf-rgbww-bulbs/blob/main/kauf-bulb.yaml
packages:
  Kauf.RGBWW: github://KaufHA/kauf-rgbww-bulbs/kauf-bulb.yaml

# https://esphome.io/components/esp8266.html
esp8266: !remove

# https://github.com/platformio/platformio-docs/blob/develop/boards/espressif32/esp32doit-devkit-v1.rst
# https://esphome.io/components/esp32.html
esp32:
  board: esp32doit-devkit-v1
  framework:
    type: esp-idf

# Installs PR with open_eth driver
external_components:
  - source: github://pr#7020
    components: [ ethernet ]

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_encryption_key

# MQTT Server
mqtt:
  broker: !secret mqtt_broker
  topic_prefix: $mqtt_prefix
  reboot_timeout: 0s
  username: lexi
  password: !secret lexi_mqtt_password

# Set OTA Password
ota:
  - platform: esphome
    password: !secret ota_password

# Replace Output
# https://esphome.io/components/output/
# https://esphome.io/components/output/esp8266_pwm.html
# https://esphome.io/components/output/ledc.html#esp32-ledc-output
output:
  - id: !remove pwm_red
  - id: !remove pwm_green
  - id: !remove pwm_blue
  - id: !remove pwm_cw
  - id: !remove pwm_ww
  - platform: ledc
    pin: $sub_red_pin
    frequency: $sub_red_freq
    id: pwm_red
    max_power: $sub_max_power
  - platform: ledc
    pin: $sub_green_pin
    frequency: $sub_green_freq
    id: pwm_green
    max_power: $sub_max_power
  - platform: ledc
    pin: $sub_blue_pin
    frequency: $sub_blue_freq
    id: pwm_blue
    max_power: $sub_max_power
  - platform: ledc
    pin: $sub_cw_pin
    frequency: $sub_cw_freq
    id: pwm_cw
    max_power: $sub_max_power
  - platform: ledc
    pin: $sub_ww_pin
    frequency: $sub_ww_freq
    id: pwm_ww
    max_power: $sub_max_power

# https://esphome.io/components/light/index.html
light:
  # Additive RGB light for Warm White
  - id: !remove warm_rgb
  - id: !remove cold_rgb
  - id: !remove kauf_light
  - platform: kauf_rgbww
    id: warm_rgb
    entity_category: config
    default_transition_length: 0ms
    icon: mdi:store-cog
    aux: true
    name: $friendly_name Warm RGB
    forced_hash: 4077116474
    # forced_addr: 28
    global_addr: global_forced_addr
    disabled_by_default: $disable_entities
    restore_mode: RESTORE_DEFAULT_OFF

  # Additive RGB light for Cold White
  - platform: kauf_rgbww
    id: cold_rgb
    entity_category: config
    default_transition_length: 0ms
    icon: mdi:store-cog-outline
    aux: true
    name: $friendly_name Cold RGB
    forced_hash: 301094535
    # forced_addr: 40
    global_addr: global_forced_addr
    disabled_by_default: $disable_entities
    restore_mode: RESTORE_DEFAULT_OFF

  # Main RGBWW light
  - platform: kauf_rgbww
    id: kauf_light
    default_transition_length: $sub_default_transition_length
    name: $friendly_name
    red: pwm_red
    green: pwm_green
    blue: pwm_blue
    warm_white: pwm_ww
    cold_white: pwm_cw
    warm_rgb: warm_rgb
    cold_rgb: cold_rgb
    warm_white_color_temperature: $sub_warm_white_temp
    cold_white_color_temperature: $sub_cold_white_temp
    forced_hash: 2723974766
    # forced_addr: 52
    global_addr: global_forced_addr
    restore_mode: $light_restore_mode
    on_turn_on:
      - script.execute: $sub_on_turn_on
    on_turn_off:
      - script.execute: $sub_on_turn_off

# https://esphome.io/components/select/index.html
# https://esphome.io/components/select/template.html
select:
  - id: !remove effect
  - platform: template
    name: $friendly_name Effect
    id: effect
    optimistic: true
    options:
      - "None"
      - "WLED / DDP"
    initial_option: "None"
    restore_value: true
    icon: mdi:string-lights
    on_value:
      - lambda: |-
          if ( x == "WLED / DDP" ) { id(kauf_light).set_use_wled(true); }
          else                     { id(kauf_light).set_use_wled(false); }
      - script.execute: script_save_changes

    entity_category: config
    forced_hash: 5841966
    # forced_addr: 66
    global_addr: global_forced_addr

# Disable Wifi
wifi: !remove

# # Connect to Wifi or Fallback to Hotspot
# wifi:
#   ssid: !secret wifi_ssid
#   password: !secret wifi_password

#   # Enable fallback hotspot (captive portal) in case wifi connection fails
#   ap:
#     ssid: $ssid
#     password: !secret hotspot_fallback_password

# https://github.com/esphome/esphome/pull/7020 (OpenCores Ethernet PR)
# https://esphome.io/components/ethernet.html#ethernet-component
ethernet:
  type: OPENETH
  use_address: $forwarded_address

# Disable Captive Portal
# https://esphome.io/components/captive_portal.html
captive_portal: !remove

# Disable Quick Boot Script
script:
  - id: !remove script_quick_boot
  - id: script_quick_boot
    then:
      lambda: return;

# Component to report useful stats on startup
debug:

# Sensor configured to read text information from the debug component
# https://esphome.io/components/text_sensor/wifi_info.html
text_sensor: !remove
  - platform: debug
    device:
      name: "Device Info"
    reset_reason:
      name: "Reset Reason"

# Sensor configured to read number information from the debug component
sensor:
  - platform: debug
    free:
      name: "Heap Free"
    # fragmentation:
    #   name: "Heap Fragmentation"
    block:
      name: "Heap Max Block"
    loop_time:
      name: "Loop Time"
    # psram:
    #   name: "Free PSRAM"

# Sets logger to debug verbosity (the default)
logger:
  level: debug
lexi-the-cute commented 2 months ago

so, at this point, i just hate these lights. even the replacement for bulb 1 is resetting on me and im just like, why? like it shouldn't be happening this much. these are 3 bulbs out of 4 that have turned out to be bad. only 1 of them has worked properly and they have been running the same ESPHome firmware