Open RobertDWhite opened 5 years ago
Hi claytonjn, Thanks for all your work! I have been looking over this more. Since I use the dimmers, I think it is more accurate to be seeking information about how to make scenes that turn on to the appropriate setting. I am looking into the Hue debugging now and have successfully turned off all my lights (one small step...). So onward, I suppose, to figuring out how to pull the circadian rhythm into Hue scenes.
Ah, yes. I started writing the documentation on that (same page in the WiKi) but haven't had the time to finish it... Hopefully I will soon.
Ah. I see. Thanks for the heads up. I do have the correct setting for power on, now, though. So maybe I will figure it out before the documentation goes up! I have challenged myself. Thanks again for all your work.
Hi Clayton, great feature set and implementation, thanks for providing your code to the public!
I'm trying to use the service call as you describe in the documentation, but my light isn't reacting.
Might be a bit naive, but is the code you give as an example for an action usable literally? I'm asking because of the switch.circadian_lighting_[...]
bit - or do I have to define an acutal name for my intended target light and use switch.lightname instead (which I tried but it didn't work).
Switching on the circadian light while my light is on does correctly change color already.
You're using the entity_id of the Circadian Lighting switch(s) that was created when you configured CL. So it should start with switch.circadian_lighting_
and you have to replace the [...]
with the rest of the entity_id based on how you named the switch.
That's what I thought (could be clearer in the docs though) and tried. See code below. This does not turn on my light though, it stays off.
In configuration.yaml:
switch:
- platform: circadian_lighting
name: Tageslichtlampe
lights_rgb:
- light.led_lichterkette_1_rgb
Automation (via HASSIO UI): Called service: light.turn_on Used entity_id: light.led_lichterkette_1_rgb Action/Data code:
brightness_pct: '{{ state_attr(''switch.circadian_lighting_tageslichtlampe'', ''brightness'') | int }}'
kelvin: '{{ state_attr(''sensor.circadian_values'', ''colortemp'') | int }}'
It also doesn't work if I append the name, i.e. switch.circadian_lighting_tageslichtlampe or switch.circadian_lighting_led_lichterkette_1_rgb. I do see that the configuration changed to the value when I specified the switch, so I do know the correct name. Does CL only work when the light is already switched on or maybe only with RBGWW lights? I'm using an analog RGB LED strip.
What's weird is that when I test the automation (manually triggering it via the UI), it says "in 8 seconds" - which it doens't for any other automation I've created so far (where it says "0 seconds ago" or something).
Edit: Fixed switch name to lowercase.
That looks right, although the quotes seem wrong. You should have a double quote "
around the template string and a single quote '
around the entity_id and attribute, per my example.
I've never uses the GUI to do Automations because it doesn't offer full functionality and it looks like you can't use templates at all. If you notice in my example the Automation has data_template:
rather than just data:
, so I'm pretty sure you just have to write the automation manually in automations.yaml
.
Does CL only work when the light is already switched on? What about this? The service call suggests that the actual light should turn on as well. Although it doesn't change the fact that the circadian "light switch" doesn't turn on. If I add another action to first turn on my light, it is the color that was set last, not circadian.
About the templating: it definitely does work per se via the UI, I'm using it for other things and it has also been confirmed by others. I also tried to change the quotes in there yaml and use that, also without success - plus my other automations use the same quote pattern anyway.
I don't know what else to try...
What does the automation look like from your automations.yaml file?
The mystery is solved! The automation via UI needs 4 actions.
Thank you for your help!
I'm confused, based on your description it sounds like you're turning on the light three times and turning on the CL switch. It may seem like it's working, but I'm thinking that what's really happening is that the CL switch adjusts as soon as it's turned on and already "listens" for the configured lights to be turned on, and the extra actions are superfluous. If you set the lights to something like green, then turn them off, then run your automation; do they come on immediately at the correct color temperature or do they come on green and then transition to the correct color temperature?
If you could post a screenshot of your automation or the code from automations.yaml that would really help clear things up.
Yes exactly, the service call does not turn on the light, which is why I tried the additional actions. With my automation sequence the light turns on with the circadian values directly, even if I set it to something else before.
Here's the code from the yaml:
- id: '1578059524133'
alias: '[Licht] Aufwachlicht'
description: LED Streifen mit Circadian Lighting anschalten
trigger:
- at: '7:30'
platform: time
condition: []
action:
- device_id: f3dba83649964f8ea3bc000a6f9a15e3
domain: light
entity_id: light.led_lichterkette_1_rgb
type: turn_on
- entity_id: switch.circadian_lighting_tageslichtlampe
service: switch.turn_on
- entity_id: light.led_lichterkette_1_rgb
service: light.turn_on
- data:
brightness_pct: '{{ state_attr(''switch.circadian_lighting_tageslichtlampe'',
''brightness'') | int }}'
kelvin: '{{ state_attr(''sensor.circadian_values'', ''colortemp'') | int }}'
entity_id: light.led_lichterkette_1_rgb
service: light.turn_on
What type of light is this? You definitely shouldn't need to send three turn_on
commands for the light, some users have reported lights only adjusting colortemp or brightness but not both in the same call so I could see that being an issue, but this should really be enough:
- id: '1578059524133'
alias: '[Licht] Aufwachlicht'
description: LED Streifen mit Circadian Lighting anschalten
trigger:
- at: '7:30'
platform: time
condition: []
action:
- service: switch.turn_on
entity_id: switch.circadian_lighting_tageslichtlampe
- service: light.turn_on
entity_id: light.led_lichterkette_1_rgb
data_template:
brightness_pct: '{{ state_attr(''switch.circadian_lighting_tageslichtlampe'', ''brightness'') | int }}'
kelvin: '{{ state_attr(''sensor.circadian_values'', ''colortemp'') | int }}'
Is the behavior different if you change the automation to be just the following?
- id: '1578059524133'
alias: '[Licht] Aufwachlicht'
description: LED Streifen mit Circadian Lighting anschalten
trigger:
- at: '7:30'
platform: time
condition: []
action:
- entity_id: switch.circadian_lighting_tageslichtlampe
service: switch.turn_on
- entity_id: light.led_lichterkette_1_rgb
service: light.turn_on
Is the behavior different if you change the automation to be just the following?
- id: '1578059524133' alias: '[Licht] Aufwachlicht' description: LED Streifen mit Circadian Lighting anschalten trigger: - at: '7:30' platform: time condition: [] action: - entity_id: switch.circadian_lighting_tageslichtlampe service: switch.turn_on - entity_id: light.led_lichterkette_1_rgb service: light.turn_on
This works, yes! Turns on the light directly into CL mode, without the former color or brightness being visible.
For completeness sake: I'm using a Simfonio LED strip (based on Tuyas version of the ESP8266, can aparently be integrated into HA via the fluxled component): https://www.amazon.de/gp/product/B07X22SCCN/
So, now we only need a mechanism to reduce/correct the brightness (as it's much brigther than the sunlight during winter now, almost at full brightness before the sun is even starting to rise).
Cheers!
This works, yes! Turns on the light directly into CL mode, without the former color or brightness being visible.
So actually you're not actually turning on the light directly to the correct values, CL just adjusts so fast you can't tell. That's perfect if it works for you! With some lights there's a noticeable delay and the templates are required.
So, now we only need a mechanism to reduce/correct the brightness (as it's much brigther than the sunlight during winter now, almost at full brightness before the sun is even starting to rise).
This is actually intentional. Circadian Lighting is designed to be weather/season agnostic so that the behavior is consistent and a rhythm is maintained. One of the big benefits of CL is keeping you more alert during winter months where it can often be dark and gloomy and depressing.
Ah, thank you for the explanation!
I’ve been working to get the additional feature of turning lights on to the appropriate state in order to avoid noticeable transitions, to no avail. I’m kind of a noob. Would anyone be willing to share their code with this feature implemented? Thanks!