xiaomigateway icon indicating copy to clipboard operation
xiaomigateway copied to clipboard

switch to patch-less miio in latest homeassistant

Open mouth4war opened this issue 4 years ago • 13 comments

Latest homeassistant uses latest miio which supports Aqara bulb. Could this component switch to using that instead of patched miio?

mouth4war avatar Jun 18 '20 23:06 mouth4war

https://github.com/fanthos/xiaomigateway The PR added support with new version python-miio, it also supports HACS for easier install. I tested the new code with Aqara Relay, but bulbs not tested.

fanthos avatar Oct 31 '20 07:10 fanthos

Thanks I tried it but it doesn't work with my gateways. I have aqara ac partner v3 and aqara homekit gateway. Both don't work. Which one have you tried with?

mouth4war avatar Dec 03 '20 19:12 mouth4war

I have aqara ac partner v2 and it works. my patch only fix for new version of miio and nothing else.

fanthos avatar Dec 04 '20 01:12 fanthos

I thought your fork doesn't need a patch since it uses latest version of miio and you've deleted patch from your fork.

Why is it still needed?

mouth4war avatar Dec 04 '20 12:12 mouth4war

Sorry I mean my patch for this component. It works with miio unpatched upstream version.

I didn't change component code. If this component works before, my version should work too.

fanthos avatar Dec 07 '20 00:12 fanthos

Ok I tried again with aqara led bulb got this error:

Unable to prepare setup for platform xiaomigateway.light: Platform not found (cannot import name 'ATTR_ENTITY_ID' from 'homeassistant.components.light' (/usr/src/homeassistant/homeassistant/components/light/init.py)).

On Mon, 7 Dec, 2020, 6:21 am Boyi C, [email protected] wrote:

Sorry I mean my patch for this component. It works with miio unpatched upstream version.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/igzero/xiaomigateway/issues/7#issuecomment-739602204, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHBO45ZP6LSKTEL2Y4LEYLSTQRHZANCNFSM4OCHQ22A .

mouth4war avatar Dec 07 '20 10:12 mouth4war

I think it needs to be updated to use LightEntity instead of attr_entity_id. Like this component : https://github.com/syssi/philipslight/blob/develop/custom_components/xiaomi_miio_philipslight/light.py

On Mon, 7 Dec, 2020, 4:15 pm MoUtH4WaR, [email protected] wrote:

Ok I tried again with aqara led bulb got this error:

Unable to prepare setup for platform xiaomigateway.light: Platform not found (cannot import name 'ATTR_ENTITY_ID' from 'homeassistant.components.light' (/usr/src/homeassistant/homeassistant/components/light/init.py)).

On Mon, 7 Dec, 2020, 6:21 am Boyi C, [email protected] wrote:

Sorry I mean my patch for this component. It works with miio unpatched upstream version.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/igzero/xiaomigateway/issues/7#issuecomment-739602204, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHBO45ZP6LSKTEL2Y4LEYLSTQRHZANCNFSM4OCHQ22A .

mouth4war avatar Dec 07 '20 11:12 mouth4war

Seems HA version related. I am running HA 0.117, and it works.

---Original--- From: "mouth4war"<[email protected]> Date: Mon, Dec 7, 2020 18:46 PM To: "igzero/xiaomigateway"<[email protected]>; Cc: "Comment"<[email protected]>;"Boyi C"<[email protected]>; Subject: Re: [igzero/xiaomigateway] switch to patch-less miio in latest homeassistant (#7)

Ok I tried again with aqara led bulb got this error:

Unable to prepare setup for platform xiaomigateway.light: Platform not found (cannot import name 'ATTR_ENTITY_ID' from 'homeassistant.components.light' (/usr/src/homeassistant/homeassistant/components/light/init.py)).

On Mon, 7 Dec, 2020, 6:21 am Boyi C, <[email protected]> wrote:

> Sorry I mean my patch for this component. > It works with miio unpatched upstream version. > > — > You are receiving this because you modified the open/close state. > Reply to this email directly, view it on GitHub > <https://github.com/igzero/xiaomigateway/issues/7#issuecomment-739602204>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AHHBO45ZP6LSKTEL2Y4LEYLSTQRHZANCNFSM4OCHQ22A> > . >

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

fanthos avatar Dec 07 '20 11:12 fanthos

I'm on the latest 1.0 beta. LightEntity came with 0.118 which is current latest stable build.

http://dev-docs.home-assistant.io/en/master/api/components.html

mouth4war avatar Dec 07 '20 11:12 mouth4war

I just check the code, ATTR_ENTITY_ID not used in light.py. remove it and try again

fanthos avatar Dec 08 '20 01:12 fanthos

I just check the code, ATTR_ENTITY_ID not used in light.py. remove it and try again

Hi, all is works after ATTR_ENTITY_ID was commented in light.py. But I have a some bug (as i think). I have two aqara bulbs and almost every time when I'm restart hass one of the bulbs lost connection with the system (entity unavailable). Moreover every restart it can be different bulb.

minskmail avatar Jan 10 '21 19:01 minskmail

Problem with function in light.py. Often it hangs with 'index out of range' error. I'm not programmer, so I dont know what leads for the issue.

async def async_update(self):
    """
    Fetch new state data for this light.
    This is the only method that should fetch new data for Home Assistant.
    """
    brightness = 0
    result = await self._try_command(
        self._device.send,
        'get_bright', None, extra_parameters={'sid':self._sid})
    if result[0] is not None:                                              # index out of range error in that line
        brightness = result[0]
        if brightness > 0 and brightness <= 100:
            self._brightness = ceil((brightness * 255) / 100)
            self._state = True
        else:
            self._brightness = 0
            self._state = False
    else:
        self._brightness = 0
        self._state = False

minskmail avatar Jan 11 '21 18:01 minskmail

HomeAssistant now officialy supports the zigbee bulbs, but appertly there is something wrong with the "get_bright" command. See https://github.com/home-assistant/core/issues/48988

Does anyone here know what I coded wrong? Could more people test the official code?

starkillerOG avatar Apr 10 '21 20:04 starkillerOG