henaa
(hen)
March 18, 2020, 10:26am
1
Hi
I have next automation
The problem i get 5-6-7 notification in the raw
What I need to do to get 1 notification in 10 minutes ?
- id: '1584303212158'
alias: Someone Eating
trigger:
- event_data:
entity_id: binary_sensor.vibration_158d0002c4c833
movement_type: vibrate
event_type: xiaomi_aqara.movement
platform: event
action:
- data:
message: Someone eating !
service: notify.mobile_app1
- data:
message: Someone eating !
service: notify.mobile_app2
Skye
March 18, 2020, 10:54am
2
Have a look at the alert integration
You could also have a condition that checks whether the last time the automation fired was longer than X minutes ago. Iâm not sure about the template syntax for that though.
tom_l
March 18, 2020, 10:56am
3
Add a condition:
condition:
- condition: template # only notify once every 10 minutes at most
value_template: "{{ ( as_timestamp(now()) - as_timestamp(state_attr('automation.someone_eating', 'last_triggered')) |int(0) ) > 600 }}"
1 Like
henaa
(hen)
March 18, 2020, 5:18pm
4
Hi
Its not work⌠you maybe know why ?
- id: '1584303212158'
alias: Someone Eating
trigger:
- event_data:
entity_id: binary_sensor.vibration_158d0002c4c833
movement_type: vibrate
event_type: xiaomi_aqara.movement
platform: event
condition:
- condition: template
value_template: 'value_template: "{{ ( as_timestamp(now()) - as_timestamp(state_attr(''automation.someone_eating'',
''last_triggered'')) |int(0) ) > 600 }}"'
action:
- data:
message: Someone eating !
service: notify.mobile_app1
- data:
message: Someone eating !
service: notify.mobile_app2
Skye
March 18, 2020, 5:19pm
5
Edit: formatting
The value_template is wrong, should be
"{{ ( as_timestamp(now()) - as_timestamp(state_attr(''automation.someone_eating'', ''last_triggered'')) |int(0) ) > 600 }}"
jocnnor
(Jim O'Connor)
March 18, 2020, 5:59pm
7
So many quotes!
Also, it should all be on a single line. The forum is making it multiple lines due to word wrap and formatting. Make sure you have it all on a single line.
As for the quotesâŚthatâs just how the built-in editor does thingsâŚso that part is ok, even if it looks weird.
"{{ ( as_timestamp(now()) - as_timestamp(state_attr('automation.someone_eating', 'last_triggered')) |int(0) ) > 600 }}"
henaa
(hen)
April 23, 2020, 6:24am
8
Hi @jocnnor @Skye @tom_l
Your solution work great
But in after 1 month i have issue when i fill the pet food
I not want notify if the vibration alert 1 times
Only from 3 and up
I try to add
- id: '1584303212158'
alias: someone_eating
trigger:
- event_data:
entity_id: binary_sensor.vibration_158d0002c4c833
movement_type: vibrate
event_type: xiaomi_aqara.movement
platform: event
condition:
- condition: template
value_template: '{{ ( as_timestamp(now()) - as_timestamp(state_attr(''automation.someone_eating'',''last_triggered''))
|int(0) ) > 600 }}'
- condition: and
conditions:
- above: '3 '
condition: numeric_state
entity_id: binary_sensor.vibration_158d0002c4c833
action:
- data:
message: Someone is eating!
service: notify.mobile_app1
- data:
message: Someone is eating!
service: notify.mobile_app_mi2
But its not work for me
You know maybe why ?
jocnnor
(Jim O'Connor)
April 23, 2020, 1:10pm
9
A binary_sensor is only ever âonâ, or âoffâ. It canât ever be âabove 3â.
I guess, make an input_number and increment it, then only alert if the number is > 3.
# In configuration.yaml
input_number:
food_eat_counter:
min: 0
max: 10
# In automations
- alias: reset_food_counter
trigger:
platform: time
at: "00:00:00"
action:
service: input_number.set_value
data:
entity_id: input_number.food_eat_counter
value: 0
- id: '1584303212158'
alias: someone_eating
trigger:
- event_data:
entity_id: binary_sensor.vibration_158d0002c4c833
movement_type: vibrate
event_type: xiaomi_aqara.movement
platform: event
condition:
- condition: template
value_template: '{{ ( as_timestamp(now()) - as_timestamp(state_attr(''automation.someone_eating'',''last_triggered'')) |int(0) ) > 600 }}'
action:
# Increment the counter
- service: input_number.set_value
data_template:
entity_id: input_number.food_eat_counter
value: "{{ states('input_number.food_eat_counter') | int + 1}}"
# Only continue if the counter > 3
- condition: template
value_template: "{{ states('input_number.food_eat_counter') | int > 3 }}"
- data:
message: Someone is eating!
service: notify.mobile_app1
- data:
message: Someone is eating!
service: notify.mobile_app_mi2
henaa
(hen)
April 23, 2020, 5:39pm
10
Thanks
The food_eat_counter not work good
food_eat_counter going up by one only after 10 minute (600 sec)
For exapmple , if i trigger the vibration motion
18:08 - trigger the vibration 7 times - the counter up by one
18:13 - trigger the vibration -3 times - the counter not up
18:19 -trigger the vibration 5 times - the counter now is two
After all iiterattion the counter not back to zero
I want the final result be
"in 10 minutes if the vibration was on 3 times or more - send push message "
after 10 minute from the last vibration was on. the timer need to init back to 0
jocnnor
(Jim O'Connor)
April 23, 2020, 7:42pm
11
# In configuration.yaml
input_number:
food_eat_counter:
min: 0
max: 10
# Also in configuraiton.yaml
timer:
food_eat_timer:
duration: "00:10:00"
# In automations
# Reset this counter after the 10 minute timer expires.
- alias: reset_food_counter
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.food_eat_timer
action:
- service: input_number.set_value
data:
entity_id: input_number.food_eat_counter
value: 0
- id: '1584303212158'
alias: someone_eating
trigger:
- event_data:
entity_id: binary_sensor.vibration_158d0002c4c833
movement_type: vibrate
event_type: xiaomi_aqara.movement
platform: event
action:
# Start (or reset) the 10 minute timer
- service: timer.start
data:
entity_id: timer.food_eat_timer
duration: "00:10:00"
# Increment the counter
- service: input_number.set_value
data_template:
entity_id: input_number.food_eat_counter
value: "{{ states('input_number.food_eat_counter') | int + 1}}"
# Only continue if the counter > 3
- condition: template
value_template: "{{ states('input_number.food_eat_counter') | int > 3 }}"
- data:
message: Someone is eating!
service: notify.mobile_app1
- data:
message: Someone is eating!
service: notify.mobile_app_mi2
This will notify you every time after 3 until the 10 minutes is up. If you donât want that, change the
# Only continue if the counter > 3
- condition: template
value_template: "{{ states('input_number.food_eat_counter') | int > 3 }}"
To
# Only continue if the counter = 3
- condition: template
value_template: "{{ states('input_number.food_eat_counter') | int == 3 }}"
Now you will only be notified once until the timer finishes and resets the counter.
henaa
(hen)
April 24, 2020, 10:25am
12
When i do restart to HA
The value on âfood eat counterâ start from 10
I guess need initial the counter to 0 after restart HA
How i add it to configuration yaml ?
jocnnor
(Jim O'Connor)
April 24, 2020, 5:27pm
13
If you donât specify an initial, it will remember the last value it was.
You just need to add
initial: 0.0
after min or max in the input_number.