TimeDeltaSensor - delta templated - #71314
Conversation
7c7e88f to
e1ad87d
Compare
| value = self.delta | ||
| if isinstance(value, timedelta): | ||
| return value | ||
| return timedelta(minutes=int(value)) |
There was a problem hiding this comment.
Why did you choose minutes for this (rather than days, or seconds) -- and why int, not float?
Either way, accepting this needs to be documented.
Also, although it's not commonly known, there is a way of expressing intervals/periods/delta with Pendulum via ISO8061:
ISO 8601 Durations are expressed using the following format, where (n) is replaced by the value for each of the date and time elements that follow the (n):
P(n)Y(n)M(n)DT(n)H(n)M(n)SWhere:
P is the duration designator (referred to as "period"), and is always placed at the beginning of the duration. Y is the year designator that follows the value for the number of years. M is the month designator that follows the value for the number of months. W is the week designator that follows the value for the number of weeks. D is the day designator that follows the value for the number of days. T is the time designator that precedes the time components. H is the hour designator that follows the value for the number of hours. M is the minute designator that follows the value for the number of minutes. S is the second designator that follows the value for the number of seconds.For example:
P3Y6M4DT12H30M5SRepresents a duration of three years, six months, four days, twelve hours, thirty minutes, and five seconds.
>>> import pendulum
>>> pendulum.parse("P3Y6M4DT12H30M5S")
Duration(years=3, months=6, days=4, hours=12, minutes=30, seconds=5)
>>> pendulum.parse("PT6000S")
Duration(hours=1, minutes=40)There was a problem hiding this comment.
minutes , because it was the existing choice of the WaitSensor
There was a problem hiding this comment.
I don't understand why you talk about pendum Duration ?
the operator TimeDeltaSensor accept a datetime.timedelta
There was a problem hiding this comment.
I don't understand why you talk about pendum Duration ?
Durations/ISO8601 Periods can be represented as plain text, and so are easy to handle via templates.
There was a problem hiding this comment.
okay I could add this feature in a second PR
|
Looks good, add an error path test similar to what #70480 has |
5226b49 to
2bd9ae9
Compare
|
the CI always block on any idea ? |
2bd9ae9 to
c6baa3c
Compare
|
CI is green :) @ashb |
this will allow to put a
deltatemplated valuesimilar than this PR #70480