KaufHA / kauf-rgbww-bulbs

Files for the KAUF RGBWW Smart Bulbs
40 stars 18 forks source link

Bulb bricked with 1.73y install #7

Closed clarsen closed 2 years ago

clarsen commented 2 years ago

It is running captive WiFi portal, but not responding to web server requests and not responding to ping at its original IP address.

This is the esphome yaml that was used. it's basically same as kauf-bulb.yaml except for absence of the forced_hash attributes...

substitutions:

  name: office-lamp-2              # **** CHANGE DEVICE NAME TO SOMETHING UNIQUE PER DEVICE.  RENAME YAML FILE TO SAME NAME.    ****
                               # **** USE DASHES (-) INSTEAD OF SPACES OR UNDERSCORE (_).  USE ONLY LOWER CASE LETTERS.     ****

  friendly_name: Office Lamp     # **** CHANGE FRIENDLY NAME TO SOMETHING UNIQUE PER DEVICE ****

esp8266:                       # https://esphome.io/components/esp8266.html
  board: esp01_1m
  restore_from_flash: true

  # framework:                   # provides updated PWM logic per https://github.com/esp8266/Arduino/pull/7231
  #   version: 3.0.2             # https://github.com/esp8266/Arduino/releases
  #   platform_version: 3.2.0    # https://github.com/platformio/platform-espressif8266/releases/

external_components:
  - source:
      type: git
      url: https://github.com/KaufHA/kauf-rgbww-bulbs
    refresh: 0s

    # kauf_rgbww and light are required external components.  If you don't want to use them, you should use kauf-bulb-minimal.yaml instead of kauf-bulb.yaml
    # web_server is not required, it just adds the version number to the web interface and also a warning about not flashing WLED or tasmota-minimal.
    # web_server_base is not required, it just makes the OTA system error out if wled or minimal are found in an uploaded firmware filename.
    # components: [kauf_rgbww,light,web_server]
  - source:
      type: git
      url: https://github.com/KaufHA/common
    refresh: 0s

esphome:
  name: $name
  project:
    name: "kauf.rgbww"
    version: "1.73y"

  on_boot:
    then:

      - lambda: |-

          // restore light state per setting.  Default is to restore previous state so we don't need an action for that.
          if (id(select_boot_state).state == "Always On - Last Value") {
            auto call = id(kauf_light).turn_on();
            call.perform();
          }
          else if (id(select_boot_state).state == "Always On - Bright White") {
            auto call = id(kauf_light).turn_on();
            call.set_color_mode(ColorMode::COLOR_TEMPERATURE);
            call.set_color_temperature(150);
            call.set_brightness(1.0);
            call.perform();
          }
          else if (id(select_boot_state).state == "Always Off") {
            auto call = id(kauf_light).turn_off();
            call.perform();
          }

          // turn on WLED if effect is selected
          if ( id(effect).state == "WLED / DDP" ) { id(kauf_light)->set_use_wled(); }

button:
  - platform: restart
    id: restart_button
    name: $friendly_name Restart Firmware
    entity_category: diagnostic
    disabled_by_default: true

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # default is 20, 17 is recommended.
  output_power: 17
  # using fast_connect as default since it is required for hidden networks.
  # feel free to change or override.
  fast_connect: true

  # use_address allows wireless programming through dashboard.
  # Set to the bulb's IP Address.  Remove after programming.
  use_address: 192.168.6.21

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Office-Lamp-2 Fallback Hotspot"
    password: "XXXXXXXXX"

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "XXXXXXXXXX"

debug:                                # outputs additional debug info when logs start

web_server:                           # web server allows access to device with a web browser

# captive_portal:

# PWM outputs for each LED channel
output:
  - platform: esp8266_pwm
    pin: GPIO4
    frequency: 1000 Hz
    id: pwm_red
  - platform: esp8266_pwm
    pin: GPIO12
    frequency: 1000 Hz
    id: pwm_green
  - platform: esp8266_pwm
    pin: GPIO14
    frequency: 1000 Hz
    id: pwm_blue
  - platform: esp8266_pwm
    pin: GPIO5
    frequency: 1000 Hz
    id: pwm_cw
  - platform: esp8266_pwm
    pin: GPIO13
    frequency: 1000 Hz
    id: pwm_ww

light:

# Additive RGB light for Warm White
- platform: kauf_rgbww
  id: warm_rgb
  entity_category: config
  default_transition_length: 0ms
  aux: true
  name: $friendly_name Warm RGB

