Using z-wave battery level for automations

I just started using z-wave with home assistant & a aeon labs z-wave stick. I was able to add and control several devices, some of which operate on battery. The battery level is reported by the devices:

So I though I could easily create a automation to send me a message when the battery was running out:

- alias: monitor battery bewegings sensor grote zolderkamer
  trigger:
    platform: numeric_state
    entity_id: zwave.beweginsensorgrotezolderkamer.battery_level
    below: 10
  action:
    service: notify.pushbullet
    data:
      message: "Batterij niveau bewegings sensor grote zolderkamer onder 10%"

Unfortunately, there seems to be something wrong with the entity id, I get this error in the log:

2018-01-14 16:39:36 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: Entity ID zwave.beweginsensorgrotezolderkamer.battery_level is an invalid entity id for dictionary value @ data['trigger'][0]['entity_id']. Got None. (See /home/pi/.homeassistant/configuration.yaml, line 449). Please check the docs at https://home-assistant.io/components/automation/

Any idea what would be the right way to get the battery level?

That’s an attribute, so you’d need to use a value_template in your numeric state trigger:

- alias: monitor battery bewegings sensor grote zolderkamer
  trigger:
    platform: numeric_state
    entity_id: zwave.beweginsensorgrotezolderkamer
    value_template: '{{ states.zwave.beweginsensorgrotezolderkamer.attributes.battery_level }}'
    below: 10
  action:
    service: notify.pushbullet
    data:
      message: "Batterij niveau bewegings sensor grote zolderkamer onder 10%"

Thanks for the suggestion. At first I thought it worked, I only had a error in the log about some other (unrelated) line of my automations.yaml, but now that I’ve added 5 of these automations, I get 5 errors, so it seems like there’s a problem with this automation after all.

The error reads:

2018-01-26 14:27:06 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: required key not provided @ data[‘trigger’][0][‘entity_id’]. Got None. (See /home/pi/.homeassistant/configuration.yaml, line 486). Please check the docs at Automation - Home Assistant

We need you to share the automation that overlaps line 486.

The Strange thing is that the error references the file configuration.yaml, not automations.yaml where I added that automation.

On line 486 of configuration.yaml I only have:

group: !include groups.yaml

followed by:

automation: !include automations.yaml

To be sure the error was about this automation, I removed all other automatons from automations.yaml, just leaving this one. With that the error message still showed up. As soon as I removed the automation, I had no more errors.

Figured it out, It had to be:

- alias: monitor battery bewegings sensor grote zolderkamer
  trigger:
    platform: numeric_state
    entity_id: zwave.beweginsensorgrotezolderkamer
    value_template: '{{ state.attributes.battery_level }}'
    below: 10
  action:
    service: notify.pushbullet
    data:
      message: "Batterij niveau bewegings sensor grote zolderkamer onder 10%"

Adding the entity_id and removing the entity from the value template did the trick.