Z-Wave device battery level

Is there any way to display the battery level for a Z-Wave device? It’s picked up in the logs:

Apr 11 00:28:18 localhost hass[4255]: INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=sensor.ecolink_doorwindow_sensor_alarm_level_4, old_state=<state sensor.ecolink_doorwindow_sensor_alarm_level_4=0; friendly_name=Ecolink Door/Window Sensor Alarm Level, hidden=True, node_id=4 @ 20:50:29 10-04-2016>, new_state=<state sensor.ecolink_doorwindow_sensor_alarm_level_4=0; friendly_name=Ecolink Door/Window Sensor Alarm Level, battery_level=100, hidden=True, node_id=4 @ 20:50:29 10-04-2016>>
1 Like

It is usually displayed as sort of an attribute on the bottom of the entity-card itself. Don’t think it’s possible to display it as its own entity.

yeah, I had seen that… was hoping for a way to just show the battery level and even better, ability to trigger a notification for low battery.

Haven’t tested it myself, but this might be some sort of clue of how to target an attribute: https://home-assistant.io/components/automation/#template-condition

Edit: or this https://home-assistant.io/cookbook/track_battery_level/

@eelan03 - I have also been trying to figure out how to trigger a notification for a low battery on my smoke detector but with no luck so far. Been trying to follow many of the examples but without success. If you happen to discover how to trigger a notification please share. Thanks

Try…

sensor:
- platform: template
  sensors:
    batt_frontdoor:
      friendly_name: 'Front Door Battery'
      value_template: '{{ states.sensor.linear_unknown_type2001_id0102_sourcenodeid_7.attributes.battery_level }}'
      unit_of_measurement: '%'

to trigger a notification…

automation:
- alias: 'Battery Low Alert - Front Door'
  trigger:
    platform: numeric_state
    entity_id: sensor.batt_frontdoor
    below: 5
  action:
    service: notify.notify
    data:
      message: "Time to change the front door's battery"
      title: ""
5 Likes

@masterkenobi

I added a sensor that is similar to what you show above and then added that sensor to a group thinking I could get the sensor to show the battery level in that group however the sensor is not showing. Should the example you provided show up on the UI with a battery level?

my setup:

sensor2:
  platform: template
  sensors:
    batt_garagedoor1:
      friendly_name: 'Garage Door 1 Battery'
      value_template: '{{ states.sensor.vision_zg8101_garage_door_detector_burglar_10.attributes.battery_level }}'
      unit_of_measurement: '%' 

added sensor.batt_garagedoor1 to a group

Just noticed I am getting an error saying “Unable to find component sensor2”

Solved! Turns out I needed a space between “sensor” and “2”

Not so sure it’s solved now, seems I am getting a number of these warnings:

WARNING:homeassistant.components.sensor.template:UndefinedError: ‘None’ has no attribute ‘attributes’

Anyone familiar with what this might mean? I know it’s related to this sensor I created because once I remove it these warnings go away.

I believe this happens because the values are None when HA is started

Should there be a fix for it or is it okay to receive them?

any news for this problem? i have the same error

Ultimately I don’t know if there should be a fix but I have found that I receive these at startup and they do not cause any problems. My understanding is that this displays because the template (or maybe zwave?) hasn’t yet initialized. Once it has these errors stop and the template displays correctly in the UI.

They are initialization errors at startup and can be safely ignored unless they persist. They are caused by the fact that template sensors are initialized pretty quickly but if they rely on ZWave values, those may not be available for a minute or more as your ZWave network slowly initializes itself. In the meantime you may get hundreds of these errors. Annoying but not harmful.

For what it’s worth, it seems you can get rid of the warning WARNING:homeassistant.components.sensor.template:UndefinedError: 'None' has no attribute 'attributes'. The templating doc here contains the following example:

{% if states.device_tracker.paulus %}
  {{ states.device_tracker.paulus.attributes.battery }}
{% else %}
  ??
{% endif %}

I tried it myself by changing my value_template from

{{ states.binary_sensor.living_area_door_sensor_2.attributes.battery_level }}

to

{% if states.binary_sensor.living_area_door_sensor_2 %}
  {{ states.binary_sensor.living_area_door_sensor_2.attributes.battery_level }}
{% else %}
  n/a
{% endif %}

and so far, I’m not seeing the warnings anymore after restarting HASS.

6 Likes

Great find! Thanks for sharing! Now my log file is much cleaner

Definitely going to give that a try - thanks!

Noice! I thought I’d just have to live with these, which is a problem since I have so many templated sensors.

Thanks!

@fanaticDavid, Can I use in my configuration file while defining the sensor itself like below?

sensor:
  - platform: template
    sensors:
      thermostat_downstairs_current_status:
        value_template: '{{ states.climate.downstairs.attributes.operation }}'
      thermostat_downstairs_current_status_fan:
        value_template: '{{ states.climate.downstairs.attributes.fan }}'
      thermostat_downstairs_away_mode:
        value_template: '{{ states.climate.downstairs.attributes.away_mode }}'

Thanks

I’m sorry but I’m not quite understanding your question. I’m also not familiar with the climate component.