Custom location state or attribute for an entity for use in automation condition

Trying to figure out how to add a custom state or attribute to an entity of type media_player (using platform: kef), or something stand-alone, that will survive a restart without getting some default value from the configuration.yaml.

I have a pair of KEF LSX speakers which I sometimes move between two locations. I have two Automations to automatically configure their DSP settings based on the location. I would like to have some way to easily, and persistently (also surviving a restart), records in which of these two locations they currently are. Each time I move the, I would like to be able to simply hit a button in the GUI that sets the state, and the GUI will show which of these two locations is currently active.

Then based on this state/attribute, I’ll add a condition to the automations to only trigger the correct one based on where the speakers are currently said to be placed.

Ideas on the preferred or best or easiest ways to achieve such a persistent location state?

Create an input_select with two options for the two locations. Change the value of input_select in the UI when you move the speakers and then use this input_select as condition in your automations.
What you want to do with attributes for the entity is currently not possible.

Couldn’t find any way to add these things directly to the entity, only a few other posts asking similar questions.

This input_select approach looks like a pretty great alternative! Thanks!

Because it’s not possible currently, only with workarounds like python scripts or appdaemon. You can only set custom static attributes, but not dynamic.

This will work nicely.

image
image

1 Like