Skip to content

Commit

Permalink
Update configuration for new whyte-house deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
nickw444 committed Feb 8, 2024
1 parent 8694d6f commit 61777ea
Show file tree
Hide file tree
Showing 35 changed files with 942 additions and 309 deletions.
2 changes: 1 addition & 1 deletion home-assistant/313a/.HA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2021.10.1
2024.2.0
4 changes: 2 additions & 2 deletions home-assistant/313a/appdaemon/apps/alarm_auto_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def initialize(self):
)

def on_presence_state_change(self, entity, attribute, old, new, kwargs):
if new == "not_home":
if new == "off":
self._maybe_arm()
else:
self._maybe_disarm()
Expand Down Expand Up @@ -93,7 +93,7 @@ def _can_arm(self):
enable_state = self.get_state(self.args[CONF_ENABLE_ENTITY])
return (
alarm_state == "disarmed"
and presence_state == "not_home"
and presence_state == "off"
and enable_state == "on"
and self._is_enabled()
)
Expand Down
4 changes: 2 additions & 2 deletions home-assistant/313a/appdaemon/apps/apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ alarm_auto_arm:
module: alarm_auto_arm
class: AlarmAutoArm
alarm_entity: alarm_control_panel.alarm_panel
arming_code: !secret arming_code
arming_code: !secret arming_code
# Whether the automation should be enabled
enable_entity: input_boolean.alarm_auto_arm_schedule
# Overrides enable_entity. Useful if enable_entity is controlled via other automations
# but want to maintain disabled/enabled state through those transitions
enable_override_entity: input_boolean.alarm_auto_arm_override
presence_entity: group.family
presence_entity: binary_sensor.family_is_home
76 changes: 52 additions & 24 deletions home-assistant/313a/appdaemon/tests/test_alarm_auto_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ARMING_CODE = "123456"
ENABLE_ENTITY = "input_boolean.enable"
ENABLE_OVERRIDE_ENTITY = "input_boolean.enable_override"
PRESENCE_ENTITY = "group.people"
PRESENCE_ENTITY = "binary_sensor.people_home"


def test_callbacks_are_registered(hass_driver, auto_arm):
Expand All @@ -31,12 +31,12 @@ def test_callbacks_are_registered(hass_driver, auto_arm):

def test_when_everyone_leaves_then_arm(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "home")
hass_driver.set_state(PRESENCE_ENTITY, "on")
hass_driver.set_state(ALARM_ENTITY, "disarmed")
hass_driver.set_state(ENABLE_ENTITY, "on")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "on")

hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")

call_service = hass_driver.get_mock("call_service")
call_service.assert_any_call(
Expand All @@ -46,12 +46,12 @@ def test_when_everyone_leaves_then_arm(hass_driver, auto_arm):

def test_logs_to_logbook_when_armed(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "home")
hass_driver.set_state(PRESENCE_ENTITY, "on")
hass_driver.set_state(ALARM_ENTITY, "disarmed")
hass_driver.set_state(ENABLE_ENTITY, "on")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "on")

hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")

call_service = hass_driver.get_mock("call_service")
call_service.assert_any_call(
Expand All @@ -61,14 +61,27 @@ def test_logs_to_logbook_when_armed(hass_driver, auto_arm):
)


def test_when_presence_unavailable_then_do_not_arm(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "on")
hass_driver.set_state(ALARM_ENTITY, "disarmed")
hass_driver.set_state(ENABLE_ENTITY, "off")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "on")

hass_driver.set_state(PRESENCE_ENTITY, "unavailable")

call_service = hass_driver.get_mock("call_service")
call_service.assert_not_called()


def test_when_everyone_leaves_and_not_enabled_then_do_not_arm(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "home")
hass_driver.set_state(PRESENCE_ENTITY, "on")
hass_driver.set_state(ALARM_ENTITY, "disarmed")
hass_driver.set_state(ENABLE_ENTITY, "off")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "on")

hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")

call_service = hass_driver.get_mock("call_service")
call_service.assert_not_called()
Expand All @@ -78,33 +91,33 @@ def test_when_everyone_leaves_and_not_enabled_via_override_then_do_not_arm(
hass_driver, auto_arm
):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "home")
hass_driver.set_state(PRESENCE_ENTITY, "on")
hass_driver.set_state(ALARM_ENTITY, "disarmed")
hass_driver.set_state(ENABLE_ENTITY, "on")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "off")

hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")

call_service = hass_driver.get_mock("call_service")
call_service.assert_not_called()


def test_when_everyone_leaves_and_armed_do_not_arm(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "home")
hass_driver.set_state(PRESENCE_ENTITY, "on")
hass_driver.set_state(ALARM_ENTITY, "armed_away")
hass_driver.set_state(ENABLE_ENTITY, "on")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "on")

hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")

call_service = hass_driver.get_mock("call_service")
call_service.assert_not_called()


def test_when_re_enabled_then_arm(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")
hass_driver.set_state(ALARM_ENTITY, "disarmed")
hass_driver.set_state(ENABLE_ENTITY, "off")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "on")
Expand All @@ -119,7 +132,7 @@ def test_when_re_enabled_then_arm(hass_driver, auto_arm):

def test_when_override_re_enabled_then_arm(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")
hass_driver.set_state(ALARM_ENTITY, "disarmed")
hass_driver.set_state(ENABLE_ENTITY, "on")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "off")
Expand All @@ -134,7 +147,7 @@ def test_when_override_re_enabled_then_arm(hass_driver, auto_arm):

