I’m trying to monitor the battery level in my zwave devices and when they fall below a certain value (e.g. 50%) to alert me so that I can swap them out.
However overnight the batteries in one of my sensors went to zero (from 88% yesterday) and I didn’t get any warnings.
In my home assistant log file I get this warning:
2019-07-09 08:31:14 WARNING (MainThread) [homeassistant.helpers.condition] Value cannot be processed as a number: <state sensor.battery_backdoor=; unit_of_measurement=%, friendly_name=Backdoor Battery @ 2019-07-09T08:31:14.085968+01:00> (Offending entity: )
Which is similar to the warnings posted by others previously but I can’t figure out how to fix this.
Is this attribute actually a string and needs converting to an integer in my sensor template below?
Should the trigger condition be 50 (without quotes) or ‘50’? The automation editor via the UI puts in the quotes even when selecting a ‘numeric_state’ trigger type - is this a bug?
Thanks, I’ve done that and restarted the service, now I get:
2019-07-09 10:07:10 WARNING (MainThread) [homeassistant.components.template.sensor] Could not render template Backdoor Battery, the state is unknown
Interestingly I have more than one sensor (I’ve truncated the code to help isolate the problem), but I don’t get this new warning for the other sensors.
I’m going to remove this sensor and re-pair it see if that helps
I’ve now removed and re-added the sensor in question, but I now get the same error for both of my sensors:
2019-07-09 10:20:38 WARNING (MainThread) [homeassistant.components.template.sensor] Could not render template Backdoor Battery, the state is unknown.
2019-07-09 10:20:38 WARNING (MainThread) [homeassistant.components.template.sensor] Could not render template Playroom Door Battery, the state is unknown.
Some other threads suggest that this could be a timing issue (the sensors aren’t ready during the startup process) so I’ve moved the zwave section of my config above the sensor section (which would make more sense!) but I still get the warning.
That all being said, I have a glance card that shows the battery levels in the UI and that’s working so maybe it is just a timing issue.
So I’ll raise the level to 99% and monitor it over the next couple of days, once I’m convinced it’s working I’ll set the level back to 50%
I think that’s a timing issue, I have a number of them for elements which have to go off and get data before they become usable. I’d do as you’ve done and give it a couple of days with the higher threshold and see if they trigger (using the numeric comparison rather than the string comparison).
{{ state_attr('zwave.kaipule_technology_co_ltd_im20_door_window_sensor_2', 'battery_level') | int }}
I think the problem is that when the template tries to render the device isn’t initialized yet so the battery state is unknown. formatting the template like above should eliminate that error.