Hi @TheFes, have you implemented your suggestion? I tried it, but it breaks the automation completely for me. I’m super confused, since I’ve double-checked that now().date gives the same value as states(''sensor.date''), and as_timestamp(now()) is very close to as_timestamp(states(''sensor.date_time_iso'')).
Both replacements result in errors. If I replace only as_timestamp(states(''sensor.date_time_iso'')), I get the following error: sunrise test: Error executing script. Error for wait_template at pos 2: In 'template' condition: AttributeError: 'datetime.datetime' object has no attribute 'lower'
If I replace states(''sensor.date'') or both, I get: sunrise test: Error executing script. Error for wait_template at pos 2: In 'template' condition: TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'
I wonder if something needs to be typecasted to a different form. Any ideas?
Is there a way that I can debug each step of the blueprint? The best way where a file for each day which can be checked with diff.
I use these from Monday to Thursday to wake me up and I works fine, except on Tuesday.I use only one setting with the template with 1- 4 isoweekday. Why the behavior on Tuesday is different is not understandable for me, so I would look to catch this.
Thoughts on what could be causing this automation to skip all the way to the end in 7 seconds? Trying this on a new HA instance and testing is going poorly. I have the lights setup through local tuya instead of a cloud tuya app if that makes a difference.
In my case (Hassio & supervisor 2022.3.5) automation works depending on the day. The error is 100% the time comparison mentioned by @Caze but I have tried to adapt his code to the original version with no luck.
Im a programmer myself, but its being hard to start because I dont even know how to properly debug this.
Can someone tell me where could I find information about the operators ~, |… or the syntaxis? Its complicated to decode what this exactly does.
I mean, I guess you get the information from the sensor or from your manual time and convert it using as_timestaps. Ok. But what ~ ‘’ ‘’ ~ means for example??
The ~ is basicly a string concat, so the states(''sensor.date'') ~ '' '' ~ manual_time
is the same as date + " " + manual_time
so you have a string which then gets converted to a datetime and then local time with timezone.
if sensor is != none:
as_timestamp(states(sensor))
else:
as_timestamp(states(sensor.date) + " " + manual_time)
which means first take the alarm time (manual or by a sensor) and include the date.
Then you have:
as_timestamp(states(''sensor.date_time_iso''))
which means take thet date time now.
So you do alarm_time - data_time_now and check if its less or equal to the amount of time the script should be running (float(seconds)) and also check if the other condition.
Questions:
when the first part ( 0 < …) gets evaluated?
Assuming | means OR why have you added | as_datetime() | as_local() in your script?
In case I want to check the output of the ‘‘as_timestamp’’ which is the correct way to debug/print and check it?
Thanks for this blueprint. It works as described! Ik would like to swap out the manual time element for aan date/time helper. How would i go about that?
@Sbyx nice blueprint. runs great. i want to have a single automation which should run primarly on weekdays but if i set a trigger to on it should also run on weekends.
i already have a trigger and i am trying to combine this with now().isoweekday() in pre sunrise actions.
is something like this possible? are these actions “or” or “and” combined?
@Sbyx very good work with this blueprint!
I just used it for a couple of days and I found something …
I am using this blueprint based on the next_alarm timestamp from the Android companion App.
Initially I found this approach very clever (using the phone configured alarm) until I found that every calendar notification (events, etc) also change / update the next_alarm timestamp on the phone and immediately on Home Assistant.
This means that I had to disable this automation because the light and speaker I turn on with this, were being triggered every now and then during the day…
Is it possible to filter only the next_alarm configured in the phone clock and not consider calendar notifications or other sources that might change next_alarm ?
Note: I am aware of
Additional entity to check before the sunrise is triggered
but I would need to over engineer it to prevent calendar reminders (triggered on phone) from waking me up in the middle of the night/weekend/etc…
Do you have any hint or suggestion that I’m not considering?