Hi
I want to record how much food my cats are eating in average at a specific time. So I wrote a python script which get the right entity e.g. cat.kalle_after_noon_food
, get the state and the counter
attribute, doing some math and then updates the state of the entity and the counter. If the entity cat.kalle_after_noon_food
not exists it will get created (should be only happen at the first time). To control the right output of the script, I’m using the sqlite addon to check the entities in the database. It’s all working fine, but when I restart HA the entity card
type: entities
entities:
- entity: cat.kalle_after_noon_food
name: Kalle nachmittags
is saying Entity not available: cat.kalle_after_noon_food
although the entity is inside the sql database after the restart. When I run the python script again a new entity without a reference to the old entity gets created (old_state_id
is NULL).
Why does HA behave like this and how can I load the sql data into the HA after restart
or something like this to get what I want.
What I’ve tried:
- adding the entities to the recorder:
recorder:
include:
entity_globs:
- cat.*
- adding the entities to the history:
history:
include:
entity_globs:
- cat.*
- adding the entities to the customize.yaml file and include in the configuration.yaml file
cat.kalle_after_noon_food:
unit_of_measurement: 'g'
- adding automation.initial_state: ‘on’ (even if I don’t really know what this is doing)
cat.kalle_after_noon_food:
unit_of_measurement: 'g'
automation:
initial_state: 'on'