simracingtools / ir2mqtt

Send MQTT messages based on iRacing telemetry
GNU General Public License v3.0
9 stars 0 forks source link

Timezone error running the Limerock test dump #3

Open DaveSanders opened 1 year ago

DaveSanders commented 1 year ago

Howdy, I'm trying to get this up and running and having an issue with the running the test file. Its blowing up at what looks to be session start, trying to handle the time zone from the track. Here's the console from the whole session.

I'm running the default base config, I've only changed the MQTT broker and added a few basic telemetry parameters.

Note, there was an error earlier in the session, but the time zone one is what kills the process.

=============================
|         IR2MQTT           |
|           1.7             |
=============================
MQTT host: oasserver
MQTT port: 1883
MQTT base: /sensors/iRacing
Debug output enabled
starting up using dump file: data/limerock-q.dmp
irsdk connected
Location:  Observer(latitude=41.928641, longitude=-73.38105, elevation=164.01)
LocationInfo:  LocationInfo(name='Lakeville', region='USA', timezone='America/New_York', latitude=41.928641, longitude=-73.38105)
sunrise start  2019-04-01 06:04:35.349539-04:00
sunrise end    2019-04-01 06:34:53.895901-04:00
sunset start 2019-04-01 19:20:37.716530-04:00
sunset end   2019-04-01 19:50:31.822780-04:00
Location:  Observer(latitude=41.928641, longitude=-73.38105, elevation=164.01)
LocationInfo:  LocationInfo(name='Lakeville', region='USA', timezone='America/New_York', latitude=41.928641, longitude=-73.38105)
MQTT: Connection successful
DEBUG mqtt_publish(/sensors/iRacing/state, 1)
Exception in thread Thread-1 (_thread_main):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/dave/dev/ir2mqtt/venv/lib/python3.10/site-packages/paho/mqtt/client.py", line 3591, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/home/dave/dev/ir2mqtt/venv/lib/python3.10/site-packages/paho/mqtt/client.py", line 1756, in loop_forever
    rc = self._loop(timeout)
  File "/home/dave/dev/ir2mqtt/venv/lib/python3.10/site-packages/paho/mqtt/client.py", line 1164, in _loop
    rc = self.loop_read()
  File "/home/dave/dev/ir2mqtt/venv/lib/python3.10/site-packages/paho/mqtt/client.py", line 1556, in loop_read
    rc = self._packet_read()
  File "/home/dave/dev/ir2mqtt/venv/lib/python3.10/site-packages/paho/mqtt/client.py", line 2439, in _packet_read
    rc = self._packet_handle()
  File "/home/dave/dev/ir2mqtt/venv/lib/python3.10/site-packages/paho/mqtt/client.py", line 3039, in _packet_handle
    return self._handle_connack()
  File "/home/dave/dev/ir2mqtt/venv/lib/python3.10/site-packages/paho/mqtt/client.py", line 3138, in _handle_connack
    on_connect(
  File "/home/dave/dev/ir2mqtt/ir2mqtt.py", line 330, in on_connect
    if state.local_date_time == -1:
AttributeError: 'State' object has no attribute 'local_date_time'
DEBUG mqtt_publish(/sensors/iRacing/eventtype, Race)
DEBUG mqtt_publish(/sensors/iRacing/practicetrackstate, carry over)
DEBUG mqtt_publish(/sensors/iRacing/currentsessiontype, Lone Qualify)
DEBUG mqtt_publish(/sensors/iRacing/ingarage, False)
DEBUG mqtt_publish(/sensors/iRacing/onpitroad, False)
DEBUG mqtt_publish(/sensors/iRacing/brake, 1.0)
DEBUG mqtt_publish(/sensors/iRacing/gear, 0)
DEBUG mqtt_publish(/sensors/iRacing/steeringwheelangle, 0.0)
session ToD: 2019-04-01T07:30:03  TZ: America/New_York
DEBUG mqtt_publish(/sensors/iRacing/ToD, 2019-04-01T11:30:03+0000)
local time:  2019-04-01 07:30:03-04:00
solar elevation: 9.179465919503954
DEBUG mqtt_publish(/sensors/iRacing/solarElevation, 9.179465919503954)
Traceback (most recent call last):
  File "/home/dave/dev/ir2mqtt/ir2mqtt.py", line 411, in <module>
    loop()
  File "/home/dave/dev/ir2mqtt/ir2mqtt.py", line 248, in loop
    publish_session_time()
  File "/home/dave/dev/ir2mqtt/ir2mqtt.py", line 141, in publish_session_time
    publish_light_info()
  File "/home/dave/dev/ir2mqtt/ir2mqtt.py", line 153, in publish_light_info
    date_and_time = datetime.astimezone(state.ir_location.timezone)
TypeError: descriptor 'astimezone' for 'datetime.datetime' objects doesn't apply to a 'America/New_York' object
DaveSanders commented 1 year ago

FWIW, I'm debugging it and trying to figure it out. I'll fork and do a PR if I can figure out the two issues. They are both related to timezone parsing. (obviously)