skodaconnect / myskoda

Python library for interacting with MySkoda APIs.
MIT License
9 stars 22 forks source link

ServiceEventName-specific deserialization of charging events #184

Closed dvx76 closed 2 days ago

dvx76 commented 2 weeks ago

After #183 every single field in ServiceEventChargingData.

We should probably look at deserializing these events differently depending on the name (ServiceEventName) and not just the topic.

E.g.

{"version":1,"traceId":"81b50439-af83-44e1-9515-5b3925d4c34a","timestamp":"2024-11-09T13:30:34Z","producer":"SKODA_MHUB","name":"charging-status-changed","data":{"userId":"97bee240-dd09-4d56-8d8b-fbdfxxxxxxxx","vin":"TMBAXXXXXXXXXXXXX"}}\

vs

{"version":1,"traceId":"b03c66fe-67c5-4cd1-b50f-3c551078f6d0","timestamp":"2024-11-09T15:04:48Z","producer":"SKODA_MHUB","name":"change-soc","data":{"mode":"manual","state":"charging","soc":"50","chargedRange":"195","timeToFinish":"440","userId":"ad0d7945-4814-43d0-801f-fbdfxxxxxxxx","vin":"TMBAXXXXXXXXXXXXX"}}
WebSpider commented 2 weeks ago

Loosly related: We probably should look at linking topic subscriptions to capabilities as well.

But yes, we need to start deserializing this data properly. Just like we should probably start properly serializing data we send, and not just slap a random dict in a json body.

fursov commented 1 week ago

@WebSpider do you work atm on this topic? I have some spare time and could take the ticket also unless you do already something.

WebSpider commented 1 week ago

Yeah im working on this when time permits

WebSpider commented 6 days ago

@fursov feel free to take this

fursov commented 6 days ago

do we know any other names besides "change-soc" and "charging-status-changed" @dvx76 reported above?

dvx76 commented 6 days ago

Check here https://github.com/skodaconnect/myskoda/blob/43b2061ac9f6cbdee50fbf6fb993c78932679510/myskoda/models/service_event.py#L14 and here https://github.com/skodaconnect/myskoda/blob/main/docs/mqtt.md

fursov commented 4 days ago

The first attempt is here: #235