Add property to active timers JSON that is the exact time a timer will expire
See original GitHub issueFeature request:
Add property to active timers JSON that is the exact time a timer will expire.
Background
I need the exact time each timer will expire (not just the next timer). It seems like the raw JSON data should be enough to get the answer, but I’m always off by a few seconds when I try to calculate it myself. I would be nice if the raw JSON has a property (e.g., expireTime
) that would be the exact time the timer was to expire. This would be the same value that is getting returned for the entity itself but add this value to the raw JSON of each timer so that its available for not just the “next timer” but for all active timers.
Example of Issue
Below is the output of a template (run via the Developer Tools–>Template page). Note that the calculated values is 2 seconds different then the value returned from the entity. 14:23:36
vs 14:23:38
From raw JSON data:
key: 230ac9db-fe6d-37f4-acac-5b553c2e738f
expireTime: 2020-09-30 14:23:36
---
From the next timer value:
States: 2020-09-30T14:23:38-06:00
Here is the template:
{% set timers = state_attr('sensor.front_room_dot_next_timer', 'sorted_active') | from_json %}
{% for timerTokenData in timers %}
{% set timerData = timerTokenData[1] %}
From raw JSON data:
key: {{ timerTokenData[0] }}
expireTime: {{ ((timerData.createdDate + timerData.remainingTime )/1000) | timestamp_local }}
{% endfor %}
---
From the next timer value:
States: {{ states('sensor.front_room_dot_next_timer') }}
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (7 by maintainers)
Top GitHub Comments
Thanks merged it in. It’s in dev. Probably release it this weekend.
With that I assume this issue is closed. Let me know if you think otherwise.
Created PR https://github.com/custom-components/alexa_media_player/pull/966. This PR adds a new attribute to notification sensors called
process_timestamp
. The value of this attribute provides access to HA templates allowing very accurate calculations of all future timers.I verified alarms, notifications, timers to ensure nothing broke.