How to get value from an Attribute with a space in it?

First time post, trying to look for some help that I can’t find an answer for.

I am trying to setup a template sensor with an attribute from inside the Xbox Live Sensor. The sensor has some attributes that have spaces in them and I can’t figure out how to get their values.

Attributes shown in the developer tools states menu are below:

XboxOne Background: Home
XboxOne Full: Plex
friendly_name: PawnyNZ
icon: mdi:xbox

I can successfully get the friendly name value via:

value_template: ‘{{ states.sensor.xbox_pawnynz.attributes.friendly_name }}’

But I can’t for the life of me find out how to get the XboxOne Full attribute which has the space in the attribute name.

Any help is appreciated.

Did you tried replacing the space by an underscore? So XboxOne_Full

Yeah, tried that but no luck in getting the value.

I found a way to do it. With the GTFS sensor, this is the template I’m using to get the Route Short Name attribute:

{{ states.sensor.tisseo_work_home.attributes['Route Short Name'] }}

Your attribute could probably be fetched with this template:

value_template: '{{ states.sensor.xbox_pawnynz.attributes["XboxOne Full"] }}'
4 Likes

Try to go to YOUR_IP::8123/dev-template and enter:
{{ states.sensor.xbox_pawnynz.attributes }}

2 Likes

Awesome!
I can confirm that the below works and realised how great the Dev Template section is for checking. And here I was restarting Home Assistant every time I wanted to change something ><

value_template: ‘{{ states.sensor.pawnynz.attributes[“XboxOne Full”] }}’

So now I can start making some automation’s based on what I am doing on the Xbox.

1 Like

If anyone is interested for using this for themselves, I ended up with the template sensor setup as the below so that the sensor shows as Offline rather than null/nothing when the Xbox is turned off.
Note: replace “pawnynz” with your xbox live ID:

  xboxapi_current:
    value_template: '{% if is_state("sensor.pawnynz", "Offline") %}Offline{% else %}{{ states.sensor.pawnynz.attributes["XboxOne Full"] }}{% endif %}'

To get some attribute values from QNAP, this did worked for me:

{{ ((states.sensor.qnap_xyz_memory_usage.attributes['Memory Size'] )) }}

Thanks a lot