openlumi / lumimqtt

Service to control Xiaomi Gateway with MQTT
GNU General Public License v3.0
40 stars 14 forks source link

Periodic publish #23

Closed muniter closed 3 years ago

muniter commented 3 years ago

The idea of this pull request is to improve periodic publishing to include lights, and also send the current state of light and sensor when connect/reconnect. This addresses #22

Changes:

  1. Refactor publishing of sensors and lights to a method each.

    • _publish_sensor
    • _publish_light

    Allowing to reuse in other parts of the code.

  2. Refactor periodic publish to also publish lights state without repeating code. Implementing logic to send in the given tele period.

  3. Addition on _connect_forever sending of sensor and light states after connecting. Therefore keeping the state in sync on reconnections.

If you agree with the changes I can update the readme to reflect this new configuration option. I'm willing to make the changes you consider appropriate in the code.

devbis commented 3 years ago

Thanks!