Skip to content

Commit

Permalink
Update HA, add light automations and limit db
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarb committed Jan 31, 2021
1 parent 5a0df93 commit 3177865
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .HA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.118.3
2021.1.5
69 changes: 69 additions & 0 deletions automations.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,72 @@
# Turn off all lights 01 / 02 (when not home)

- id: '1564525145700'
alias: Turn christmas lights on when dark outside
trigger:
entity_id: sun.sun
attribute: elevation
platform: numeric_state
below: -3.0
condition: []
action:
- service: homeassistant.turn_on
data:
entity_id: group.christmas_lights
- id: '1564525145711'
alias: Turn christmas lights off when bright outside
trigger:
- platform: sun
entity_id: sun.sun
event: sunrise
condition: []
action:
- service: homeassistant.turn_off
data:
entity_id: group.christmas_lights
- id: '1608504370538'
alias: Turn off Christmas lights at night
trigger:
- platform: time
at: 00:30
condition: []
action:
- service: homeassistant.turn_off
data:
entity_id: group.christmas_lights
- id: '1564525145701'
alias: Turn office lights on when computer is active
trigger:
- platform: state
entity_id: binary_sensor.macbook_pro
to: 'on'
condition:
condition: state
entity_id: binary_sensor.macbook_pro_at_desk
state: 'on'
action:
- service: light.turn_on
data:
entity_id: group.office
- id: '1564525145702'
alias: Turn office lights off when computer is inactive
trigger:
- platform: state
entity_id: binary_sensor.macbook_pro
to: 'off'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.macbook_pro_at_desk
state: 'on'
- condition: time
after: '15:30:00'
action:
- service: light.turn_off
data:
entity_id:
- office.office_spotlights
- office.office_desk_lamp
- id: '1564525145782'
alias: Hallway motion turns on tablet
trigger:
Expand Down
50 changes: 50 additions & 0 deletions blueprints/automation/homeassistant/motion_light.yaml
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
43 changes: 43 additions & 0 deletions blueprints/automation/homeassistant/notify_leaving_zone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
blueprint:
name: Zone Notification
description: Send a notification to a device when a person leaves a specific zone.
domain: automation
source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml
input:
person_entity:
name: Person
selector:
entity:
domain: person
zone_entity:
name: Zone
selector:
entity:
domain: zone
notify_device:
name: Device to notify
description: Device needs to run the official Home Assistant app to receive notifications.
selector:
device:
integration: mobile_app

trigger:
platform: state
entity_id: !input person_entity

variables:
zone_entity: !input zone_entity
# This is the state of the person when it's in this zone.
zone_state: "{{ states[zone_entity].name }}"
person_entity: !input person_entity
person_name: "{{ states[person_entity].name }}"

condition:
condition: template
value_template: "{{ trigger.from_state.state == zone_state and trigger.to_state.state != zone_state }}"

action:
domain: mobile_app
type: notify
device_id: !input notify_device
message: "{{ person_name }} has left {{ zone_state }}"
67 changes: 67 additions & 0 deletions configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,63 @@ conversation:

# Enables support for tracking state changes over time
history:
exclude:
domains:
- automation
- updater
- camera
- device_tracker
- group
- input_text
- persistent_notification
- script
- sensor
- variable
entities:
- binary_sensor.updater
entity_globs:
- binary_sensor.macbook_pro_*
- binary_sensor.mqtt_*
- switch.*_sensor
- switch.ip_webcam
- sensor.mqtt_*
- sensor.*dimmer*

include:
domains:
- light
- binary_sensor
- switch
- sensor
- sun
- switch
- vacuum
entities:
- sensor.ip_webcam_motion
- sensor.oneplus_6t_geocoded_location
- media_player.tv
- device_tracker.oneplus_a6013
- binary_sensor.macbook_pro
- binary_sensor.macbook_pro_at_desk

# View all events in a logbook
logbook:
exclude:
domains:
- updater
- media_player

# Purge database regularly
recorder:
purge_keep_days: 7
exclude:
domains:
- automation
- updater
- camera
- group
- persistent_notification
- script

# Enables a map showing the location of tracked devices
map:
Expand Down Expand Up @@ -98,6 +148,23 @@ binary_sensor:
{{ is_state('binary_sensor.mqtt_hallway_motion', 'on')
or (is_state('binary_sensor.mqtt_hallway_motion', 'unavailable') and is_state('switch.hallway_motion_sensor', 'on')) }}
- platform: template
sensors:
macbook_pro:
friendly_name: "MacBook Pro active"
value_template: >-
{{ is_state('binary_sensor.macbook_pro_active', 'on')
or is_state('binary_sensor.macbook_pro_active_work', 'on')
}}
- platform: template
sensors:
macbook_pro_at_desk:
friendly_name: "MacBook Pro at desk"
value_template: >-
{{ not is_state('sensor.macbook_pro_internal_battery_state', 'Not Charging') }}
# Switches
switch:
- platform: wake_on_lan
Expand Down
14 changes: 14 additions & 0 deletions scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ turn_everything_off:
- service: switch.turn_off
entity_id: all

good_morning_home:
alias: Turn lights on in the morning
sequence:
- service: light.turn_on
entity_id:
- light.living_room_christmas_star
- light.kitchen_ceiling
- service: switch.turn_on
entity_id:
- switch.advent_candlestick
- switch.christmas_tree
- switch.balcony_string_lights


cast_youtube:
alias: Cast YouTube
sequence:
Expand Down

0 comments on commit 3177865

Please sign in to comment.