cadavre / miio_gateway

lumi.gateway.mieu01 with custom miio_client integration for HA
54 stars 22 forks source link

[New feature] Restore sensor state after HA restart #5

Closed cadavre closed 4 years ago

cadavre commented 4 years ago

I've changed basic representation of sensor from Entity to RestoreEntity and added restore parameter to sensor mapping.

Now, restore defaults to False but you can overwrite it to get your sensor states back after HA restart.

You can find the release-candidate version in #dev-restore branch: https://github.com/cadavre/miio_gateway/tree/dev-restore

I haven't tested it yet by myself, but you're free to try and let me know. :)

kind3r commented 4 years ago

Hi @cadavre , There is an issue with XiaomiGatewayAlarm, it does not implement supported_features required by RestoreEntity (guessing, not an expert in python) :


Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/miio_gateway/alarm_control_panel.py", line 17, in setup_platform
    devices.append(XiaomiGatewayAlarm(gateway))
TypeError: Can't instantiate abstract class XiaomiGatewayAlarm with abstract methods supported_features```
cadavre commented 4 years ago

Hi @kind3r is it just on 0.103 or even previous versions?

kind3r commented 4 years ago

HA 0.103.0 yes. It's a bit more dificult for me to test older versions. I'm new to HA and still trying to figure it out.

I have modified the alarm_control_panel.py :

cadavre commented 4 years ago

Fixed.