skodaconnect / myskoda

Python library for interacting with MySkoda APIs.
MIT License
8 stars 20 forks source link

MQTT event field can have lowercase values #55

Closed dvx76 closed 1 month ago

dvx76 commented 1 month ago
2024-09-29 10:20:13 WALLY myskoda.mqtt[25433] DEBUG Message (service-event) received for TMBxxx on topic charging: b'{"version":1,"traceId":"a1877638-cd2d-4907-8716-f9c0292e4794","timestamp":"2024-09-29T08:19:49Z","producer":"SKODA_MHUB","name":"change-soc","data":{"mode":"manual","state":"charging","soc":"67","chargedRange":"324","timeToFinish":"200","userId":"uuid","vin":"TMBxxxx"}}'
2024-09-29 10:20:13 WALLY asyncio[25433] ERROR Exception in callback Client.loop_read()
handle: <Handle Client.loop_read()>
Traceback (most recent call last):
  File "<string>", line 15, in __mashumaro_from_dict__
  File "/home/fdevaux/.pyenv/versions/3.12.2/lib/python3.12/enum.py", line 744, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fdevaux/.pyenv/versions/3.12.2/lib/python3.12/enum.py", line 1158, in __new__
    raise ve_exc
ValueError: 'manual' is not a valid ChargeMode

Joostlek — Today at 10:42 Lower case is nice because our translation files work with snake_case You could also consider making non essential values optional. In Withings I have a few enums that are optional, so i made a thing that puts in the log like, hey, this measurement unit is not part of the enum, please open an issue at this repo

WebSpider commented 1 month ago

This is currently sending my 2024.10.b install in a logging loop, logging about 40MB/min.

dvx76 commented 1 month ago

@WebSpider it's not really this specific issue which makes MQTT go berserk. It's any issue parsing the event. I'm fixing this specific parse issue here but I'll try to take a look at the generic MQTT issue today as part of skodaconnect/homeassistant-myskoda#63