Error while processing template: Template

HI All,

I get this error for some one my sensors when I restart HA, Zwave device is not ready at moment when HA was restarted.
Can someone tell me how to solve this?

2020-12-24 10:20:52 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{ (states.sensor.zwave2mqtt_nodeid_77_electricity_kwh_meter.attributes.value) | float('Unavailable')  }}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 353, in async_render
    render_result = compiled.render(kwargs)
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.8/site-packages/jinja2/filters.py", line 794, in do_float
    return float(value)
jinja2.exceptions.UndefinedError: 'mappingproxy object' has no attribute 'value'

binary_sensor:

    washing_machine:
      friendly_name: "Washing machine"
      value_template: "{{ states('sensor.zwave2mqtt_nodeid_77_electricity_w_meter') | float(0) > 5 }}"
      attribute_templates:
        kwh: "{{ (states.sensor.zwave2mqtt_nodeid_77_electricity_kwh_meter.attributes.value) | float('Unavailable')  }}"

sensor:

    washing_machine:
      friendly_name: "Washing Machine kWh"
      value_template: "{{ (states.sensor.zwave2mqtt_nodeid_77_electricity_kwh_meter.attributes.value) | float('Unavailable') }}"

Try this for the template:

{{ state_attr('sensor.zwave2mqtt_nodeid_77_electricity_kwh_meter', 'value') | float('Unavailable') }}
1 Like

{{ state_attr(‘sensor.zwave2mqtt_nodeid_77_electricity_kwh_meter’, ‘value’) | float(‘Unavailable’) }}

Seems to work !! Thank you
Can I also do float(‘2000’) so when sensor is not ready the value will always show 2000?

Is that the correct way how I read this line?

EDIT: Have my answer already. Tried it. Worked… Now updated other sensors and all errors are gone while reboot HA