-
-
Notifications
You must be signed in to change notification settings - Fork 372
Description
Is there an existing issue for this?
- I have searched the existing open and closed issues and I checked the docs https://jokob-sk.github.io/NetAlertX/
The issue occurs in the following browsers. Select at least 2.
- Firefox
- Chrome
- Edge
- Safari (unsupported) - PRs welcome
- N/A - This is an issue with the backend
Current Behavior
I noticed some odd behaviour after the change to summer time today.
The MQTT sensors last connected are an hour ahead and the MQTT explorer shows some really weird timezone offset.
I looked up the code in the MQTT publisher plugin and pasted it into the python console and sure enough it produces the same nonsense:
>>> dt=datetime.fromisoformat("2025-09-28 14:44:23")
>>> print(dt)
2025-09-28 14:44:23
>>> print(dt.tzinfo)
None
>>> dt=dt.replace(tzinfo=timezone("Pacific/Auckland"))
>>> print(dt)
2025-09-28 14:44:23+11:39
Totally wrong offset. We are now UTC+13:00
I googled some pytz issues and found this:
https://stackoverflow.com/questions/6410971/python-datetime-object-show-wrong-timezone-offset
UPDATE: Actually, the official pytz website states that you should always use localize or astimezone instead of passing a timezone object to datetime.datetime.
So I replicated the same in Python console:
>>> tz = timezone('Pacific/Auckland')
>>> print(tz)
Pacific/Auckland
>>> dt=datetime.fromisoformat("2025-09-28 14:44:23")
>>> dt=tz.localize(dt)
>>> print(dt)
2025-09-28 14:44:23+13:00
Correct result!
I'll update the MQTT publisher but this may be an issue in other places.
Expected Behavior
2025-09-28 14:44:23+13:00
Steps To Reproduce
No response
app.conf
docker-compose.yml
What installation are you running?
Production (netalertx)
app.log
No response
Debug enabled
- I have read and followed the steps in the wiki link above and provided the required debug logs and the log section covers the time when the issue occurs.