Here is the complete package I use for exactly same purpose.
Few notes:
- I use fibaro smart implant input connected to reed switch to detect mover presence in base, so you will find reference to it my package. So my actual sensor iz zwave based.
- I also use iPhone notifications (actually after 2:15, not after 2h as descriptions would suggest (in Polish
), it is controlled by timer that is easy to reconfigure.
- I have 2 cards in Lovelace configured; one is showing status of mover and one is conditional, that pops up on main dashbord if automover did not returned to base.
- input_boolean.automover_automation is used to control whole package for winter, if set to false it disables notifications and hides cards from dashboards.
Here is whole code package:
########################################################
########################################################
### Automover automation package
########################################################
########################################################
#
# Actual presence detection sensor for automover is:
# sensor.fibaro_system_fgbs222_smart_implant_burglar_5
#
########################################################
### Sensors
########################################################
sensor:
- platform: template
sensors:
automover_status:
friendly_name: "Automover Status"
value_template: >-
{% if is_state('input_boolean.automover_automation', 'off') %}
Automation Disabled
{% elif is_state('input_boolean.automover_status', 'off') %}
Charging
{% elif is_state('input_boolean.automover_status', 'on') and is_state('input_boolean.automover_out', 'on') %}
Did not return to the base!!!
{% else %}
Working
{% endif %}
icon_template: >-
{% if is_state('input_boolean.automover_status', 'off') %}
mdi:battery-charging-50
{% elif is_state('input_boolean.automover_status', 'on') and is_state('input_boolean.automover_out', 'on') %}
mdi:close-box-outline
{% else %}
mdi:robot-vacuum-variant
{% endif %}
########################################################
### Input Boolean
########################################################
input_boolean:
automover_out:
name: Automover did not returned to base!!!
icon: mdi:robot-vacuum-variant
initial: off
automover_status:
name: Automevier Status
automover_automation:
name: Enable Automover automation
icon: mdi:robot-vacuum-variant
#########################################################
# Timers
#########################################################
timer:
automover:
duration: '02:15:00'
########################################################
### Automations
########################################################
automation:
# Automover out of base
- id: 'automover_left_base'
alias: Automover Left Base Satation
initial_state: true
trigger:
platform: state
entity_id: sensor.fibaro_system_fgbs222_smart_implant_burglar_5
to: '2'
action:
- service: input_boolean.turn_on
entity_id: input_boolean.automover_status
- service: script.rotate_log
data:
new_log_entry: "Automover is working now"
- service: timer.start
entity_id: timer.automover
# Automover returned to base
- id: 'automover_returned_to_base'
alias: Automover Returned to Base
initial_state: true
trigger:
platform: state
entity_id: sensor.fibaro_system_fgbs222_smart_implant_burglar_5
to: '0'
action:
- service: input_boolean.turn_off
entity_id: input_boolean.automover_out
- service: input_boolean.turn_off
entity_id: input_boolean.automover_status
- service: script.rotate_log
data:
new_log_entry: "Automover is charging now"
- service: timer.cancel
entity_id: timer.automover
# Notify about automover being out of base for more than 2 hours
- id: 'automover_out_of_base'
alias: Automover out of base for more than 2 hours
initial_state: True
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.automover
action:
- service: notify.mobile_app_mireks_iphone
data:
title: "UWAGA !!!"
message: "Kosiarka poza bazą ponad 2 godziny!"
- service: input_boolean.turn_on
entity_id: input_boolean.automover_out
Here is status card:
card:
cards:
- text: AUTOMOVER
type: 'custom:text-divider-row'
- aspect_ratio: 5/1
entity: sensor.automover_status
icon: 'mdi:robot-mower-outline'
layout: icon_name_state
name: Automover Status
show_state: true
size: 100%
styles:
icon:
- color: |
[[[
if (entity.state == 'Charging') return 'var(--cyanish)';
if (entity.state == 'Working') return 'var(--greenish)';
else return 'var(--alert-text)';
]]]
type: 'custom:button-card'
- entities:
- sensor.automover_status
hours_to_show: 24
refresh_interval: 5
type: history-graph
- entities:
- entity: timer.automover
name: Automover timer
show_header_toggle: false
type: entities
type: 'custom:vertical-stack-in-card'
conditions:
- entity: input_boolean.automover_automation
state: 'on'
type: conditional
And here is the conditional popup card:
card:
entity: input_boolean.automover_automation
icon: 'mdi:robot-mower-outline'
name: Automover did not return to the base ! ! !
size: 20%
styles:
icon:
- animation: blink 2s ease infinite
- color: 'rgb(255, 0, 0)'
tap_action:
action: none
type: 'custom:button-card'
conditions:
- entity: sensor.automover_status
state: Did not return to the base!!!
- entity: input_boolean.automover_automation
state: 'on'
type: conditional