Read entity state from MQTT topics
Opened this issue · 1 comments
Per @mion00's suggestion in #18, we should store state of our created entities in an MQTT topic.
I have an idea: what if we use the broker as our "state storage"? Since all the entities are strictly correlated with a config message inside the HA topic tree, and those are retained, we could read them on startup, and for each device in the "device" field we create this "virtual device" that the user interacts with.
It might seems a bit cumbersome, but this way we don't depend on a local state file and in addition any device deleted by the user in HA will not show up for us, avoiding sync problems.
The more I think about it, the more I like this idea. Being able to persist a current state in our entities should make the command line tools less awkward.
Edit: Make this to read the config topic and load the state(s) it points at.
Maybe there was a bit of misunderstanding on my part: right now the states of the entities are already published under the hmd/
topic tree when an entity is created./its state changes. The CLI therefore only needs to retrieve these retained messages on startup to know the entities that are available for the user to interact with.