sorry for my bad English.
I am using the following script to get notified when humidity at baby’s room is high.
- id: '1576277582476'
alias: High Humidity - Notification
description: ''
trigger:
- above: '60'
entity_id: sensor.humidity_baby_room_calibrated
platform: numeric_state
condition:
- after: '16:00'
before: 01:00
condition: time
action:
- data:
message: Το παιδικό δωμάτιο έχει υψηλή υγρασία! ( {{ states('sensor.humidity_baby_room_calibrated')
}} %)
title: ΠΡΟΕΙΔΟΠΟΙΗΣΗ ΥΓΡΑΣΙΑΣ
service: persistent_notification.create
- data:
message: Το παιδικό δωμάτιο έχει υψηλή υγρασία! ( {{ states('sensor.humidity_baby_room_calibrated')
}} %)
title: ΠΡΟΕΙΔΟΠΟΙΗΣΗ ΥΓΡΑΣΙΑΣ
service: notify.mobile_app_sm_g980f
- data:
message: Το παιδικό δωμάτιο έχει υψηλή υγρασία! ( {{ states('sensor.humidity_baby_room_calibrated')
}} %)
title: ΠΡΟΕΙΔΟΠΟΙΗΣΗ ΥΓΡΑΣΙΑΣ
service: notify.mobile_app_iphone_gerasimos
- data:
message: Προσοχή το παιδικό δωμάτιο έχει υψηλή υγρασία! ( {{ states('sensor.humidity_baby_room_calibrated')
}} %)
service: notify.sofita_tv
- data:
message: Προσοχή το παιδικό δωμάτιο έχει υψηλή υγρασία! ( {{ states('sensor.humidity_baby_room_calibrated')
}} %)
service: notify.bedroom_tv
- service: automation.turn_off
data: {}
entity_id: automation.high_humidity_notification
mode: single
I get notification on HA, I get notifications on our smartphones and I also get notified at our TV’s when they are switched on. We have two TV’s.
The problem I have, which is not really a problem, is that if one of the TV’s is switched off the automation is giving an error.
What I would like to achieve is the following:
if 1st TV (sofita TV) is on, then send notification. If is off, continue.
if 2nd TV is on (bedroom), then send notification, if is off continue to the next service call (automation turn off)
This will not give me an error at log files.
I don’t know how to do it as having one condition If the result of a condition is false (TV off), the action will stop there so any service calls after that condition will not be executed.
The first time the humidity rises from below to above 60 (during the specified time period) you will be notified. You will not be notified again if the humidity continues to rise beyond 60.
The only way you will be notified again is if the humidity first falls below 60 and then rises above 60 again (all within the time period). Is this something that can happen, where the humidity rises above 60, falls below 60, rises again above 60, etc all within one evening?
Thank you! You always answer my posts
That is very nice of you.
I know about sensor threshold and when the automation fires.
However we live at a Greek island and humidity is a big problem especially the winter period.
My automation is a bit more complex than this with a dehumidifier starting when threshold is passed.
So yes, it might goes up or down 60% a couple of times every day.
That is the reason I turn it off after it runs once.
However, my main problem is not sensor’s threshold but how i will have a simultaneous condition check of 2 entities ?
OK, in that case I suggest you create an input_boolean, such as input_boolean.humidity_alert. Change the automation you currently use to turn on automation.high_humidity_notification so that it turns off input_boolean.humidity_alert (instead of turning off the automation).
After you have done that, you can use the following version of high_humidity_notification.
The automation contains a second condition that checks if input_boolean.humidity_alert is off. If it is on then it means it already sent notifications and will not continue.
The automation’s action sets input_boolean.humidity_alert to on (which serves to prevent further notifications).
It proceeds to send three notifications (phones, etc).
If media_player.sofita_tv is notoff it sends a notification to it.
Finally, if media_player.bedroom_tv is notoff it sends a notification to it.
thank you very much! You rock!
It works very smoothly. One last question.
Is my implementation which turn offs the automation wrong?
Is the best practice to use input_boolean instead?
I would like to know your opinion about it as I have several automation built with the same logic.
It’s not wrong. However, in this case it makes it easier to implement what you requested if the last service call is not turning off the automation.
Personally, I prefer to use an input_boolean to serve as a ‘status flag’ and do not allow an automation to turn itself off. If an automation is off, that’s because I chose to manually turn it off, for some temporary reason (perhaps to test another version), and not because the automation turned itself off as part of its normal operation.