# Additive RGB light for Cold White
- platform: kauf_rgbww
  id: cold_rgb
  entity_category: config
  default_transition_length: 0ms
  aux: true
  name: $friendly_name Cold RGB

# Main RGBWW light
- platform: kauf_rgbww
  id: kauf_light
  default_transition_length: 250ms
  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

select:

  # default light state on boot
  - platform: template
    name: $friendly_name Power On State
    id: select_boot_state
    optimistic: true
    options:
      - "Restore Power Off State"
      - "Always On - Last Value"
      - "Always On - Bright White"
      - "Always Off"
    # defaulting to always on is nice so you know new bulbs are working
    initial_option: "Restore Power Off State"
    restore_value: true
    icon: mdi:restart-alert
    set_action:
      - script.execute: save_changes
    entity_category: config

  - platform: template
    name: $friendly_name Effect
    id: effect
    optimistic: true
    options:
      - "None"
      - "WLED / DDP"
    initial_option: "None"
    restore_value: true
    icon: mdi:string-lights
    set_action:

      - lambda: |-
          if ( x == "None" )       { id(kauf_light)->clr_use_wled(); }
          if ( x == "WLED / DDP" ) { id(kauf_light)->set_use_wled(); }

      - script.execute: save_changes

    entity_category: config

sensor:
  - platform: uptime
    name: $friendly_name Uptime
    update_interval: 60s
    entity_category: diagnostic
    disabled_by_default: true

# Send IP Address to HA.  Disabled by default, not as important now that Home Assistant provides link.
text_sensor:
  - platform: wifi_info
    ip_address:
      name: $friendly_name IP Address
      entity_category: diagnostic
      disabled_by_default: true

script:
  - id: save_changes
    mode: restart
    then:
      - delay: 3s
      - lambda: 'global_preferences->sync();'
KaufHA commented 2 years ago

So you flashed with that yaml successfully but now can't find the bulb? Can you see if it is connected to your wifi by looking at your router? Can you see it putting up its wifi network "Office-Lamp-2 Fallback Hotspot"?

Maybe start by removing the use_address field and seeing if it will connect by mdns. For instance, type http://office-lamp-2.local in a web browser or try to ping office-lamp-2.local

clarsen commented 2 years ago

So you flashed with that yaml successfully but now can't find the bulb? Can you see if it is connected to your wifi by looking at your router? Can you see it putting up its wifi network "Office-Lamp-2 Fallback Hotspot"?

I do see the wifi network "Office-Lamp-2 Fallback Hotspot", however when I try to join using the password configured in the YAML, while I get an IP address 192.168.4.2, I cannot ping 192.168.4.1 reliably although I can see the ARP entry for it:

? (192.168.4.1) at be:ff:4d:48:10:b2 on en0 ifscope [ethernet]

➜ ~ ping 192.168.4.1 PING 192.168.4.1 (192.168.4.1): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1 64 bytes from 192.168.4.1: icmp_seq=2 ttl=255 time=189.953 ms Request timeout for icmp_seq 3 64 bytes from 192.168.4.1: icmp_seq=4 ttl=255 time=6.644 ms 64 bytes from 192.168.4.1: icmp_seq=5 ttl=255 time=3.502 ms Request timeout for icmp_seq 6 Request timeout for icmp_seq 7 Request timeout for icmp_seq 8 64 bytes from 192.168.4.1: icmp_seq=9 ttl=255 time=217.802 ms 64 bytes from 192.168.4.1: icmp_seq=10 ttl=255 time=3.826 ms ^C --- 192.168.4.1 ping statistics --- 11 packets transmitted, 5 packets received, 54.5% packet loss round-trip min/avg/max/stddev = 3.502/84.345/217.802/98.000 m

The MAC bc:ff:4d:48:10:b2 is statically assigned to 192.168.6.21, but that IP isn't responding.

I've seen a similar failure with another ESPhome update to a different (non-Kauf bulb) device, so i'm suspecting it might be related to ESPhome 2022.2.5. The other devices running 2021.12.3 are able to join wifi and stay online.

clarsen commented 2 years ago

Issue actually was with router not responding to DHCP - The DHCP server was crashing due to another bug (Ubiquiti EdgeRouter allowing duplicate hostname entries in DHCP configuration)

KaufHA commented 2 years ago

Awesome, glad you got it.