How to use waze entity attributes as sensor

Hello,

I would like to include the attribute “Route” of the Waze sensor as an own sensor to be able to output the calculated route on a display.

In this topic, the same issue was addressed and solved, however, I do not understand the solution or get with the presented solution always error messages and can not restart the system.

Solved Thread

My Questions are especially:

Where does ‘jeroen_naar_huis’ come from as a name. For me the Waze entity is called sensor.firma or in the waze integration itself simply “firma”. Is my ‘jeroen_naar_huis’ then simply ‘firma’? I have tried that without success.

The rest I have taken over analogous to my sensor designation, but I can’t restart HA because I always get error messages through the YAML.

Looking at the poster’s response:

I don’t read Dutch either. But what they’re doing is creating a template Sensor: (docs here)
Template - Home Assistant (home-assistant.io)

The value template of each one points to sensor.jeroen_naar_huis (Google Translate says that’s Joen to Home) Which makes sense if it’s a Waze sensor. Yours may be this ‘sensor.firma,’ here’s how to find out:

they’re pointing at a state_attr (attribute) not a state, so you want to find the waze sensor (your name here instead of theirs (sensor.firma), or in my case lets look at one of mine) in the dev tools:

See those attributes - that’s all the ‘extra’ stuff that sensor has available. The template sensor is just exposing them all as independent sensors - usually so you can put them on a dashboard easily with cards that don’t support accessing attributes directly. If you’ve hit the right one, those will be there. and you just use the code in the other example - replacing your entity and dropping them in the right place in your configuration.yaml.

1 Like

Thank you very much for the answer.

I have understood everything so far. But I still get an error message from the configuration.yaml.

How must the entry for the sensor look there?

With the following entry in Line 40. That’s between my other Sensors.

  Firma:
    value_template: '{{ state_attr("sensor.firma","route") }}'
    friendly_name: 'Firma Route'

i’ll get the following error:

Error loading /config/configuration.yaml: while parsing a block collection
in "/config/configuration.yaml", line 18, column 3
expected <block end>, but found '?'
in "/config/configuration.yaml", line 40, column 3

I think my problem is that I don’t know how the entry in Configuration.yaml should look like and where it should be.

1 Like

I think I found the solution in the Chinese Home Assistant help. It would be good if you confirm that the optimal entry looks like this.

  - platform: template
    sensors:
      firma_route:
        value_template: '{{ state_attr("sensor.firma","route") }}'
        friendly_name: 'Firma Route'

In any case, a sensor with the name “sensor.firma_route” was created, which also outputs the correct value.

1 Like

You got it. Also the docs for all of it are in that link labeled template above. Notice if you scroll down to the sensor section it gives you that syntax and where it should list in Configuration.

Glad you got it. Knowing how to do what you just did unlocks a ton of HA. If you dont like how something is presented you can now reformat it however you like.

Good luck! Happy automating!

1 Like

Again, thank you very much for your help! :grinning:

Nathan,

I noted your support on the subject of the attributes from the Waze integration, i wonder if you could take a look at my issue. I’m struggling to create a sensor from the distance attribute from the waze state. I have made a post on this earlier and linked to it below. In short, i can create a sensor that displays the route however i cannot seem to get any success with the distance. If i create a template (via Developer Tools), i see everrything i want but when I implement this in my sensors.yaml i get “unavailable” for the distance.

Thanks in advance