I have an automation to change the color of a led strip at my door so I know when it’s cold or not.
The problem is that if the light is changed to some other color or turned off and on (by a switch), the automation won’t trigger when the lamp turns back on since the automation already has been fired when the trigger was triggered (3 degrees Celsius)
Is there anyway I can monitor the temperature and the state of the light continuously to keep the wanted color during the condition time?
I don’t know how either of those automations are working for a number of reasons. The spacing is off in pretty much every spot possible, unless there is a copy paste issue going on here.
I’m going to go out on a limb and say that this must be a copy paste issue. So with that assumption being said, here are the issues that I see with the automation:
You’re placing numbers in numeric states as strings. As soon as you use a quote, the system thinks it’s a string. Remove the quotes.
All time inputs in the software require hours:minutes:seconds inside quotes. EX: “HH:MM:SS” or “08:00:00” for 8 am.
You’re completely missing quotes on your 8:30 time in the second automation.
Not really a mistake but you say “-3” in your post but your automation has 3. Which is it? I’ll assume your post had the correct number of -3.
So, now, lets sit back and think about this a second. You want a scene to be to be on at all times between 20:00 and right? Well, we can condense this into a single automation using templates.
- alias: Kallt Vader Dorrlampa
trigger:
- platform: state
entity_id: sensor.yr_temperature
condition:
- condition: time
after: '20:00:00'
before: '08:30:00'
action:
- service: hue.hue_activate_scene
data_template:
group_name: Hall
scene_name: >
{% if trigger.to_state.state | int > -3 %}
WarmWeather
{% else %}
ColdWeather
{% endif %}
So now we have a single automation that switches depending on the temperature and will always execute when the temperature changes.
Now the next thing is that you want this scene to initialize when you turn on the device. So the first question I have is, does HA know when you turn the switch on or off? If the answer is no, then we can just add a ‘fire every 1 minute’ trigger. This will cause us to change the template in scene_name.
- alias: Kallt Vader Dorrlampa
trigger:
- platform: state
entity_id: sensor.yr_temperature
- platform: time_pattern
minutes: '/1'
condition:
- condition: time
after: '20:00:00'
before: '08:30:00'
action:
- service: hue.hue_activate_scene
data_template:
group_name: Hall
scene_name: >
{% if states('sensor.yr_temperature') | int > -3 %}
WarmWeather
{% else %}
ColdWeather
{% endif %}
This template will trigger every minute or if the temperature changes.
Everything in this post is documented in these places:
First of, many thanks for your detailed answer.
I was typing on my cell phone, sorry for all formatting issues and potential typos etc.
Regarding comments
1: Sorted!
2: Missed that one, many thanks.
3: Fixed it.
4. Yes, you are correct, I meant 3 Celsius, not -3 (post updated)
About your example with the event firing every minute, when I use that and try to save the config, HA is throwing this error: Can you figure out why? Here’s the error:
Invalid config for [automation]: required key not provided @ data[‘action’]. Got None
required key not provided @ data[‘trigger’].