How to list out all possible states of an entity?

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?

1 Like

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.

1 Like

Oh okay, thanks. I am ok with reading some code.

… how do I go about finding the location of the code behind a specific entity or even entity type?

The code is at https://github.com/home-assistant/home-assistant/tree/dev/homeassistant

If you go to the components folder, you will find pretty much everything there. You can also use search feature.

3 Likes

That’s great, thank you very much

Hi all,

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)
  • In homeassistant.components.device_tracker I see device_state_attributes but not sure how to call that on my device_tracker
  • 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 %}

device_trackers possible states are:

home
not_home
Zone Name

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.

1 Like

Thanks @petro, I really appreciate you taking the time to reply!

  1. 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.
  2. 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!
  3. homeassistant.components.device_tracker - device_state_attributes I see the following
    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)
  4. Thank you for that clarification and I appreciate the link to the example! :slight_smile:

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.

Sorry, it’s not possible. I forgot to mention unavailable state because all entities can have this state if the device is unavailable.

That’s cool, it is what it is. Thank you again for taking the time to answer my post, it’s much appreciated!