Value cannot be processed as a number

I have some strange error. Can someone help? This is the code that I use:

      water_sensor_battery_status:
        friendly_name: 'Water Sensor Battery Level'
        value_template: >-
          {% if states.zwave.aeotec_dsb45_water_sensor %}
            {{ states.zwave.aeotec_dsb45_water_sensor.attributes.battery_level }}
          {% else %}
            n/a
          {% endif %}
        unit_of_measurement: '%'

This is the error message:

Log Details (WARNING)

Thu Nov 29 2018 16:06:20 GMT-0600 (Central Standard Time)

Value cannot be processed as a number: <state sensor.water_sensor_battery_status=; friendly_name=Water Sensor Battery Level, unit_of_measurement=% @ 2018-11-29T16:06:20.192911-06:00> (Offending entity: )```

n/a is not a number. Change that to 0 or something else.

Thank you, but there is something else. I tried to make it more simple:

      water_sensor_battery_status:
        friendly_name: 'Water Sensor Battery Level'
        value_template: "{{ states.zwave.aeotec_dsb45_water_sensor.attributes.battery_level }}"
        unit_of_measurement: '%'

But still have the same error:

Log Details (WARNING)

Thu Nov 29 2018 16:22:30 GMT-0600 (Central Standard Time)

Value cannot be processed as a number: <state sensor.water_sensor_battery_status=; friendly_name=Water Sensor Battery Level, unit_of_measurement=% @ 2018-11-29T16:22:30.951923-06:00> (Offending entity: )

what does the attribute battery_level output? Check the states tab

Here it is:

Put this in the template editor and tell me what the output is

{{ states.zwave.aeotec_dsb45_water_sensor.attributes.battery_level * 2 }}

also, you restarted after changing the template right?

Yes, I restarted HA using Restart in the Server Management.

The output is 200.

I’m stumped, its gotta be something simple. Go take a look at the actual logs. home-assistant.log in the config directory. Search for the error associated with the template sensor

It gives me the same error in the home-assistant.log file:

2018-11-29 16:55:23 WARNING (MainThread) [homeassistant.helpers.condition] Value cannot be processed as a number: <state sensor.water_sensor_battery_status=; friendly_name=Water Sensor Battery Level, unit_of_measurement=%, icon=mdi:battery-alert @ 2018-11-29T16:55:23.580208-06:00> (Offending entity: )

try swapping it for this:

"{{ state_attr('zwave.hallway_ms','battery_level') }}"

This fixed it, thank you.

Hmm, that must have been a startup error then.