Closed roccolord closed 3 months ago
This is a great integration however it would be great if values persisted across restarts
Hello, I agree but so far I wasn't able to find the way to do that :/.
Found this regarding the states:
The RestoreEntity class is used by Home Assistant to restore an entities state when you restart home assistant. It saves periodically and when you shutdown home assistant, all the states of your entities in a file under config/.storage/core.restore_state. When you startup home assistant, integrations that extend RestoreEntity can call a method async_get_last_state(self) to retrieve the previous state and use it to setup the component.
The sensors created with xtend_tuya doesn't exist in core.restore_state.
Sensors which restore the state after restart or reload should not extend RestoreEntity because that does not store the native_value, but instead the state which may have been modified by the sensor base entity. Sensors which restore the state should extend RestoreSensor and call await self.async_get_last_sensor_data from async_added_to_hass to get access to the stored native_value and native_unit_of_measurement.
https://developers.home-assistant.io/docs/core/entity/sensor/
Hello, Thanks for the info, I've implemented this feature and now the values are being restored :).
Please update to the latest version.
Have a nice day, Azerty
Hello thanks for a good xtention! Could you add so that consumption is retrieving the last known value at boot? would be nice so that graphs for consumption over time doesn't reset when you need to restart HA.