How to template the companion app attributes

looking to isolate the attribute country_code, called ISO Country Code in the Lovelace frontend, I searched for that in the attributes list filter directly, but it shows empty,


though it is displayed in the attributes when only searching the entity_id.

Schermafbeelding 2020-11-06 om 15.08.19

{{states.sensor.xxx.geocoded_location.attributes}} shows the entity with all attributes.

{{states.sensor.xxx.geocoded_location.attributes.['ISO Country Code']}}

shows nothing, nor does {{states.sensor.xxx.geocoded_location.attributes.ISOCountryCode}} which should really be correct, according to https://companion.home-assistant.io/docs/core/sensors#geocoded-location-sensor ?

makes me wonder how to get to the attributes of the geocoded_location sensor at all…

please help me out here, thanks!

(edited the atributes to attributes in this post, but that wasn’t the issue in the template editor)

I think you should stop using the states.sensor.xxxx notation and switch to states(xxx) as mentioned in the docs.

This template works fine for me:

{{ state_attr('sensor.location_phone_dimitri', 'ISO Country Code') }}

I think to make your template work you’d need to change it to this:

{{ states.sensor.xxx.geocoded_location.atributes['ISO Country Code'] }}

because this is working for me as well:

{{ states.sensor.location_phone_dimitri.attributes['ISO Country Code'] }}

how odd…

I always use the states() notations, but, because it didnt work before, I used the states.sensorxxx notation.

returning to my template editor now results in a NL :wink:


still, using the states page, remains empty when the ISO Country Code is entered in the attributes list.

btw, just noticed, that when editing in the template editor, coming from a valid template, the result field doesnt update, and the former valid template remains in view.