I basically copied the example from the docs and it only works if my time is set 4 hours back. Using templates I can see that the date_time is wrong maybe it a timezone thing?
here is the date_time screen showing that it is set to 00:30
Well, you fixed it for one case, but broke it for the original case for which it was apparently written.
Whether you should use True or False for local time in that example depends on whether or not the input_datetime has both date & time, or just time. The way the example was originally written was apparently for the case where it just had time, which does not work if it has date & time. The way you changed the example it now works if it has both date & time, but now it doesnāt work if it just has time. E.g.:
Actually, if you did [-8:-3] (instead of [0:5]) it would work whether it had a date or not.
And, yes, I agree this is a simpler/better solution. My point was the example was, and still is, wrong because it doesnāt handle both cases (and doesnāt say so.)
Iāve asked for the PR to be reverted. Iāll think about expanding the documentation to include both cases and maybe even the simpler solution tomorrow. Unless anyone gets their first.
Okay, now I thought I understood that ā¦ but then I looked again ā¦
[0:5] (to me) means starting at char 0 (the first character) take the next 5
This allows it to match the string produced by sensor.time xx:xx
[-8:-3] ā¦ I would have assumed was take 8 off the front and 3 off the back and youād be left with : -
ā25 05:00ā
So that wouldnāt work ā¦ or the model in my head is wrong ?
Edit: I assume you are talking about the documentation not āsaying soā as my input_datetimes are created especially for this purpose and highlight this in the template with the [0:5] ???
[x:y] is a Python range operator. The first parameter is the starting index, and the second parameter is one past the ending index. So [0:5] means start at index zero and take everything up to, but not including, index 5 (so 0 through 4.)
Negative indices mean start at the end, where -1 is the last, -2 is the next to last, etc. So [-8:-3] means start with the eight from the end and take everything up to, but not including, the third from the last.
This is just how Python ranges work.
I was referring to the example that was pointed out in the OP. That gave an example that assumed the input_datetime did not have date, but didnāt say so.
I was just messing around trying to work out a trigger using an input datetime and figured out that I needed ātrueā for it to work in the template. When I checked the docs a bit ago I saw that it in fact did have ātrueā in it. But I was trying to figure out where I would have gotten the āfalseā from and I could have sworn that I saw āfalseā in there yesterday.
So you just changed it in the interim. I knew my memory wasnāt that bad!