Watchman Updated sensor Invalid Timestamp
See original GitHub issueI have noticed a small bug with the timestamp formatting of the sensor.watchman_last_updated entity when using the iOS / iPadOS Home Assistant apps.
When viewing any lovelace dashboards with the watchman_last_updated entity displayed, the entity would show as Invalid timestamp
and I would get the following error in the HA logs:
ERROR (MainThread) [frontend.js.latest.202203010] https://[my-HA-URL]/frontend_latest/92deadc4.js:258:77216 RangeError: number argument must be finite
The errors do not occur on Windows with Edge.
The error did not occur for any of my other device_class: timestamp entities.
Looking at the formatting of my working entity it is using (what I have just learnt is) the ISO 8601 format of YYYY-MM-DDTHH:MM:SS+UTCOFFSET
, e.g. 2022-03-03T14:12:17+00:00
The watchman_last_updated sensor is substituting the T with a space character, e.g. 2022-03-10 17:33:25.133995+11:00
I found that the HA templating documentation reference this issue:
If your template is returning a timestamp that should be displayed in the frontend (e.g., as a sensor entity with device_class: timestamp), you have to ensure that it is the ISO 8601 format (meaning it has the “T” separator between the date and time portion). Otherwise, frontend rendering on macOS and iOS devices will show an error.
I’m running: Watchman: 0.5.0 (through HACS) Home Assistant Core: 2022.3.2 Supervisor: 2022.03.2 Home Assistant OS: 7.4 Hardware: Raspberry Pi 4b
Would the date format of the sensor be something you would be happy to change? Let me know if there is any other information or testing I can help with, and thanks very much for a great integration!
Edit: The above documentation suggests enforcing iso conversion with the function isoformat()
. That didn’t work for me with the watchman sensor, but for testing, I created the below template sensor which did not generates the errors:
- name: "Watcher Test"
state: "{{ as_timestamp(states('sensor.watchman_last_updated')) | timestamp_custom('%Y-%m-%dT%H:%M:%S%z') }}"
device_class: timestamp
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
I can confirm it’s now displaying correctly and no longer generating an error. Thanks very much!
Thanks very much. And thanks again for a great integration, it has helped me find many loose ends I didn’t know I had!