ironsheep / RPi-Reporter-MQTT2HA-Daemon

Linux service to collect and transfer Raspberry Pi data via MQTT to Home Assistant (for RPi Monitoring)
GNU General Public License v3.0
460 stars 64 forks source link

Multiple conflicting time zone configurations found #36

Closed tehbra1n closed 2 years ago

tehbra1n commented 2 years ago

On a fresh install of Raspberry Pi OS on an RPI4, I get the following errors when trying to start the daemon through systemctl.

Oct 19 10:44:48 miflora python3[726]: Traceback (most recent call last):
Oct 19 10:44:48 miflora python3[726]:   File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 35, in <module>
Oct 19 10:44:48 miflora python3[726]:     local_tz = get_localzone()
Oct 19 10:44:48 miflora python3[726]:   File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 205, in get_localzone
Oct 19 10:44:48 miflora python3[726]:     _cache_tz = _get_localzone()
Oct 19 10:44:48 miflora python3[726]:   File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 167, in _get_localzone
Oct 19 10:44:48 miflora python3[726]:     tzname = _get_localzone_name(_root)
Oct 19 10:44:48 miflora python3[726]:   File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 146, in _get_localzone_name
Oct 19 10:44:48 miflora python3[726]:     raise utils.ZoneInfoNotFoundError(message)
Oct 19 10:44:48 miflora python3[726]: tzlocal.utils.ZoneInfoNotFoundError: 'Multiple conflicting time zone configurations found:\n/etc/timezone: America/New_York\n/usr/share/zoneinfo/posixrules: posixrules\nFix the configuration, or set the time zone in a TZ environment variable.\n'
Oct 19 10:44:48 miflora systemd[1]: isp-rpi-reporter.service: Main process exited, code=exited, status=1/FAILURE

I'm running this software without issue on some other RPIs, so I'm at a bit of a loss. /usr/share/zoneinfo/America/New_York is a symlink to /usr/share/zoneinfo/posixrules.

woodmj74 commented 2 years ago

Seeing a similar thing, installed on 4 pi's already and just spinning a new one up and hit the same. Really unsure where to do with it having spent a couple of hours on Google!

Traceback (most recent call last):
  File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 35, in <module>
    local_tz = get_localzone()
  File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 206, in get_localzone
    _cache_tz = _get_localzone()
  File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 168, in _get_localzone
    tzname = _get_localzone_name(_root)
  File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 147, in _get_localzone_name
    raise utils.ZoneInfoNotFoundError(message)
tzlocal.utils.ZoneInfoNotFoundError: 'Multiple conflicting time zone configurations found:\n/etc/timezone: Europe/London\n/etc/localtime is a symlink to: GB\nFix the configuration, or set the time zone in a TZ environment variable.\n'
jojo416 commented 2 years ago

Same, so it's not just me.

Traceback (most recent call last): File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 35, in <module> local_tz = get_localzone() File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 206, in get_localzone _cache_tz = _get_localzone() File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 168, in _get_localzone tzname = _get_localzone_name(_root) File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 147, in _get_localzone_name raise utils.ZoneInfoNotFoundError(message) tzlocal.utils.ZoneInfoNotFoundError: 'Multiple conflicting time zone configurations found:\n/etc/timezone: America/New_York\n/etc/localtime is a symlink to: posixrules\nFix the configuration, or set the time zone in a TZ environment variable.\n'

tehbra1n commented 2 years ago

FWIW there was a tzdata package update that was ready for install this AM. Doing the upgrade and restarting the server produced the same results.

ironsheep commented 2 years ago

I'm looking into this... more soon...

ironsheep commented 2 years ago

OK, I'm going to need more info about your setups. Please help!

In order to recreate I took a new RPi4 and new uSD, initialized with buster 2021-05-07-raspios-buster-armhf.img

After getting it up on my network at the proper IP, I then ran:

I then followed the RPI-Daemon install instructions to the letter.

MY FINDING: No such issues for me.

So something is different about how you are installing.

@tehbra1n @woodmj74 @jojo416 please provide more information about your context.

woodmj74 commented 2 years ago

@ironsheep - thank you for taking the time to look into this. I decided to do a fresh build again following your comments and can confirm I have this now running.

I am unable to explain what I did different to previous attempts (very good at following instructions) but had done a number of fresh installs originally to check I wasn't missing anything.

Once again, appreciate you looking at this and big thanks for doing this in the first instance, I love it!

tehbra1n commented 2 years ago

I noticed this issue with tzlocal. I installed tzlocal==4.1 and can now successfully start the daemon by hand running the python script, but starting it as a daemon with systemctl still results in an error:

pi@miflora:~ $ sudo systemctl start isp-rpi-reporter.service
Job for isp-rpi-reporter.service failed because the control process exited with error code.
See "systemctl status isp-rpi-reporter.service" and "journalctl -xe" for details.
pi@miflora:~ $ sudo systemctl status isp-rpi-reporter.service
● isp-rpi-reporter.service - RPi Reporter MQTT Client/Daemon
   Loaded: loaded (/opt/RPi-Reporter-MQTT2HA-Daemon/isp-rpi-reporter.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Fri 2021-11-12 08:53:52 EST; 1s ago
     Docs: https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon
  Process: 1507 ExecStart=/usr/bin/python3 -u /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py (code=exited, status=1/FAILURE)
 Main PID: 1507 (code=exited, status=1/FAILURE)
pi@miflora:~ $ journalctl -xe
Nov 12 08:53:56 miflora python3[1513]: tzlocal.utils.ZoneInfoNotFoundError: 'Multiple conflicting time zone configurations found:\n/etc/timezone: America/New_York\n/usr/share/zoneinfo/posixrules: posixrules\nFix the configuration, or set the time zone
Nov 12 08:53:56 miflora systemd[1]: isp-rpi-reporter.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- An ExecStart= process belonging to unit isp-rpi-reporter.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Nov 12 08:53:56 miflora systemd[1]: isp-rpi-reporter.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The unit isp-rpi-reporter.service has entered the 'failed' state with result 'exit-code'.
Nov 12 08:53:56 miflora systemd[1]: Failed to start RPi Reporter MQTT Client/Daemon.
-- Subject: A start job for unit isp-rpi-reporter.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit isp-rpi-reporter.service has finished with a failure.
--
-- The job identifier is 14231 and the job result is failed.
tehbra1n commented 2 years ago

I got some time to reflash that Pi and reinstall this software and everything works fine. No idea what I might have done differently but I'll close this out.