I’ve a problem that I don’t understand. I’ve some entities created with a script in python_scripts that call hass.states.set() method.
Those entities are updated at least daily (every few hours at most).
Once a day (that seems variable time, not fixed), independently by when those entities were updated (apparently) HA deletes them (I couldn’t find any information about the deletion in logs).
If I recreate them, the history is still here, but it’s frustrating.
I just noticed the same problem with another “integration”: I’ve set “Notify for Amazfit” app (Android) to send data directly to HA (use a webhook). Even the entities created with this method are deleted once a day, until the app send data again.
Anyone has a suggestion or a hint to resolve the problem?
You are not creating entities with hass.states.set(), you are injecting a state change.
That change will be represented by a fake entity until you restart.
Create an integration that provides entities if you want to create entities. Or use input_text helpers and the input_text.set_value service.
Thank you! I didn’t think that the restart and the “entity deletion” was connected (I just remembered that this morning I applied the 2023.1.6 update).
So, for the first problem I’ve 2 way to fix this problem, as I understand:
The correct way is to study how to make an integration and implement it
The dirty way (in this case is possibile) is to create an automation that re-run the entities creation at every boot
So I think that I will use the 2) until the 1) is ready.
For the second problem (the Amazfit watch integration) I have to write a trigger-based template sensor (for every entity) with platform: state that “store” the new value anytime it arrives.