Alert when exceeding humidity level

Hello there,

I am planning to set an alert if my xiaomi-humidity sensor reaches a certain humidity level. I’ve gone through the following steps:

1st. Adding the sensor sensor.humidity_ABC where ABC is a device-specific ID. It shows the correct humidity and has been integrated in a group.

2nd. Creating a binary_sensor. As stated here.

binary_sensor:
  - platform: template
    sensors:
      zimmer_feucht:
        value_template: '{{ states.sensor.humidity_ABC > 40 }}'
        friendly_name: 'Luftfeuchte Zimmer'

I changed the “value_template” a little bit (might be wrong? I am a SQL-Newbie). According to the SQL-DB which reads (52.08 is the relevant value):

3rd. Adding an alert based on the binary_sensor:

alert:
  feuchtigkeit:
    name: Luftfeuchte Zimmer
    entity_id: binary_sensor.zimmer_feucht
    repeat: 60
    state: 'on'
    notifiers:
      - telegram

Which (in my opinion) should send me a Telegram notification (Telegram setup successfully tested with other notifications) as soon as the humidity level is higher than 40%

Long story short: It does not work. Has anyone some ideas how to troubleshoot? How to manually trigger the alert?

Thanks

No one has an idea?

Copy and paste your template {{ states.sensor.humidity_ABC }} in Developer Tools/templates for testing it.
There you will see that it not returns the value you expect.
You need {{ states.sensor.humidity_ABC.state }} to get the value and maybe | int if the sensor returns a string.

1 Like

You were right. with the “.state” added at the end I get the humidity-value in the template-section formatted as 48.33
Thanks for that. Nevertheless the alert is still not working and I have no idea why.

What does the binary_sensor.zimmer_feucht show under Developer Tools/states?

Only the state “off” and its friendly name.

Should be ‘on’ if value > 40.
Have you tried {{ states.sensor.humidity_ABC.state | int > 40 }} for the value_template?
If you test it in the templates tool it should show ‘True’ (=‘on’) or ‘False’ (=‘off’) if the value is under 40.

Thank you! The “int”-part was the missing piece.

Maybe the documentation has to be updated? The Complex Alert Criteria-section uses the value template without “int”.

If your sensor returns an int, you don’t need it. Most sensors (including your’s) return numbers as string.