Skip to content

Custom ESPHome Adaptive lighting external component.

License

Notifications You must be signed in to change notification settings

mdvorak/esphome-adaptive-lighting

Repository files navigation

ESPHome Adaptive Lighting

Adaptive lighting component for ESPHome. It sets the light color temperature based on the current position of the sun.

If the light color is adjusted manually, the adaptive lighting will be disabled until the light is turned off and on again. The adaptive lighting is also a switch, so it can be enabled or disabled manually, or by automation.

adaptive_lighting:
  - light_id: cw_light

Configuration variables

  • id (Optional, ID): Manually specify the ID used for code generation. At least one of id or name must be specified.
  • name (Optional, string): The name of the component.
  • icon (Optional, icon): Manually specify the icon to use for this component. Used for enable switch in the frontend.
  • light_id (Required, ID): The light to control. It must support color temperature.
  • cold_white_color_temperature (Optional, float): The color temperature (in mireds or Kelvin) of the cold white channel. This can differ from the configuration of the light, but it still must be within the supported range.
  • warm_white_color_temperature (Optional, float): The color temperature (in mireds or Kelvin) of the warm white channel. This can differ from the configuration of the light, but it still must be within the supported range.
  • sunrise_elevation (Optional, float): The elevation of the sun at sunrise. Default is nautical (-12 deg).
  • sunset_elevation (Optional, float): The elevation of the sun at sunset. Default is nautical (-12 deg).
  • speed (Optional, float): The speed of the transition between color temperatures. Default is 1.0.
  • update_interval (Optional, Time): The interval in which the color temperature is updated. Default is 60s.
  • transition_duration (Optional, Time): The duration of the transition between color temperatures. Default is 1s.
  • restore_mode (Optional, RestoreMode): The restore mode to use. Default is ALWAYS_ON.

Example

external_components:
  - source: github://mdvorak/esphome-adaptive-lighting@v1

adaptive_lighting:
  - light_id: cw_light
    name: "Adaptive Lighting"
    cold_white_color_temperature: 6000 K
    warm_white_color_temperature: 2700 K
    sunrise_elevation: -15.0 deg
    sunset_elevation: -15.0 deg

output:
  - platform: ledc
    id: ledc_cold
    # Set the pin and frequency
  - platform: ledc
    id: ledc_warm
    # Set the pin and frequency

light:
  - platform: cwww
    id: cw_light
    name: "Light"
    cold_white: ledc_cold
    warm_white: ledc_warm
    cold_white_color_temperature: 6500 K
    warm_white_color_temperature: 2700 K
    constant_brightness: true

sun:
  latitude: !secret latitude
  longitude: !secret longitude

time:
  - platform: sntp
    timezone: !secret timezone

Credits

License

Apache License Version 2.0

See Also