JuiceRescue / juicepassproxy

Proxy UDP requests to/from Juicebox EV chargers to MQTT discoverable by Home Assistant
Apache License 2.0
86 stars 12 forks source link

UnboundLocalError when receiving DBG,ERR:JCom_TxTcpData_Wlan #37

Closed Snuffy2 closed 11 months ago

Snuffy2 commented 11 months ago

For a quick fix, I'll just ensure active defaults to true. I'll see if I find more in my logs, but we probably want to detect ERR or DBG,ERR in the data and update the HA status to Error or something like that.

juicepassproxy  | 2023-11-21 22:54:16,210 DEBUG      remote: b'CMD22254A0040M040C124S533!JYJ$'
juicepassproxy  | 2023-11-21 22:54:20,972 DEBUG      local : b'0910042001280643829222621623:DBG,ERR:JCom_TxTcpData_Wlan open err 7034,3(https://directory-api.emotorwerks.com/v1/profiles/juicebox/0910042001280643829222621623/):'
juicepassproxy  | Traceback (most recent call last):
juicepassproxy  |   File "/juicepassproxy/juicepassproxy.py", line 592, in <module>
juicepassproxy  |     main()
juicepassproxy  |   File "/juicepassproxy/juicepassproxy.py", line 584, in main
juicepassproxy  |     pyproxy.udp_proxy(src, dst)
juicepassproxy  |   File "/juicepassproxy/pyproxy/pyproxy.py", line 56, in udp_proxy
juicepassproxy  |     data = LOCAL_DATA_HANDLER(data)
juicepassproxy  |            ^^^^^^^^^^^^^^^^^^^^^^^^
juicepassproxy  |   File "/juicepassproxy/juicepassproxy.py", line 252, in local_data_handler
juicepassproxy  |     message = self.basic_message_try_parse(data)
juicepassproxy  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
juicepassproxy  |   File "/juicepassproxy/juicepassproxy.py", line 224, in basic_message_try_parse
juicepassproxy  |     elif part[0] == "E" and active:
juicepassproxy  |                             ^^^^^^
juicepassproxy  | UnboundLocalError: cannot access local variable 'active' where it is not associated with a value
juicepassproxy  | 2023-11-21 22:54:25,230 DEBUG      JuiceboxUDPCUpdater check...
juicepassproxy  | 2023-11-21 22:54:25,456 DEBUG      Active UDPC Stream: 8
juicepassproxy  | 2023-11-21 22:54:25,456 INFO       UDPC IP incorrect, updating...
Snuffy2 commented 11 months ago

Other ones from a quick search of the logs:

juicepassproxy  | 2023-11-18 23:25:45,889 DEBUG      local : b'0910042001280643829222621623:DBG,NFO:NTP timeout. Attempting NTP Resync:'
juicepassproxy  | 2023-11-18 23:25:46,960 DEBUG      local : b'0910042001280643829222621623:DBG,NFO:time sync from NTP successful:'
juicepassproxy  | 2023-11-19 08:54:32,336 DEBUG      local : b'0910042001280643829222621623:DBG,NFO:JCL_tx_hr_init Next ECL-Tx 8:50:'
juicepassproxy  | 2023-11-19 10:00:38,007 DEBUG      local : b'0910042001280643829222621623:DBG,WRN:Events_03_04ce0Z-01-01 Open Err 7034:'
juicepassproxy  | 2023-11-21 22:05:00,357 DEBUG      local : b'0910042001280643829222621623:DBG,WRN:ELife_0 Open Err 7034:'
juicepassproxy  | 2023-11-21 22:05:00,364 DEBUG      local : b'0910042001280643829222621623:DBG,WRN:UpdateLifetimeEnergy: ELife_0 err 7034,0,1916134:'
juicepassproxy  | 2023-11-21 22:05:00,372 DEBUG      local : b'0910042001280643829222621623:DBG,WRN:ELife_1 Open Err 7034:'
juicepassproxy  | 2023-11-21 22:05:00,379 DEBUG      local : b'0910042001280643829222621623:DBG,WRN:UpdateLifetimeEnergy: ELife_1 err 7034,1,1916134:'
juicepassproxy  | 2023-11-21 22:05:00,391 DEBUG      local : b'0910042001280643829222621623:DBG,WRN:ELife_2 Open Err 7034:'
juicepassproxy  | 2023-11-21 22:05:00,398 DEBUG      local : b'0910042001280643829222621623:DBG,WRN:UpdateLifetimeEnergy: ELife_2 err 7034,2,1916134:'
juicepassproxy  | 2023-11-21 22:05:05,553 DEBUG      local : b'0910042001280643829222621623:DBG,WRN:ECache_03_04ce2Z-01-01 Open Err 7034:'
juicepassproxy  | 2023-11-21 22:05:19,000 DEBUG      local : b'0910042001280643829222621623:DBG,WRN:Events_03_04ce2Z-01-01 Open Err 7034:'
juicepassproxy  | 2023-11-21 22:54:20,972 DEBUG      local : b'0910042001280643829222621623:DBG,ERR:JCom_TxTcpData_Wlan open err 7034,3(https://directory-api.emotorwerks.com/v1/profiles/juicebox/0910042001280643829222621623/):'