simbaja / gehome

Python SDK for GE smart appliances
MIT License
42 stars 29 forks source link

ErdCode decoding ValueError #48

Closed NickStallman closed 1 year ago

NickStallman commented 1 year ago

When using this with a brand new Haier fridge (Model HRF680YPAA) I kept getting this error:

ValueError("invalid literal for int() with base 10: '0A'

I added some additional error checking in gehomesdk/erd/erd_encoder.py and got this:

2023-01-07 11:52:05,767 DEBUG    Setting ErdCode.APPLIANCE_TYPE to ErdApplianceType.FRIDGE
2023-01-07 11:52:05,767 DEBUG    Setting ErdCode.SABBATH_MODE to False
2023-01-07 11:52:05,767 ERROR    Got ValueError ErdCode.WIFI_MODULE_UPDATING - 0A
2023-01-07 11:52:05,767 DEBUG    Setting ErdCode.WIFI_MODULE_UPDATING to b'\n'
2023-01-07 11:52:05,767 ERROR    Got ValueError ErdCode.WIFI_MODULE_UPDATING - 0A
2023-01-07 11:52:05,767 DEBUG    Setting ErdCode.WIFI_MODULE_SW_VERSION to 0.1.11.50
2023-01-07 11:52:05,767 DEBUG    Setting ErdCode.WIFI_MODULE_SW_VERSION_AVAILABLE to 0.0.0.0

No clue why it's set to 0A.

My little patch adds a except for ValueError.

        try:
            return self._registry[erd_code].erd_decode(erd_value)
        except KeyError:
            return erd_decode_bytes(erd_value)
        except ValueError:
            _LOGGER.error(f'Got ValueError {erd_code} - {erd_value}')
            return erd_decode_bytes(erd_value)

Currently if that error is hit then the entire thing aborts, with that except it will continue running at least which seems like a good idea. Not sure if erd_decode_bytes is the correct thing but it seems to work.

simbaja commented 1 year ago

I think that they're changing some meaning of some of the codes between the brands... this one should just be a bool (0 or 1), but clearly isn't. I've added your patch for now, but we may need to make some other updates.