Hi,
I have an Mi LED Desk Lamp 1S, and till now I manage to switch it on and off, and change brightness and colour temp using the following automation:
- id: '1608972899489'
alias: Switch on Desk Lamp when PC On
description: Switch on Desk Lamp when PC On
trigger:
- platform: state
entity_id: binary_sensor.sandro_pc
from: 'off'
to: 'on'
condition: []
action:
- service: light.turn_on
data:
brightness_pct: 60
color_temp: 350
entity_id: light.mi_desk_lamp_1s
mode: single
Now I would like to create an automation, that will change the color_temp value according to the time of the day or sun position. I read that I need to use a template, but to be honest I never got the hang how to use templates in automation. Anyone can provide some help on this?
Sorry for raising this topic from the grave but just wanted to say thank you so much for those template sensors. I’ve been trying Flux and Adaptive Lighting and both have either failed miserably (Flux) or worked for a day and then started turning things on and off for no reason and not making any logs of it (Adaptive Lighting). Your template sensors on the other hand did almost exactly what I wanted on the first try and have continued to work flawlessly where both Flux and Adaptive Lighting both failed. Thank you.
Not sure if this is still an open topic for you, but in case someone else finds this thread in the future: the problem happens at the moment the sun sets, then the day length becomes negative:
I still want to tweak the logic in the template, haven’t wrapped my head around it yet though. Brute force “fix”: check in the automation if the value is positive and only then use it for setting the lamp color.