Skip to content

Commit

Permalink
Merge pull request #131 from jnewland/bring-back-roomba
Browse files Browse the repository at this point in the history
Bring back the roomba
  • Loading branch information
jnewland committed Jan 3, 2020
2 parents 6cb2fba + 318c729 commit cca2a30
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 145 deletions.
9 changes: 4 additions & 5 deletions automation/ack_turn_on.yaml
Expand Up @@ -10,13 +10,12 @@ action:
entity_id: '{{ trigger.event.data.action_data.entity_id }}'
- service_template: '{{ trigger.event.data.action_data.notify_service }}'
data_template:
data:
push:
apns_headers:
'apns-collapse-id': >
{{ trigger.event.data.action_data.entity_id }}
message: >
{{ trigger.event.data.sourceDeviceName }} {{ trigger.event.data.action_data.confirmation_message }}.
data:
apns_headers:
'apns-collapse-id': >
{{ trigger.event.data.action_data.apns_collapse_id | default(trigger.event.data.action_data.entity_id) }}
- service: notify.slack
data_template:
message: ':+1: to {{ trigger.event.data.action_data.entity_id }} from {{ trigger.event.data.sourceDeviceName }}'
Expand Down
28 changes: 0 additions & 28 deletions automation/mode_away_to_day.yaml

This file was deleted.

36 changes: 0 additions & 36 deletions automation/mode_day.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions automation/mode_morning.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion configuration.yaml
Expand Up @@ -59,4 +59,4 @@ weather:
- platform: darksky
api_key: !env_var FORECAST_API_KEY
zone: !include zone.yaml
# vacuum: !include_dir_list vacuums
vacuum: !include_dir_list vacuums
2 changes: 1 addition & 1 deletion packages/deploy.yaml
Expand Up @@ -19,4 +19,4 @@ script:
- service: homeassistant.restart

shell_command:
deploy: /bin/bash ./script/deploy {{ sha }}
deploy: /bin/bash ./script/deploy {{ sha }}
65 changes: 65 additions & 0 deletions packages/mode_day.yaml
@@ -0,0 +1,65 @@
automation:
- alias: Day mode
trigger:
- platform: state
entity_id: input_select.mode
to: Morning
- platform: state
entity_id: binary_sensor.master_bath_motion
from: 'off'
to: 'on'
- platform: state
entity_id:
- sensor.jphone_11_pro_battery_state
- sensor.katie_s_iphone_battery_state
to: 'Not Charging'
for:
seconds: 30
condition:
condition: and
conditions:
- condition: state
entity_id: input_select.mode
state: Morning
- condition: template
value_template: |
{{
(states.device_tracker.jphone_11_pro.state == "not_home" or states.sensor.jphone_11_pro_battery_state.state == "Not Charging") and
(states.device_tracker.katie_s_iphone.state == "not_home" or states.sensor.katie_s_iphone_battery_state.state == "Not Charging")
}}
action:
- service: input_select.select_option
entity_id: input_select.mode
data:
option: Day

- alias: Mode away to day
trigger:
- platform: state
entity_id: lock.front_door
to: 'unlocked'
- platform: state
entity_id: binary_sensor.garage
from: 'off'
to: 'on'
- platform: state
entity_id: binary_sensor.gate
from: 'off'
to: 'on'
- platform: zone
entity_id: device_tracker.jphone_11_pro
zone: zone.home
event: enter
- platform: zone
entity_id: device_tracker.katie_s_iphone
zone: zone.home
event: enter
condition:
condition: state
entity_id: input_select.mode
state: Away
action:
- service: input_select.select_option
entity_id: input_select.mode
data:
option: Day
51 changes: 51 additions & 0 deletions packages/mode_morning.yaml
@@ -0,0 +1,51 @@
automation:
- alias: Morning mode
trigger:
- platform: state
entity_id: binary_sensor.closet_motion
from: 'off'
to: 'on'
- platform: state
entity_id: binary_sensor.master_bath_motion
from: 'off'
to: 'on'
- platform: state
entity_id:
- sensor.jphone_11_pro_battery_state
- sensor.katie_s_iphone_battery_state
to: 'Not Charging'
for:
seconds: 30
condition:
condition: and
conditions:
- condition: state
entity_id: input_select.mode
state: Sleeping
- condition: time
after: '05:00:00'
before: '12:00:00'
action:
- service: input_select.select_option
data:
entity_id: input_select.mode
option: Morning

