You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I mentioned this before, and just wanted to note it here, as I'm going to be away for a while, so not likely to get to this soon, in case it helps anyone else looking at it.
As I see things there are probably 8 entities to add -
Off Peak Weekday Start
Off Peak Weekday End
Off Peak Weekend Start
Off Peak Weekend End
Solar Start
Solar End
Schedule Time Start
Schedule Time End
I had some thoughts / random notes on how the schedule could be handled (feel free to ignore all of this, I just wanted to note it somewhere in case it helps)
from datetime import time
st = time(11, 0)
et = time(16, 30)
sidx = int(st.hour * 2 + st.minute / 30)
eidx = int(et.hour * 2 + et.minute / 30)
sched = 'PPP0000000000000000000SSSSSSSSSS00000000000PPPPP00'
# Adding new schedule when start time < end time
If the string is loaded to a list it can be indexed and may be easier for manipulation
sched_list = list(sched)
sched_list.pop() # 2 times to remove last two 0 as they aren't used
sched_list[sidx:eidx]= "S" * (eidx - sidx)
sched = "".join(sched_list)
sched = sched + "00" # need to add the 00s back on
sched
'PPP0000000000000000000SSSSSSSSSSSS000000000PPPPP00'
if sidx > eidx: # The time period loops past midnight
sched_list[0:eidx-1] = "T" * (eidx-1)
sched_list[sidx:len(sched_list)] = "T" * (len(sched_list) - sidx)
start time from string to time object -
>>> time(sched.index("S") // 2, (sched.index("S") % 2) * 30)
datetime.time(11, 0)
end time from string to time object -
>>> time(sched.rindex("S") // 2, (sched.rindex("S") % 2) * 30)
datetime.time(15, 30)
Checking current time schedule...
sched_list[0] == sched_list[-1] # indicates the schedule loops past midnight
Still need something to read start / end time when it loops around midnight
Off peak - "P"
Scheduled Time - "T"
Solar - "S"
Things that might need to be taken in to account:
overlapping times between entities - how should this be handled / blocked
before adding a new time period the old one is going to need to be blanked out with 0s some how so you don't end up with an old and new block in the schedule
The EO app on iOS at least lets you set everything before it is pushed to the server but Home Assistant does changes straight away which isn't ideal when you have linked entities like start/end time and things as above that you don't want to overlap
Should also add itertools.cycle might help with the rotating past midnight issue, and might simplify some things.
The text was updated successfully, but these errors were encountered:
I mentioned this before, and just wanted to note it here, as I'm going to be away for a while, so not likely to get to this soon, in case it helps anyone else looking at it.
Time entities are in the new 2023.6 release - https://www.home-assistant.io/blog/2023/06/07/release-20236/#new-entities-date-time-datetime - hopefully they will be able to set some sort of step so minutes can change only to 00 or 30, but I haven't looked.
As I see things there are probably 8 entities to add -
I had some thoughts / random notes on how the schedule could be handled (feel free to ignore all of this, I just wanted to note it somewhere in case it helps)
Things that might need to be taken in to account:
Should also add itertools.cycle might help with the rotating past midnight issue, and might simplify some things.
The text was updated successfully, but these errors were encountered: