Custom sensor and number percentage

I have create a custom sensor from a ZWave attribute.

sensor:
  - platform: template
    sensors:
      front_door_battery:
        value_template: >-
          {%- if states.zwave.schlage_be469_touchscreen_deadbolt_2 -%}
            {{ states.zwave.schlage_be469_touchscreen_deadbolt_2.attributes.battery_level }}
          {%- else -%}
            101
          {%- endif -%}
        unit_of_measurement: '%'
        entity_id: zwave.schlage_be469_touchscreen_deadbolt_2

I create a automation to know when the battery is low.

- id: '1543724536619'
  alias: Front Door Low Battery SMS
  trigger:
  - below: '20'
    entity_id: sensor.front_door_battery
    platform: numeric_state
  condition: []
  action:
  - data:
      message: Front Door battery below 20%
      target:
      - '<private number>'
    service: notify.twilio_sms

The metric shows up and I get the value displaying in the interface, but I get the following error on startup of Home Assistant

2019-04-04 07:19:55 WARNING (MainThread) [homeassistant.helpers.condition] Value cannot be processed as a number: <state sensor.front_door_battery=; unit_of_measurement=%, friendly_name=front_door_battery @ 2019-04-04T07:19:55.888586-07:00> (Offending entity: )

Anything I am doing wrong?

The state of the template sensor sensor.front_door_battery depends on receiving a value from zwave.schlage_be469_touchscreen_deadbolt_2. When you restart Home Assistant, it may take some time before it sets up the zwave component and receives data from the schlage deadbolt. During this setup time, it has no value available to supply to the template sensor.

I believe that may be the cause of the error message Value cannot be processed as a number.

1 Like