Hi,
I have a simple automation that notifies me when smart plug is switched on. That works great. Now I want it to send me repeated notification every 60s as long as that plug is on. I have tried changing the automation mode to restart but that made no difference - I just get one notification when the plug is switched on but nothing after that ( I will be hooking up 120dB siren to that plug to act as a basic burglar alarm for my shed )
My automation:
alias: PLUG - notification
description: ''
trigger:
- platform: state
entity_id: switch.plug10
to: 'on'
action:
- service: notify.mobile_app_my_iphone
data:
title: notification
message: Plug is on
mode: single
I’m not sure how to approach this. Any suggestions?
Thanks
Well, one way would be to create an automation on a time based trigger for the notification, and have that automation be enabled/disabled when the swtich is toggled. That would be a bit more efficient for HA than having a condition in it saying the switch must be on.
Trying to implement this but I am not getting notification… this is in my configuration.yaml file and both notifiers are tested working. Not getting any alerts. for now I am using a state of ‘off’ so I do not have to hold the button to on. So I trigger it to on get a notice from other automation but I would expect if this is working that 1 minute later I would get a notification from this alert. Thanks for the help. TIA
Secondly, it will not trigger after one minute, but directly, when the condition is true and then every new minute again. If you want to avoid the first, use skip_first. See docs.
And then, what is the history of input_boolean.water_sensor_main_drain_water_leak? The alert will only switch on, if it changes from something else to off in your example. You should test this behavior manually with your input_boolean. And double-check, the status of the (generated) alert-entity alert.water_found.
BTW is there a alert.water_found entity and did you restart HA?
very sorry did not realize what you where telling me… believe I have it right this time
input_boolean does not appear to come up on the list when I start entering it. Should it?
Yes so the way I have written the code is test the water sensor when it goes from the on to off state so that I am not listening to the beep beep beep while I wait for a minute (or more to go buy) testing to make sure it works … So I trigger a wet condition and other interfaces confirm that it has been triggered and then then I stop the device from thinking it is wet so it returns to off state which is when I would expect this to trigger this action and likely keep sending me out alerts for a long time (kinda of a dumb move but it would prove the point with out listening to beep beep beep beep… ) Once working I would move the state to ‘on’ in the action
Hope that all made sense.
This code works for the control panel. Showing the binary_sensor… item works with on and off
Sorry, was a typo. I was talking about your binary_sensor.water_sensor_main_drain_water_leak
But coming back to my questions above. Is there the alert-entity available? And what is the value and history of that? And was ist the current value and the history of `binary_sensor.water_sensor_main_drain_water_leak?
I don’t understand what you mean by this: Is there the alert-entity available? If I go to developer tools.>States->Entity and try and enter alert. nothing comes up if this is what you mean. Can’t get to history without understanding how to get to it.
For the water sensor - main drain this is the status of it (see attached) at 1:45 I put the entity_id: binary_sensor.water_sensor_main_drain_water_leak inline as suggested and reloaded the system. triggered water for which I get notification from other entities right away that water is detected but waiting for the notices to come in when the state went to off but no luck yet.
If the setup for the alert is working, there is a alert entity afterwards. In your case alert.water_found
If it is not there, it cannot work. Is the nothing in the log if you restart HA?
Did you try my suggestion above and restart HA? Really don’t get, why you are not trying suggestions. It is now the third time I’m mentioning the change in the entity_id row.
Thanks for your persistence (most people just walk away) Yup that was exactly it the alert was not loading into the system… and well that was the novice to HA in me… I had entered it into the configuratoin.yaml under the zigbee2mqtt drop down and not the one in the root directory.
But yes I was doing everything I could and understood that you documented sorry if I was not clear in my responses but ya I was doing everything.
Thanks for your help and persistence got it figured out now. As a relative newbie to HA really appreciate the help.
Found another error while checking the logs for you that will keep me busy for a little. It appears to work but I get errors (just love those ones).
Complains about this one:
TemplateError(‘ValueError: Template error: int got invalid input ‘unknown’ when rendering template ‘{{ states (‘sensor.water_mb_window_sill_battery’) | int / 2 }}’ but no default was specified’) while processing template ‘Template("{{ states (‘sensor.water_mb_window_sill_battery’) | int / 2 }}")’ for attribute ‘_attr_native_value’ in entity ‘sensor.battery_status_mb_sill’
5:06:03 PM – (ERROR) helpers/template_entity.py - message first occurred at 5:06:03 PM and shows up 4 times
Error while processing template: Template("{{ states (‘sensor.water_mb_window_sill_battery’) | int / 2 }}")
5:06:03 PM – (ERROR) helpers/template.py - message first occurred at 5:06:03 PM and shows up 4 times
But exact same line different sensor (same model… no complaints ).
{{ states (‘sensor.water_sensor_main_drain_battery’) | int / 2 }}
Regrading the errors. You should use default for filters ( here |int) wherever you can. Esp. as they are thowing errors, if there is no value and you don’t use them (new for some releases, before it returned 0 or input value or …).
So have a look here
and use e.g.
states (‘sensor.water_mb_window_sill_battery’) | int(default=0)
This makes sense, I will review and work on it later… kinda indicates why I was not figuring it out that it did not have a valve… but weirdly the result works… Where it is being used is the Third Reality water sensors are now reporting to zigbee twice the power they have so 90 is reported as 180 and they did this because the values where getting a mess when they where going through certain devices… but left us out on a lurch that we can pickup the real value so I had to right an entity that held the value at half and so this happens on only some of there devices, depends on the firware level and they do not expose the firmware level to us to do the math with just have to do it manually for each of the devices… apparently they are going to have a chat with zigbee2mqtt to see what can be done to make it work right for them. Till then NewValue= OrgValue/2 but weird it comes back with no value but it still work and gauges are all reading correctly now.
Is there any chance you can help me figure out how to repeat a low reading until it goes back to its normal level?
I have no clue how to add a repeat to this Automation that reads it out once but I would like it to keep doing this every 5 mins until the reading is above!
alias: "Read out Low reading "
description: With Echo Show 10
trigger:
- platform: numeric_state
entity_id:
- sensor.blood_sugar
id: Low-readings
below: 72
- platform: numeric_state
entity_id:
- sensor.blood_sugar
id: normal-readings
above: 75
- platform: numeric_state
entity_id:
- sensor.blood_sugar_2
below: 4
id: Low-readings_mmols
enabled: false
condition: []
action:
- action: notify.alexa_media_dave_s_echo_show_living_room
data:
message: Dave, your blood sugar is running low.
enabled: true
- choose:
- conditions:
- condition: trigger
id:
- Low-readings
sequence:
- action: notify.alexa_media_dave_s_echo_show_living_room
metadata: {}
data:
message: Dave, your blood sugar is running low.
- action: notify.alexa_media_dave_s_echo_dot_bedroom
metadata: {}
data:
message: Dave, your blood sugar is running low.
- action: notify.mobile_app_sm_s928b
metadata: {}
data:
message: Dave, your blood sugar is running low.
- action: notify.alexa_media_dave_s_echo_show_kitchen
metadata: {}
data:
message: Dave, your blood sugar is running low.
- action: notify.alexa_media_dave_s_echo_dot_bathroom
metadata: {}
data:
message: Dave, your blood sugar is running low.
- action: notify.mobile_app_ticwatch_pro_3_ultra_gps
metadata: {}
data:
message: Dave, your blood sugar is running low.
- action: notify.alexa_media_david_s_3rd_echo_dot
metadata: {}
data:
message: Dave, your blood sugar is running low.
- conditions:
- condition: trigger
id:
- normal-readings
sequence:
- action: notify.alexa_media_dave_s_echo_show_living_room
metadata: {}
data:
message: Dave, your blood sugar is ok now, and normal levels
- action: notify.alexa_media_dave_s_echo_dot_bedroom
metadata: {}
data:
message: Dave, your blood sugar is ok now, and normal levels
- action: notify.mobile_app_sm_s928b
metadata: {}
data:
message: Dave, your blood sugar is ok now, and normal levels
- action: notify.alexa_media_dave_s_echo_show_kitchen
metadata: {}
data:
message: Dave, your blood sugar is ok now, and normal levels
- action: notify.alexa_media_dave_s_echo_dot_bathroom
metadata: {}
data:
message: Dave, your blood sugar is ok now, and normal levels
- action: notify.mobile_app_ticwatch_pro_3_ultra_gps
metadata: {}
data:
message: Dave, your blood sugar is ok now, and normal levels
- action: notify.alexa_media_david_s_3rd_echo_dot
metadata: {}
data:
message: Dave, your blood sugar is ok now, and normal levels
mode: single
Well, you do not need to repeat anything if you continue on the path above to create an alert sensor. It does that for you. You can specify how often warning shoud occur while the problem persists. But you seem to have given up on that because of an error in a template, and instead want to go for a more difficult approach?
Step one: create a binary sensor that is on if there is a problem, and turns off when the problem is gone. I suggest you use a threshold sensor for that, with a lower bound of 73.5 and a hysteresis of 1.5. You can create it in the gui using a helper.
Then set up the alert entity like was suggested before, using the threshold sensor as the enitity: