Edit dict object output

Hello all.
I have a kid in school here in Denmark.
That means that I have to use a portal called Aula.

A dev have made a plugin for Aula that pulls a handful of data in.

I am specifically interested in the location information I can pull do to how easy it is to go to the correct location at the school to go pick up my daughter.

The thing is that it is a long string of text.
And when I pull the location data to my phone as a push message it gives me the long string of info.

I just want one line and remove a word and : from the message.

This is the info I have do to the trail and error attempts I have done whit help from another one.

The location attribute contains a dictionary. The keys in the dictionary are id, name, description, etc. It’s unclear to me which key you want but I will assume it’s name. Here’s how to get the value of the name key.

{{ state_attr('sensor.3a_freja', 'location').name }}

Totally forgot to tell which one I needed.
But yes. It was the name part.

But will this code snip only show the value after “name:” or will it include “name:” as I does now?

I can’t test the output before tomorrow do to I have picked my daughter up a few hours ago.

It reports the value of the name key.

It’s not. That’s what Taras is trying to show you. The value of an attribute isn’t always text. In this case its a dictionary so you need to treat it like a dictionary and ask for the value of the key that you want.

Just wanted to be clear since this question made it seem like you still thought it was a block of text.

Perfect :+1:
I will give it a try and test it when she gets of from school tomorrow and report back.

But for now I will mark it as the answer.

1 Like

I have tested it today and it works perfectly.

Thanks :+1:

1 Like