def test_when_re_enabled_but_override_disabled_then_do_not_arm(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")
hass_driver.set_state(ALARM_ENTITY, "disarmed")
hass_driver.set_state(ENABLE_ENTITY, "off")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "off")
Expand All @@ -147,12 +160,27 @@ def test_when_re_enabled_but_override_disabled_then_do_not_arm(hass_driver, auto

def test_when_someone_home_disarm(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")
hass_driver.set_state(ALARM_ENTITY, "armed_away")
hass_driver.set_state(ENABLE_ENTITY, "on")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "on")

hass_driver.set_state(PRESENCE_ENTITY, "on")

call_service = hass_driver.get_mock("call_service")
call_service.assert_any_call(
"alarm_control_panel/alarm_disarm", entity_id=ALARM_ENTITY, code=ARMING_CODE
)


def test_when_presence_unavailable_then_disarm(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "off")
hass_driver.set_state(ALARM_ENTITY, "armed_away")
hass_driver.set_state(ENABLE_ENTITY, "on")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "on")

hass_driver.set_state(PRESENCE_ENTITY, "home")
hass_driver.set_state(PRESENCE_ENTITY, "unavailable")

call_service = hass_driver.get_mock("call_service")
call_service.assert_any_call(
Expand All @@ -162,25 +190,25 @@ def test_when_someone_home_disarm(hass_driver, auto_arm):

def test_fires_event_when_disarmed(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")
hass_driver.set_state(ALARM_ENTITY, "armed_away")
hass_driver.set_state(ENABLE_ENTITY, "on")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "on")

hass_driver.set_state(PRESENCE_ENTITY, "home")
hass_driver.set_state(PRESENCE_ENTITY, "on")

fire_event = hass_driver.get_mock("fire_event")
fire_event.assert_any_call("auto_arm_disarmed")


def test_logs_to_logbook_when_disarmed(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")
hass_driver.set_state(ALARM_ENTITY, "armed_away")
hass_driver.set_state(ENABLE_ENTITY, "on")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "on")

hass_driver.set_state(PRESENCE_ENTITY, "home")
hass_driver.set_state(PRESENCE_ENTITY, "on")

call_service = hass_driver.get_mock("call_service")
call_service.assert_any_call(
Expand All @@ -192,25 +220,25 @@ def test_logs_to_logbook_when_disarmed(hass_driver, auto_arm):

def test_when_someone_home_but_override_disabled_dont_disarm(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")
hass_driver.set_state(ALARM_ENTITY, "armed_away")
hass_driver.set_state(ENABLE_ENTITY, "on")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "off")

hass_driver.set_state(PRESENCE_ENTITY, "home")
hass_driver.set_state(PRESENCE_ENTITY, "on")

call_service = hass_driver.get_mock("call_service")
call_service.assert_not_called()


def test_when_someone_home_but_disabled_then_disarm(hass_driver, auto_arm):
with hass_driver.setup():
hass_driver.set_state(PRESENCE_ENTITY, "not_home")
hass_driver.set_state(PRESENCE_ENTITY, "off")
hass_driver.set_state(ALARM_ENTITY, "armed_away")
hass_driver.set_state(ENABLE_ENTITY, "off")
hass_driver.set_state(ENABLE_OVERRIDE_ENTITY, "on")

hass_driver.set_state(PRESENCE_ENTITY, "home")
hass_driver.set_state(PRESENCE_ENTITY, "on")

call_service = hass_driver.get_mock("call_service")
call_service.assert_any_call(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
id: "1669714840315"
alias: "outdoor: turn off tree lights at 10:00pm"
description: ""
trigger:
- platform: time
at: "22:00:00"
- platform: homeassistant
event: start
condition:
- condition: or
conditions:
- condition: sun
before: sunset
- condition: time
after: "21:59:59"
action:
- service: light.turn_off
data: {}
target:
entity_id: light.tree_lights
mode: single
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id: "1669714700223"
alias: "outdoor: turn tree lights on at sunset"
description: "outdoor: turn tree lights on at sunset"
trigger:
- platform: sun
event: sunset
offset: 30
action:
- service: light.turn_on
data: {}
target:
entity_id: light.tree_lights
mode: single
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
id: "1588501846352"
alias: when quiet room fridge or freezer door open for more than 5 minutes, send notification
description: ""
trigger:
- device_id: a5ea6ad6759345c698658afb9c644309
domain: binary_sensor
entity_id: binary_sensor.0x00158d000451d897_contact
for:
hours: 0
minutes: 5
seconds: 0
platform: device
type: opened
- device_id: 70146a3c3a6247d59063afbfeea3eb7f
domain: binary_sensor
entity_id: binary_sensor.0x00158d00049fb09a_contact
for:
hours: 0
minutes: 5
seconds: 0
platform: device
type: opened
condition: []
action:
- data:
message: The quiet room fridge or freezer has been left open
service: notify.everyone
13 changes: 13 additions & 0 deletions home-assistant/313a/automations/ups/ups-state-change.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id: "1591600935265"
alias: on UPS state change, send a notification
description: ""
trigger:
- entity_id: sensor.ups_status
platform: state
condition: []
action:
- data_template:
message: >
The UPS status changed to {{ trigger.from_state.state }}
to {{ trigger.to_state.state }}
service: notify.admins
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
blueprint:
name: Motion-activated Light
description: Turn on a light when motion is detected.
domain: automation
source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
light_target:
name: Light
selector:
target:
entity:
domain: light
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds

# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent

trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"

action:
- service: light.turn_on
target: !input light_target
- wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- delay: !input no_motion_wait
- service: light.turn_off
target: !input light_target
Loading

0 comments on commit 61777ea

Please sign in to comment.