#Detect the Entity ID in a input_text set_value Event

1 messages · Page 1 of 1 (latest)

fluid jackal
#

I have an automation that I want to implement but the only way I can think to do so seems like it might not be possible. I am writing specific, set, values to a text helper off some actions, and then using that stored value to trigger card/section visibility. I want to be able to detect if the triggering action is attempting to write the same value as the previously stored value, and then trigger another action off that, but my problem is that the "State" trigger does not fire if the same value is being sent, since it's technically not updating even though the event is being sent. So I was then going to listen for "set_value" service calls to the specific entity id, but there seems to be no way to have an automation read the entity ID from the event, because it's being passed as a list and not a string. For example:

event_type: call_service
data:
domain: input_text
service: set_value
service_data:
value: Example Value
entity_id:
- input_text.example_helper

Is there something I am missing here? Or is it just actually not possible to do this? I might be missing something blatant, this is a lot more in-depth than I usually get with my automations.

I also don't really get why entity_id is being passed as a list when there is only a single value

Let me know if I explained anything poorly as well and I'll clarify, or at least try lol

patent ravine
#

what exactly are you triggering from?

fluid jackal
#

Yeah that's what I was doing it's just kinda clunky with how many values there are. I was hoping to not have to hardcode any of the values and just detect if the previous value was the same regardless of what the value actually is.

Firing the set_value events based on card tap actions across various dashboards for a handful of different users

#

It's kinda wild that this isn't something that can be detected just directly. Should default to sending entity ids as a string when there is only 1 id included. I would think this kind of thing would be useful for a bunch of use-cases but I guess it is still pretty niche

gloomy orchid
#

What are you writing to the input_text exactly? Can post an example of its possible values, and the action you are using to set it?

fluid jackal
patent ravine
#

i mean... you could set the value to something else as a placeholder first before setting it to what it needs to be.
that means it would always trigger but you would get a placeholder event too which you would have to do nothing with.

there is definetly better solutions to this problem though

gloomy orchid
#

You could force the input_text's state to update by passing the update time in the value, like {{ {'a': 'Music', 't': as_timestamp(now())} }}. That would guarantee that the state would change every time you call input_text.set_value, even if the value is the same as the previous one. Then later on in your automation, you would need to parse the state of the input_text to retrieve the value - something like {{ (states('input_text.xxx') | from_json).a }}.

fluid jackal