Cereal2nd / velbus-aio

Velbus Asyncio
Apache License 2.0
15 stars 10 forks source link

Fix requirement of reload of Velbus integration in HA after startup. #23

Closed DannyDeGaspari closed 2 years ago

DannyDeGaspari commented 2 years ago

This change fixes the scanning timeout before the scan is ended due to slow start of Velbus integration in HA. Instead of waiting for 15s, it waits now for the end of scan event which is detected by the packet transmission by checking if address 255 is coming from the message queue. The Velbus integration reload after HA has started is now not needed anymore. Also the last address was not scanned and is also fixed now.

You can be critical on my changes because its my first attempt in asynchronous IO.

Best regards, Danny

Cereal2nd commented 2 years ago

so basically we now wait until the last scan message is send before starting the wait for the full load of the module ?

DannyDeGaspari commented 2 years ago

Yes, for example on my system where HA Core is running on a RPi 3B+: At startup of HA, scanning starts so slowly that after 10 addresses have been scanned, the 15s timeout already jumps in. So velbusaio does not listen to the remaining scan responses anymore. After roughly 100 addresses have been scanned, the scanning rate is going at the normal rate of 60ms per address. This is only at startup of HA, when you do a reload of the integration afterwards, scanning runs at the expected rate from the first address.

And I think panic1 has the same issue on his system: https://github.com/Cereal2nd/velbus-aio/issues/22