zewelor / bt-mqtt-gateway

A simple Python script which provides a Bluetooth to MQTT gateway, easily extensible via custom workers. See https://github.com/zewelor/bt-mqtt-gateway/wiki for more information.
MIT License
549 stars 116 forks source link

Am43 improvements pt2 #233

Closed andrey-yantsen closed 2 years ago

andrey-yantsen commented 2 years ago

Description

In this PR, I continue to improve the AM43 worker: I made a few mistakes in the state detection logic in the last one, especially when blinds have moved since the previous update.

Also, in the previous PR, I added some magic to automatically reduce desired update interval to 3 seconds when some changes were detected — to handle the complete open/close procedure quickly: now I moved this hardcoded 3 seconds to a configuration variable, documenting both default_update_interval and the new rapid_update_interval on the way.

In addition, I've switched the worker to use a patched Zemismart driver, which helps to detect whether a command was successful.

Plus, now you can select a desired device class for the blinds in HASS (previously, it was hardcoded) :)

Type of change

Please delete options that are not relevant.

zewelor commented 2 years ago

I think I've missed retry logic last time. There is some wrapped mechanism for retry in place already: https://github.com/zewelor/bt-mqtt-gateway/blob/debb5ae8544eff15ac0e4924a6eb9308b9f9a7ad/workers/thermostat.py#L200 and https://github.com/zewelor/bt-mqtt-gateway/blob/debb5ae8544eff15ac0e4924a6eb9308b9f9a7ad/workers/base.py#L95 . Maybe you want to use it.

andrey-yantsen commented 2 years ago

I've added the retry() usage and updated the config example; thanks for pointing it out!

andrey-yantsen commented 2 years ago

@zewelor, just a reminder, if you missed the notification :) I've fixed all your suggestions.

zewelor commented 2 years ago

Thanks for ping, missed previous notification. Looks great now thanks !