- alias: Run default morning actions
trigger:
- platform: state
entity_id: input_select.mode
to: Morning
action:
- service: light.turn_off
entity_id: group.master
- service: input_number.set_value
data:
entity_id: input_number.brightness
value: 255
- service: light.turn_on
entity_id:
- group.speakers
- light.cabinets
- service: alarm_control_panel.alarm_disarm
entity_id: alarm_control_panel.alarm
55 changes: 55 additions & 0 deletions packages/roomba.yaml
@@ -0,0 +1,55 @@
script:
find_roomba:
sequence:
- service: vacuum.locate
entity_id: vacuum.downstairs_roomba
noop:
sequence:
- service: homeassistant.update_entity
entity_id: binary_sensor.updater
automation:
- alias: Find the roomba in the morning
trigger:
- platform: state
entity_id: input_select.mode
to: Morning
condition:
condition: template
value_template: |
{{ not is_state_attr("vacuum.downstairs_roomba", "status", "Charging") }}
action:
- service: script.ask_about_turning_on
data_template:
entity_id: script.find_roomba
message: >
The downstairs roomba is lost. Should I make it beep?
confirmation_message: found the roomba

- alias: Empty the roomba in the morning
trigger:
- platform: state
entity_id: input_select.mode
to: Morning
condition:
condition: template
value_template: |
{{ is_state_attr("vacuum.downstairs_roomba", "bin_full", True) }}
action:
- service: script.ask_about_turning_on
data_template:
entity_id: script.noop
apns_collapse_id: roomba-full
message: The downstairs roomba is full. Did you empty it out?
confirmation_message: emptied the roomba

- alias: Run roomba in reading mode
trigger:
- platform: state
entity_id: input_select.mode
to: Reading
action:
- service: vacuum.turn_on
entity_id: vacuum.downstairs_roomba



8 changes: 5 additions & 3 deletions scripts/ask_about_turning_on.yaml
Expand Up @@ -5,17 +5,19 @@ sequence:
message: |
{{ message | default("Turn on " + entity_id) }}
data:
apns_headers:
'apns-collapse-id': >
{{ apns_collapse_id | default(entity_id) }}
push:
apns_headers:
'apns-collapse-id': >
{{ entity_id }}
category: >
{%- if secure | default("false") != "false" -%}
secure_ack
{%- else %}
ack
{%- endif -%}
action_data:
apns_collapse_id: >
{{ apns_collapse_id | default(entity_id) }}
entity_id: |
{{ entity_id }}
notify_service: |
Expand Down
5 changes: 0 additions & 5 deletions scripts/mode_day.yaml

This file was deleted.

29 changes: 0 additions & 29 deletions scripts/mode_morning.yaml

This file was deleted.

4 changes: 1 addition & 3 deletions scripts/mode_reading.yaml
Expand Up @@ -34,6 +34,4 @@ sequence:
value_template: >
{{ states.input_boolean.guests.state != "on" }}
- service: alarm_control_panel.alarm_arm_home
entity_id: alarm_control_panel.alarm
# - service: vacuum.turn_on
# entity_id: vacuum.downstairs_roomba
entity_id: alarm_control_panel.alarm
4 changes: 3 additions & 1 deletion ui-lovelace.yaml
Expand Up @@ -16,6 +16,7 @@ views:
- cover.gate
- binary_sensor.front_gate
- input_number.brightness
- vacuum.downstairs_roomba
- type: horizontal-stack
cards:
- type: picture-entity
Expand Down Expand Up @@ -141,7 +142,7 @@ views:
- switch.stairs_motion.battery_level
- switch.upstairs_motion.battery_level
- switch.wine_room_motion.battery_level
# - vacuum.downstairs_roomba.battery_level
- vacuum.downstairs_roomba.battery_level
- title: Speakers
icon: mdi:speaker
cards:
Expand Down Expand Up @@ -273,6 +274,7 @@ views:
entities:
- input_boolean.guests
- automation.away_mode
- vacuum.downstairs_roomba
- type: entities
entities:
- sensor.current_version
Expand Down

0 comments on commit cca2a30

Please sign in to comment.