galletn / iaqualink

Home Assistant Iaqualink Vacuums Robots
8 stars 1 forks source link

HACS install sensor.py mapping incorrect attributes #2

Closed ppastur closed 1 year ago

ppastur commented 1 year ago

Reposting from #https://github.com/flz/iaqualink-py/issues/23

HACS install works but there is an issue with mapping which prevents the sensor from loading in HASS

I managed to get it working by tweaking sensor.py

Here is what I changed:

line 110 is trying to map

self._temperature = data["state"]["reported"]["equipment"]["robot"]["sensors"]["sns_1"]["val"] but it should be (in my case) self._temperature = data["state"]["reported"]["equipment"]["robot"]["sensors"]["sns_1"]["state"] as "val" doesn't exist

so now I get this

not sure if this is just specific to my device.

galletn commented 1 year ago

@ppastur, I expected this indeed, I'm wondering if this is related to your robot or not.

I could easily add a if else based on robot numbers .. or try catch ... but not sure what the cleanest solution is. at this moment the try catch seems the cleanest to avoid building up a list of "supported" robots.

Might need to add the list of "tested" robots in the readme, that would also avoid people wondering why it goes wrong.

ppastur commented 1 year ago

I understand. I cant really comment on the best solution because I have no clue how often the schema will change per model. I do agree that we need to gracefully handle the error so the other attributes can load and worst case scenario you will simply have a reduced list of attributes. In my case, the code stopped and no sensor was instantiated in HASS. I figured it out because I used postman to look at the schema and compare it to what the code was trying to map. Does yours work without the change?

galletn commented 1 year ago

@ppastur for me it works indeed, can you try out the new version? added the error logging and catch on the temperature

ppastur commented 1 year ago

Just reloaded the integration from HACS and I can confirm it works without issue.

LOki61 commented 1 year ago

Just reloaded the integration from HACS and I can confirm it works without issue.

I haven’t tested yet guys, once I get my robot back from repairs will try again