Hi guys,
I’ve been trying to get my automation trigger working for the past few hours but obviously doing something wrong!
Here’s my code from automation:
- id: vacuum_complete_ios_notification
alias: Vacuum Complete
trigger:
platform: numeric_state
entity_id: vacuum.xiaomi_vacuum_cleaner
value_template: '{{ state.attributes.cleaning_count }}'
above: 0
condition:
# - condition: template
# value_template: '{{ trigger.from_state.state != none }}'
# - condition: template
# value_template: '{{ states.sensor.vacuum_cleaning_count.state | int > 0 }}'
# value_template: '{{ states.vacuum.xiaomi_vacuum_cleaner.attributes.cleaning_count | int > 0 }}'
- condition: template
value_template: '{{ trigger.to_state.state|int > trigger.from_state.state|int }}'
action:
service: notify.ios_my_iphone
data:
title: "Home Assistant"
message: "Jeeves has finished cleaning."
data:
push:
thread-id: "home-assistant-vacuum"
I did have another sensor called sensor.vacuum_cleaning_count that just pulled the cleaning_count attribute but thought that doing it the right way was better (although harder )
I just need it to trigger when it goes from one number to a higher number.
Any chance someone could point out my silly mistake(s)?
Thanks in advance!
I just tried this but it’s still no good:
- id: vacuum_complete_ios_notification
alias: Vacuum Complete
trigger:
platform: template
value_template: '{{ states.vacuum.xiaomi_vacuum_cleaner.attributes.cleaning_count|int > trigger.from_state.state|int }}'
action:
service: notify.ios_my_iphone
data:
title: "Home Assistant"
message: "Jeeves has finished cleaning."
data:
push:
thread-id: "home-assistant-vacuum"
i feel like I’m closer though
edit: and this, but still no good
- id: vacuum_complete_ios_notification
alias: Vacuum Complete
trigger:
platform: template
value_template: '{{ states.vacuum.xiaomi_vacuum_cleaner.attributes.cleaning_count|int + 1 }}'
action:
service: notify.ios_my_iphone
data:
title: "Home Assistant"
message: "Jeeves has finished cleaning."
data:
push:
thread-id: "home-assistant-vacuum"
petro
(Petro)
February 7, 2019, 12:42pm
3
Is the count actually changing? Triggers only check state changes, if no state change occurs, nothing is checked.
Also this should work if the number changes.
- id: vacuum_complete_ios_notification
alias: Vacuum Complete
trigger:
platform: template
value_template: '{{ states.vacuum.xiaomi_vacuum_cleaner.attributes.cleaning_count > 0 }}'
action:
service: notify.ios_my_iphone
data:
title: "Home Assistant"
message: "Jeeves has finished cleaning."
data:
push:
thread-id: "home-assistant-vacuum"
Although it may always return true when any state changes. Might need to store the last count number and check against that.
Bob_NL
(Bob Visser)
October 5, 2019, 12:32pm
4
I have a similair automation. I created a seperate custom sensor for the cleaning_count
and trigger an automation on state change of this custom sensor (which is on the moment it docks after completing a cleanup) .
Custom sensor:
- platform: template
sensors:
roborock_count:
value_template: "{{ states.vacuum.roborock.attributes.cleaning_count }}"
Automation:
- alias: 'Roborock finished cleanup'
trigger:
- platform: state
entity_id: sensor.roborock_count
action:
- service: notify.telegram
data_template:
message: 'Roborock cleaning finished. Cleaned {{ states.vacuum.roborock.attributes.cleaned_area }}m² in {{ states.vacuum.roborock.attributes.cleaning_time }} minutes. Battery level: {{ states.vacuum.roborock.attributes.battery_level }}%. Recharging now.'