esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
420 stars 26 forks source link

Restore component state from mqtt state topic after reboot #1622

Open syp1975 opened 2 years ago

syp1975 commented 2 years ago

Describe the problem you have/What new integration you would like

Restoring data from flash puts our device in risk with flash writes. If we want to reduce this risk, we must sacrifice some recent data. Restoring data from RTC is limited and not surviving a power failure.

What if the state of selected components could be restored from the mqtt broker?

Please describe your use case for this integration and alternatives you've tried:

This would be usefull for storing component data where is important to recover the latest state, like the position of an actuator, a counter, an integration, an average, ....

I would have tried with the mqtt_subscribe component, but I discarded the idea rapidly.

Additional context

This would require for selected components to:

Of course, also we need to setup an mqtt broker that supports retained messages and that is not using a scard or usb stick as permanent storage.

PRO: a great improvement for the safety and use cases of our devices. CON: when the device boots it will depend on mqtt broker survival and avaliability.

nagyrobi commented 2 years ago

I'd say not limit this to MQTT, also have the option restore from HA via the API.

Similar to https://github.com/esphome/feature-requests/issues/1492