Skip to content

Additional Functionality

Clayton Nummer edited this page Jul 3, 2019 · 3 revisions

Turn on lights to correct color temperature / brightness

Circadian Lighting "listens" for when any configured lights turn on and immediately adjusts them to the calculated circadian values, however a number of factors can cause this adjustment to be delayed enough that the initial adjustment is noticeable. This can easily be eliminated by sending the correct color temperature and/or brightness in the turn_on service call.

Circadian Lighting exposes the calculated color temperature as an attribute of the sensor.circadian_values entity, and exposes brightness as an attribute of the switch.circadian_lighting_[...] entity(s). The following are a couple examples of how these values can easily be extracted:

Automation:

action:
  service: light.turn_on
  data_template:
    entity_id: light.entity
    kelvin: "{{ state_attr('sensor.circadian_values', 'colortemp') | int }}"
    brightness_pct: "{{ state_attr('switch.circadian_lighting_[...]', 'brightness') | int }}"

Python Script:

hass.services.call('light', 'turn_on', { "entity_id" : "light.entity" , "kelvin" : int(float(hass.states.get('sensor.circadian_values').attributes['colortemp'])) , "brightness_pct" : int(float(hass.states.get('switch.circadian_lighting_[...]').attributes['brightness'])) })

Update Hue scenes to Circadian Lighting values

The best use-case for this is when controlling Hue lights outside of Home Assistant (e.g. with Hue Dimmer or Tap, or with one of the Friends of Hue switches). When those devices are paired to Hue lights through the Hue bridge they work regardless of any issues with internet, Home Assistant, etc.

The Hue or FoH devices turn lights on to a specific Hue scene, so by adjusting scenes to the calculated circadian values it will eliminate the potential for a noticeable initial adjustment when the lights are turned on.

For this to all work properly you need to configure a separate Circadian Lighting switch for each set of lights controlled by a Hue/FoH device, and a separate Hue scene for each Circadian Lighting switch.

Creating Hue Scene(s)

There are many ways to create Hue Scenes - the most universal way is by connecting directly to the debug interface of your Hue bridge. Start by following the instructions here to familiarize yourself with the debug interface and Hue API.

There's basically two steps to creating the Hue scene(s): Get the ID(s) of the light(s) in the scene, and create a scene with those ID(s). To get the ID(s) of the lights you can use the instructions here to get a JSON of all lights and use the name to determine the ID. In the example on that page, the light with name "Hue color lamp 7" has ID "1". Then, follow the instructions here to create a scene with the ID(s) you just found. Make sure you remember the scene ID returned in the response body of creating the scene - you'll need this later!

Updating Hue Scene(s) from Home Assistant

COMING SOON!