The issue is that sometimes when I am away from home, I turn my automation off. Then on the day after the trigger has passed, ie it’s after 4PM and the sun is lower than 25° I will turn the automation back on again.
Then invariable, the light turns ON immediately and I don’t understand why it is being triggered.
I suspect it’s because it’s after 4 as the numeric state hasn’t changed below 25° but I don’t know. So is there any way I can alter the triggers so it won’t go on if say I turn the automation on at 5PM?
I don’t use the quotes in numeric states, and that works fine.
btw, I think I learned that the only template triggers allowed are in the form of platform: template :
ok learned something again, thx for showing me! Of course this isn’t a template trigger. Should have read the paragraph sun trigger more carefully, its there…albeit in another order, which shouldn’t be of influence in your issue?
Absolutely, you are right. Thanks for the input.
I’ve been using the following syntax up till now, which seemed to work as well to prevent the unknown state:
{{ states('sun.sun.attributes.elevation') | int < 25 }}
I’m going to remove the quotes from the 25 as you’re right…
I think converting to an integer will have unexpected consequences. Eg say the sun is at 24.99 degrees… does it round up?
In any case, you all seem to be losing sight of the fact it is working except for the unwanted trigger if I enable the automation say at 5PM when the sun is below 25. I just can’t see why it is being triggered then.
(Just for further clarification, last week before we switched to summer time, the sun was below 25 about 3:55PM but it wouldn’t trigger till 4 - correct behaviour. We switched to DST on Sunday and the sun goes below 25 at 4:55PM and it is triggering at 4:55PM as it’s after 4 - correct behaviour,)
As triggers are per default ‘OR’ and not like conditions that are ‘AND’ it seems right to me if it triggers at 5PM when sun is below 25, as at least one trigger (elevation) will fire and both conditions are met.
no, not losing sight, just repsonding to the other triggers format.
what happens if you comment out the sun trigger, to have it only trigger on the time trigger? does it still trigger at 5Pm then?
btw, if you rewrite your time conditions as follows, it is easier to check in the dev-template:
- condition: state
entity_id: automation.<whatever_the_name_of_this_is>
state: 'on'
for:
minutes: 5
If you just turn it on, it should’t trigger the automation.
EDIT: I should clarify, this will only work if the sun elevation is the trigger that is causing this to fire when you turn it on. (which I agree with @tom_l, I think this is the trigger). FYI this also may keep firing every time the sun elevation is below 25.
EDIT 2: You could alter the conditional value_template that you have as well. Just make it look at the from_state and verify that it was above 25. Then this will only run at the transition, the 4 pm trigger will likely never cause this to work as you’ll probably never catch the transition at 4 pm.
Petro - I don’t think that will work. In Winter I want the lights to come on at 4PM and not before and at that time, the sun may have been below 25° since 3PM so the trigger-from and trigger-to won’t be true.
I’m going to try the automation state for 5 minutes. I do like the second one though…
You’re just in a catch-22 because it will trigger anytime between 4-10pm when the sun elevation changes. So if you turn it on and it doesn’t trigger, it may trigger whenever the sun elevation changes.
I don’t think I understand what you are saying. The way I read that value template, that condition will only be true when the elevation changes from above 25 to below 25… which is OK in summer as it will always be after 4pm But in Winter, I don’t see how it can ever be triggered as that elevation change could happen at 3PM and thus the 2 conditions won’t be satisfied ever.
I wonder if I should just delay it for 7 hours instead of 5 minutes. Then if I enable it after 3PM it won’t have the condition satisfied until 10PM and then it will fail anyway… Or maybe I should just suck it up and switch the bloody light off manually!