Hoping that somebody can point me in the right direction with this simple automation I am trying to set-up using an MQTT sensor which is measuring humidity.
This is the MQTT message: Topic: humidor/sensor1, message: {“temperature”:“21.10”,“humidity”:“58.20”}
(I have tried various options for value_template and also without value_template, doesn’t seem to make a difference)
Don’t get any error messages either.
Can somebody help and explain where I am going wrong? Thanks.
Hi Keith, thanks for your help. I tried your suggestions, but unfortunately it doesn’t work. I created a new automation.yaml file with only this automation in it, just to make sure nothing else was interfering.
When I call up the automation card for this automation and I click on trigger, the notification pops up, so that bit works. Therefore the problem is in the trigger section. Is the numeric_state platform correct for an MQTT sensor? Ronald
Please can you post your current code using the code blocks so we can see the formatting. And yes I use numeric state all the time tho’ only for temperature.
- action:
- data:
message: "Humidor vochtigheid onder 65% of boven 74%!"
service: persistent_notification.create
alias: Humidor
id: '1499539668475'
trigger:
- entity_id: sensor.humidor_humidity
platform: numeric_state
below: 65
and this
alias: Humidor
trigger:
platform: numeric_state
entity_id: sensor.humidor_humidity
below: 65
action:
service: persistent_notification.create
data:
message: "Humidor vochtigheid onder 65% of boven 74%!"
The first block of code is built with the new HomeAssistant Automation function. the second I created in a separate ‘automations.yaml’ file.
Thanks for your help.
The first block I can’t really help with it looks like OK, but it also looks completely wrong to me
The second block needs some hyphens and the spacing is not quite correct, btw I’m not sure if you can have both types of automation in the config yaml file, I would pick one and stick to it.My preference would be for the second type
- alias: Humidor
trigger:
- platform: numeric_state
entity_id: sensor.humidor_humidity
below: 65
action:
- service: persistent_notification.create
data:
message: "Humidor vochtigheid onder 65% of boven 74%!"
Thanks again. That was sloppy of me, missing those hyphens. Unfortunately this corrected version still didn’t work. When I manually trigger the message appears, so still an issue with the trigger condition.
Therefore I tried something different and used the template platform, after some testing I got this to work:
- alias: Humidor
trigger:
- platform: template
value_template: '{{states.sensor.humidor_humidity.state | float < 65.00 }}'
action:
- service: persistent_notification.create
data:
message: "Humidor vochtigheid onder 65% of boven 74%!"
which in the new HomeAssistant automation looks like:
- action:
- data:
message: "Humidor vochtigheid onder 65% of boven 74%!"
service: persistent_notification.create
alias: Humidor
id: '1499539668475'
trigger:
- platform: template
value_template: '{{states.sensor.humidor_humidity.state | float < 65.00 }}'
Now I need to figure out how to make a “<65 OR >74” value template.
Thanks, Ronald
you should be able to do …
value_template: ‘{{states.sensor.humidor_humidity.state | float < 65.00 or states.sensor.humidor_humidity.state | float > 74.00}}’
So it should return false if inbetween 65 and 74 else true