dawidchyrzynski / arduino-home-assistant

ArduinoHA allows to integrate an Arduino/ESP based device with Home Assistant using MQTT.
https://dawidchyrzynski.github.io/arduino-home-assistant/
GNU Affero General Public License v3.0
498 stars 118 forks source link

No configuration for expire_after #159

Closed PM04290 closed 8 months ago

PM04290 commented 1 year ago

Some times, for example for push button or else, it would be interesting to set expire_after parameter on mqtt configuration, for sensor and binary_sensor; as it is possible to do in the configuration of zigbee2mqtt, for example: https://www.zigbee2mqtt.io/guide/configuration/devices-groups.html

real case example : push button who send pressed time : 350ms, 1500ms, 5200ms, etc... actually if i want to do the same function i must send a 0 (zero) value after few millisecond, so expire_after in HA save this action and is better for mqtt bandwidth :)

dawidchyrzynski commented 8 months ago

This feature will be available in the upcoming version of the library. Please refer to the linked Pull Request for more information.

PM04290 commented 8 months ago

As there were no more modifications I had to Fork the library, I added expire_after and state_class; but the most important thing was changing the mqtt connection. I would prefer to use this library if it will continue to live.

dawidchyrzynski commented 8 months ago

@PM04290 the new features are already available on the develop branch. Feel free to try them.

but the most important thing was changing the mqtt connection.

Could you please provide additional details? I'm unsure about what you're referring to.

PM04290 commented 8 months ago

Because of multiple disconnect callback when mqtt is OFF, i must put comment on callback process; only when pubsubclient detect them, with adding onDisconnect callback. image image image