How to use (waze) entity attributes in lovelace

Hi,

So I’ve been banging my head over this. I’ve read so much topics I don’t know where to start anymore.
I have a waze integration that:

  • uses a device tracker as ‘source’
  • uses a static address as ‘destination’

This creates an entity (sensor.jeroen_naar_huis) and number of attributes, amongst which are ‘duration’ and ‘distance’. Now I want to present those in human readable format in lovelace cards.
For example, the current values are:
Duration: 12,92
Distance: 9,14

The first challenge would be to actually present them in lovelace, the second one would be to fix their formatting.

I read tons of stuff about not being able to do this in Lovelace itself, you’d have to use templating, but please, either way I try to do it, it doesn’t work. Could anyone please provide some clean code and clear instructions on where to put code, that’d be helpful. This has been stressing me for nearly a week now and I’m getting pretty desperate!

Thanks in advance!

Ok so after many more nights of tinkering I finally found the solution. After having made the Waze integration, edit your configuration.yaml. Scroll down and enter something like:

In my case, the waze integration is called ‘jeroen_naar_huis’, so use this as pointer to get the attributes you’re looking for. The ‘jeroen_thuis_tijd’-part is the new name of the sensor you’re creating and you cannot use dashes, you must use underscores or you’ll get a crazy error.
Go to devtools and ‘yaml configuration’-tab. Click the ‘check config’ button and you should pass (if not, verify your syntax, HA is very tedious about syntax). As you can derive from the attributes, from top to bottom I here create 3 sensor-based attribute sensors: duration of the travel, distance of the travel and the route description. Also, the |round(n) portion helps to round down the numbers to whatever you feel is right.

Next, you can add these to lovelace by entering:

</ha-icon>&nbsp;<span style="color: #888888;">${states['sensor.jeroen_thuis_afstand'].state} km</span><br/>`

obviously, adjust _afstand to the corresponding attribute.

ALSO:
If you get ‘unavailable’ as a result in your newly created sensors. Check to see if you’re case-matching to the original sensor and its attributes. Go to devtools, 2nd tab (states) and find the original sensor. Scroll down a bit and you’ll get an ACTUAL attribute name overview (with its values). Match that exact case and try again. I spent 2 days on having it right, but case-mismatched, hence the ‘unavailable’ state.

Hope this helps anyone!
Cya

2 Likes