I’ve been reading all night and can’t find what I need, or, am totally confused.
It could be both.
I have two input_datetime helpers that are configured as ‘time only’ and hold the start and end time of an event.
I would like to create a on/off template sensor that tells me if the current time is between the two helpers.
There is an attribute of timestamp to the input_datetime helpers, but without a date I guess it’s from the beginning of time so wouldn’t work properly. Is there a way to get a timestamp of now(), but only the time, not the date?
{% set n = (now()) %}
{% set open = (today_at(states('input_datetime.battery_charge_start'))) %}
{% set closed = (today_at(states('input_datetime.battery_charge_finish'))) %}
Open: {{ open }}
now: {{ n }}
close: {{ closed }}
{% if now() > open %}
true
{%- else -%}
false
{%- endif %}
No, it doesn’t. I should have started with DateTime, but the kit I’m sending the data to only needs time, ill just format for the hours and mins before I send
If the Input datetimes are being updated the same date you need them , you might be able to pull the date from the last_changed property of the entity i.e.
I think I need to go back to the drawing board on this one…
I’m trying to sync my solar inverter charging window with my energy providers off peak windows, which are dynamic.
The rules I have are:
Everyday the off-peak window is 2330hrs - 0530hrs.
There may be additional off-peak windows though and I want to take advantage of these by remotely updating the inverters charging window.
Additional off-peak windows are received as datetime stamps.
The inverter only accepts hh:mm for start and finish.
1 - If the dynamic window is between 2330hrs - 0530hrs, ignore and do not update the inverter. Ensure the inverter continues with 2330 - 0530.
2 - If the dynamic window is outside of 2330 - 0530 then update the inverter with the new window (say, 2000hrs - 2200hrs)
3 - When the dynamic window ends, restore the 2230hrs - 0530hrs window.
You may be right… it seems like there is something overly convoluted. If you want, post the automation so we can see how you have the logic structured.
Appreciated, so this automations “works” in that the inverter gets updated, but I need to make it smarter:
It is triggered when the dynamic charging windows are made available/updated.
I am ignoring the fact that there may be multiple windows, and just working with the earliest one, which is acceptable to me