Custom-UI - Context Specific Friendly Name

Hey all, how can I get the custom-ui defined friendly names?

Tried a few iterations of this with no luck…

friendly_name = self.get_state(device, attribute="all")['attributes']['group']['group.battery_group']['friendly_name']

is this possible?

First just try printing what get_state() returns so you can see where it is …

I would guess:

friendly_name = self.get_state(device, attribute="all")['attributes']['friendly_name']

If you have a specific device in device

Thanks, @aimc I was hitting an exception I wasn’t seeing so your *poke to use the log more helped. One of the battery devices was not in my group custom-ui group so it was barfing.

It turned out it is like so:

        try:
            friendly_name = self.get_state(device, attribute="group")['group.battery_group']['friendly_name']
        except TypeError:
            friendly_name = self.get_state(device, attribute="friendly_name")
        self.log(friendly_name)
1 Like