Automation error while entity is unavailable

Hello,
i have Smartmi Humidifier Evaporator 2 (CJXJSQ04ZM, zhimi.humidifier.ca4) which integrated into HA with syssi/xiaomi_airpurifier custom component.
Works great but… periodically becomes unavailable. This is not a problem if I didn’t want to use automation: send a message via the notification service if the water level in the humidifier is below a certain value. For this, the following automation was created:

  • alias: Notify when water level low
    trigger:
    platform: numeric_state
    entity_id: sensor.airhumidifier_level
    below: 45
    condition:
    condition: template
    value_template: “{{ states(‘sensor.airhumidifier_level’) | float > 0 }}”
    action:
    service: notify.me
    data:
    message: “Water level below than 45%”

It works fine, but if the water level is less than the set value and the humidifier changes its state to “unavailable”, then I receive repeated messages via the notification service and an error in the log:

Logger: homeassistant.helpers.condition
Source: helpers/condition.py:234
First occurred: 16 декабря 2020 г., 22:49:06 (102 occurrences)
Last logged: 11:26:11

  • Value cannot be processed as a number: <state sensor.airhumidifier_level=; unit_of_measurement=%, friendly_name=Air Humidifier Level, icon=mdi:water-percent @ 2020-12-18T10:47:11.687635+03:00> (Offending entity: )

How to avoid duplicate messages when the status of the humidifier changes?



Thank you!

Please try changing the condition template to
“{{ states.sensor.airhumidifier_level != “unavailable” }}”

it was in my first draft of automation:

can you try with double quotes “unavailable”?

Shouldn’t matter (double quotes)
Have you tried in dev-tools template tool?

while entity is availble templete shows:
{{ states(‘sensor.airhumidifier_level’) | float > 0 }} is boolean with result “true”

Is unavailable the correct state when it’s unavailable? (Check in history)
Also what does it show in template editor? Should also say true if it’s not unavailable.

history for this sensor is empty:


but history for the device shows that it changes it’s state to “unviable” (if i understand right it doesn’t matter that in frontend i see it on my local language as “недоступно” )

as i’m away from home a can’t make device unviable on purpose. can check it this evening only

Maybe check the database for the state… unviable is different to unavailable.

Sorry David, it’s just misspelling.
Just unplugged device and results are:




Your screenshots are showing 2 completely different entities?

Sensor is part of device Fan.
History for sensor shows “holes” in graph then Fan is unavailable.


There is no any state for sensor when fan is unavailable (as shown in screen shot from my previous message)