Show z-wave node information (eg. battery level) on lovelace

Hi. I see that battery level is reported by the device and I would like to display it on lovelace. I tried the script bellow but it returns unknown. Any ideas?

  - platform: template
    sensors: 
      danfoss_bedroom_heater_battery_level:
        value_template: '{{ zwave.danfoss_bedroom_thermostat.state.attributes.battery_level|int }}'  
        friendly_name: 'Bedroom Thermostat Battery Level' 
        unit_of_measurement: '%'

Try this, works for me:

value_template: '{{ states.zwave.danfoss_bedroom_thermostat.attributes.battery_level }}'

or this:

value_template: '{{ state_attr("zwave.danfoss_bedroom_thermostat", "battery_level") }}'

1 Like

Awesome. The 2nd one worked!
I had already tried the first one. That one doesn’t.

Strange, works for me, at least you have it working.

FYI, Home Assistant 0.100 will include z-wave battery sensors by default. The template sensors will not be needed any longer.

https://github.com/home-assistant/home-assistant/pull/26943

2 Likes

There is also a HACS plugin, “Attributes” that “Breaks out specified attribute from other entities to a sensor”. Super easy to do. I used to have a template working but then I changed something and it stopped working. I got lazy and moved over to the plugin.

I’m kind of surprised that one worked either. Usually the quotes outside the template need to be the opposite type of the ones inside the template brackets or the template parser throws an error.

Yes, I did fix the quotes.