Danielhiversen / PyXiaomiGateway

PyXiaomiGateway
MIT License
152 stars 55 forks source link

Migrate to async listener #196

Closed starkillerOG closed 2 years ago

starkillerOG commented 2 years ago

Demo script:

import asyncio
from xiaomi_gateway import AsyncXiaomiGatewayMulticast

gateway_ip = "192.168.1.IP"

async def asyncio_demo(loop):
    def callback_func_gateway(data):
        print("Gateway callback")
        print(data)

    multicast = AsyncXiaomiGatewayMulticast(interface = "any")

    await multicast.start_listen()

    multicast.register_gateway(gateway_ip, callback_func_gateway)

    await asyncio.sleep(30)

    multicast.stop_listen()

if __name__ == "__main__":
    loop = asyncio.new_event_loop()
    loop.run_until_complete(asyncio_demo(loop))
starkillerOG commented 2 years ago

@syssi could you have a look and merge?

syssi commented 2 years ago

I will test the new implementation later the week and provide some additional feedback! Thanks for your time!

starkillerOG commented 2 years ago

@syssi since the new async listener will require some small changes in HomeAssistant, you can't yet test with HomeAssistant. I posted my demo script in the discription of this PR, if you push buttons/open doors (with aqara) while running the script, you schould see the events coming in. (just change the IP to the IP of your aqara gateway).

starkillerOG commented 2 years ago

@syssi could you review/merge this?

starkillerOG commented 2 years ago

@syssi gentile reminder.

syssi commented 2 years ago

Sorry for the delay and thanks for the reminder. I try hard! :-)

ReWiG commented 2 years ago

I would like to know what is the status of the verification of this PR? Is additional help needed?

syssi commented 2 years ago

@ReWiG If you could do a review and some testing I would be happy. I would like to make sure this change improves the situation and doesn't make it worse.

starkillerOG commented 2 years ago

@ReWiG you can test this using the demo script in the discription. @syssi Note that I did test it myself using 2 gateways, but I do get you want to have it tested on a diffrent network by someone else.

starkillerOG commented 2 years ago

@syssi can you just merge this and release a new version? We can always easily revert to a previous version....

starkillerOG commented 2 years ago

@Danielhiversen could you maybe review/merge?

starkillerOG commented 2 years ago

@Danielhiversen would you be so kind to also release a new version to pypi?

Danielhiversen commented 2 years ago

Done

Danielhiversen commented 2 years ago

Ahh, the .travis builder is not working anymore. Will look into it.

starkillerOG commented 2 years ago

@Danielhiversen thank you very much for releasing the new version! The HomeAssistant PR is here: https://github.com/home-assistant/core/pull/74979