Here’s a newbie question: How do I find out all the possible states of an entity?
When in Home Assistant web console, I click on the developer tools and pick the States menu, I can see a list of all my entities. But I can only see the current State value. How can I see all the possible other State values of every entity so that I write my automations?
The state values are not always same, and they can be anything. Unfortunately there is no easy way of getting that information. If you are looking for a specific entity, you might want to check the corresponding code of that entity/device for possible state values.
I’m new to HA and have the same question about determining all the possible states of an entity
Question
I’d like to get all the possible states of my device_tracker which was provided via integration with my Mikrotik router. Per Device Tracker documentation:
“The state of the device will be determined by the source that reported last.”
Per @skalavala 's answer I looked in the Mikrotik code but was unable to find the states looking through the code.
Follow-up Question
I’m wondoering if there’s a way to code, and ultimately debug, a script to display the states?
I’m a developer (C# & recently Java) though new to HA, Python, and Lynux - I’m running HA on Windows 10 Hyper-V
I’ve noticed the following:
Developer Tools doesn’t seem to have a place to write/call a script (not sure where to put a script to call)
Templating documentation shows the following: Print out a list of all the sensor states:
{% for state in states.sensor %}
{{ state.entity_id }}={{ state.state }},
{% endfor %}
Yes it does, call service tab allows you to call all services. A script is a service.
This is displayed in developer tools → states page. You have to have a wide enough monitor but the attributes are on the right most column.
Those are state objects, not the individual states a device can be. State objects are what the state machine stores information about each device at the current moment of time. Here’s a good explanation.
Thanks @petro, I really appreciate you taking the time to reply!
Per Device Tracker documentation I did see the 2 states that you referenced (home and not_home) but I discovered that my device also has a state of unavailable (which I was able to utilize in an automation), that’s why I’m pursuing an easy way to find all the states of an entity that I might be able to use for any entity, not just the one I’m using now - again complete newbie, this is my 2nd day looking at HA but I hope to find some time to use it more.
Thanks, your reply gave me just enough of a hint to search/find this cool little scripts video, in case others see this and want more detail. This could come in handy, thank you!
which just shows the current state so I was confused by device_state_attributes but I guess that’s just referencing that these are the filter states of the following entities, I was hoping it was a way to show all the available states of an entity (see # 1)
Thank you for that clarification and I appreciate the link to the example!
I guess in the end I’m still hoping that there might be some way to get a list of all the possible states of any given entity, as the OP asked, through a script or otherwise? If possible, maybe a link to some reference - documentation, description, video… If not, which sounds like it may be the case from the other answers, thanks again for taking the time you already spent helping and for anything else you may be able to offer.