ESPHome

ESPHome currently only works with one light per ESPHome device. This protocol will even work with switches that are mapped as lights in ESPHome, making it very flexible and ideal for a large variety of devices.

Supported modes of operation are:

  • RGBW
  • CT
  • RGB
  • Dimmable
  • Toggle

To add the device to diyHue, simply configure it using the information below and search for lights. The devices should be automatically imported into diyHue with the correct information.

General Configuration

All devices must have a text sensor:

{"esphome_diyhue_light;mac_address;light_name;ct_boost;rgb_boost"}

Replace the values as follows:

  • esphome_diyhue_light: cannot be changed and must remain here to allow for proper detection of the light by diyHue
  • mac_address: replace with the MAC address of the device
  • light_name: replace with the name of the light
  • ct_boost: this value is utilized by diyHue to increase/decrease the default brightness of the CT light. Set this value to 0 to disable the feature. Must be an integer.
  • rgb_boost: same as ct_boost except will apply for the RGB component of the light.

Important: ct_boost and rgb_boost must have a numeral value regardless of the bulb’s capabilities. For bulbs that are dimmable and toggle, simply set these values to 0.

The alert switch will be called when the bulb is requested to be located. As it stands now, it is not ideal as it does not return the light to the original state.

RGBW

Including a white_led and a color_led light in the configuration will allow diyHue to automatically detect the devices as an RGBW device.

CT

Include a white_led light to mark the light as a CT light.

RGB

Include a color_led light to mark the light as a RGB light.

Dimmable

Include a dimmable_led light to mark the light as a Dimmable light.

Toggle

Include a toggle_led light to mark the light as a Toggle light.

Sample Configuration

This is a sample configuration for a RGBW light, namely the Feit Electric Smart Bulb. This configuration can be modified using the above information to integrate practically any type of light ESPHome supports with diyHue.

esphome:
  name: light1
  platform: ESP8266
  board: esp01_1m

ota:
  password: "redacted"

wifi:
  ssid: "redacted"
  password: "redacted"

  ap:
   ssid: "ESPhome light1"

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:
  password: "redacted"

power_supply:
  - id: 'fast_led_pwr'
    pin: GPIO13

output:
  - platform: esp8266_pwm
    pin: GPIO5
    id: cold_white_gpio
    frequency: 4000 Hz
    inverted: False
    min_power: 0
    max_power: 1

  - platform: esp8266_pwm
    pin: GPIO12
    id: warm_white_gpio
    frequency: 4000 Hz
    inverted: False
    min_power: 0
    max_power: 1

light:
  - platform: cwww
    id: white_led
    name: "white_led"
    cold_white: cold_white_gpio
    warm_white: warm_white_gpio
    cold_white_color_temperature: 6500 K
    warm_white_color_temperature: 2000 K
    gamma_correct: 0.8
    default_transition_length: 0.4s

  - platform: fastled_spi
    id: color_led
    chipset: SM16716
    data_pin: GPIO14
    clock_pin: GPIO4
    power_supply: fast_led_pwr
    num_leds: 1
    rgb_order: BGR
    name: "color_led"
    default_transition_length: 0.4s
    gamma_correct: 0.8
    effects:
      - random:
          name: Random Effect With Custom Values
          transition_length: 5s
          update_interval: 3s

text_sensor:
  - platform: template
    name: "light_id"
    id: light_id
    lambda: |-
      return {"esphome_diyhue_light;mac_address;light_name;ct_boost;rgb_boost"};
    update_interval: 24h

switch:
  - platform: template
    name: alert
    id: alert
    optimistic: true
    turn_on_action:
      - light.turn_off: color_led
      - light.turn_on:
          id: white_led
          brightness: 100%
          color_temperature: 4000 K
      - delay: 1s
      - light.turn_on:
          id: white_led
          brightness: 10%
          color_temperature: 4000 K
      - delay: 1s
      - light.turn_on:
          id: white_led
          brightness: 100%
          color_temperature: 4000 K
      - delay: 1s
      - light.turn_on:
          id: white_led
          brightness: 10%
          color_temperature: 4000 K
      - delay: 1s
      - light.turn_on:
          id: white_led
          brightness: 100%
          color_temperature: 4000 K
      - switch.turn_off: alert

web_server:
  port: 80