Skip to content

Commit

Permalink
Create temperature and humidity alerts; Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpalottahigh committed Jul 16, 2017
1 parent 1c107e2 commit af3f364
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 124 deletions.
4 changes: 1 addition & 3 deletions android_cameras.yaml
Expand Up @@ -2,6 +2,4 @@
name: Office
switches:
- ffc
- torch
- host: !secret camera_office_2_ip
name: Office 2
- torch
56 changes: 17 additions & 39 deletions automations/home/home.yaml
@@ -1,18 +1,3 @@
# Daily fun announcement
- alias: "Announce a daily fun diaper change"
trigger:
- platform: time
after: "18:00"
action:
- service: tts.google_say
entity_id: media_player.living_room_home
data:
message: "Hm. Maybe I will. Maybe I won't. Or maybe I will... eat... a little bit of... chicken leggie. Chicken leggie! Diaper change!"
- service: notify.yar
data:
title: Diaper change
message: 'Time for a diaper change!'

- alias: "Hello Mr. President!"
trigger:
platform: zone
Expand Down Expand Up @@ -60,41 +45,34 @@
platform: state
entity_id: media_player.living_room_home
to: 'playing'
condition:
condition: and
conditions:
- condition: template
value_template: '{{ states.media_player.living_room_home.attributes.app_name == "Google Play Music" }}'
action:
- service: homeassistant.turn_on
entity_id: switch.livingroom_ball_lights
# - service: homeassistant.turn_on
# entity_id: switch.livingroom_tv_led_demo
- service: homeassistant.turn_on
entity_id: switch.livingroom_tv_led_mode_plus
- service: homeassistant.turn_off
entity_id: switch.livingroom_tv_led_mode_plus
- service: homeassistant.turn_on
entity_id: switch.livingroom_tv_led_mode_plus
- service: homeassistant.turn_off
entity_id: switch.livingroom_tv_led_mode_plus
- service: homeassistant.turn_on
entity_id: switch.livingroom_tv_led_mode_plus
- service: homeassistant.turn_off
entity_id: switch.livingroom_tv_led_mode_plus
- service: homeassistant.turn_on
entity_id: switch.livingroom_tv_led_mode_plus
- service: homeassistant.turn_off
entity_id: switch.livingroom_tv_led_mode_plus
- service: homeassistant.turn_on
entity_id: switch.livingroom_tv_led_mode_plus
- service: homeassistant.turn_off
entity_id: switch.livingroom_tv_led_mode_plus
entity_id: switch.livingroom_tv_led_demo

# Set TV backlights to demo when music is playing on Google Home
- alias: 'Stopping music played on Google Home turn regular TV backlight'
trigger:
platform: state
entity_id: media_player.living_room_home
from: 'playing'
to: 'paused'
# to: 'paused'
condition:
condition: or
conditions:
- condition: state
entity_id: media_player.living_room_home
state: 'paused'
- condition: state
entity_id: media_player.living_room_home
state: 'idle'
action:
- service: homeassistant.turn_off
entity_id: switch.livingroom_ball_lights
# TODO: add ws2812b led strips
- service: homeassistant.turn_on
entity_id: switch.livingroom_tv_led_teal
36 changes: 34 additions & 2 deletions automations/lights/lights.yaml
Expand Up @@ -35,7 +35,7 @@
- alias: "Lights off at 23:45 (sun-thu)"
trigger:
- platform: time
after: "23:45"
at: "23:45"
condition:
- condition: time
weekday:
Expand All @@ -58,7 +58,7 @@
- alias: "Dim lights to night mode at 20:00"
trigger:
- platform: time
after: "20:00"
at: "20:00"
action:
- service: light.turn_on
data:
Expand Down Expand Up @@ -106,6 +106,22 @@
color_temp: 327
transition: 5

# Turn off office light based on LUX sensor
- alias: "Turn off office light based on LUX sensor"
trigger:
platform: numeric_state
entity_id: sensor.sn1_ldr
above: 25
condition:
- condition: state
entity_id: light.office_hue
state: "on"
- condition: time
after: "07:00"
action:
- service: homeassistant.turn_off
entity_id: light.office_hue

# Turn on living room light based on LUX sensor
- alias: "Turn on living room light based on LUX sensor"
trigger:
Expand All @@ -127,6 +143,22 @@
color_temp: 327
transition: 5

# Turn off living room light based on LUX sensor
- alias: "Turn off living room light based on LUX sensor"
trigger:
platform: numeric_state
entity_id: sensor.sn2_ldr
above: 25
condition:
- condition: state
entity_id: light.living_room_hue
state: "on"
- condition: time
after: "07:00"
action:
- service: homeassistant.turn_off
entity_id: light.living_room_hue

# Porch ws2812b led strip
- alias: "Porch Animation Speed"
initial_state: True
Expand Down
100 changes: 94 additions & 6 deletions automations/notifications/notifications.yaml
@@ -1,18 +1,106 @@
# High temperature warning (office - sensor 1)
- alias: 'Temperature warning: office'
trigger:
platform: state
entity_id: sensor.sn1_temperature
condition:
condition: template
value_template: '{{ (states("sensor.sn1_temperature") | float) > (27 | float) }}'
action:
- service: tts.google_say
entity_id: media_player.living_room_home
data_template:
message: 'Warning! Office temperature has reached {{ states.sensor.sn1_temperature.state }} degrees.'
- service: notify.yar
data_template:
title: Office temperature too high
message: 'Temperature: {{ states.sensor.sn1_temperature.state }}'
- service: mqtt.publish
data_template:
topic: 'home/sensornode1/set'
payload: '{"color": {"g": 0, "r": 255, "b": 0}, "state": "ON"}'
- delay: 00:01:00

# High humidity warning (office - sensor 1)
- alias: 'Humidity warning: office'
trigger:
platform: state
entity_id: sensor.sn1_humidity
condition:
condition: template
value_template: '{{ (states("sensor.sn1_humidity") | float) > (55 | float) }}'
action:
- service: tts.google_say
entity_id: media_player.living_room_home
data_template:
message: 'Warning! Office humidity has reached {{ states.sensor.sn1_humidity.state }} percent.'
- service: notify.yar
data_template:
title: Office humidity too high
message: 'Humidity: {{ states.sensor.sn1_humidity.state }}'
- service: mqtt.publish
data_template:
topic: 'home/sensornode1/set'
payload: '{"color": {"g": 0, "r": 0, "b": 255}, "state": "ON"}'
- delay: 00:01:00

# High temperature warning (livingroom - sensor 2)
- alias: 'Temperature warning: livingroom'
trigger:
platform: state
entity_id: sensor.sn2_temperature
condition:
condition: template
value_template: '{{ (states("sensor.sn2_temperature") | float) > (27 | float) }}'
action:
- service: tts.google_say
entity_id: media_player.living_room_home
data_template:
message: 'Warning! Livingroom temperature has reached {{ states.sensor.sn2_temperature.state }} degrees.'
- service: notify.yar
data_template:
title: Livingroom temperature too high
message: 'Temperature: {{ states.sensor.sn2_temperature.state }}'
- service: mqtt.publish
data_template:
topic: 'home/sensornode2/set'
payload: '{"color": {"g": 0, "r": 255, "b": 0}, "state": "ON"}'
- delay: 00:01:00

# High humidity warning (livingroom - sensor 2)
- alias: 'Humidity warning: livingroom'
trigger:
platform: state
entity_id: sensor.sn2_humidity
condition:
condition: template
value_template: '{{ (states("sensor.sn2_humidity") | float) > (55 | float) }}'
action:
- service: tts.google_say
entity_id: media_player.living_room_home
data_template:
message: 'Warning! Livingroom humidity has reached {{ states.sensor.sn2_humidity.state }} percent.'
- service: notify.yar
data_template:
title: Livingroom humidity too high
message: 'Humidity: {{ states.sensor.sn2_humidity.state }}'
- service: mqtt.publish
data_template:
topic: 'home/sensornode2/set'
payload: '{"color": {"g": 0, "r": 0, "b": 255}, "state": "ON"}'
- delay: 00:01:00

# Rain Alert
- alias: 'Raining'
trigger:
platform: state
entity_id: sensor.dark_sky_precip_intensity
from: '0'
to: '0.4'
action:
- service: tts.google_say
entity_id: media_player.living_room_home
data_template:
message: 'Weather forecast: There is currently {{ states.sensor.dark_sky_precip_probability.state }} chance of rain and it is {{ states.sensor.dark_sky_temperature.state | int }}degrees outside. Please consider putting away the deck furniture cushions!'
cache: false
- delay: 00:01:00
- service: automation.turn_off
entity_id: automation.raining
- delay: 00:30:00
- service: automation.turn_on
entity_id: automation.raining
- delay: 01:00:00
4 changes: 2 additions & 2 deletions automations/outlets/outlets.yaml
Expand Up @@ -2,7 +2,7 @@
- alias: Make morning coffee at 6:50
trigger:
- platform: time
after: "06:50"
at: "06:50"
condition:
- condition: time
weekday:
Expand All @@ -22,7 +22,7 @@
- alias: Turn on window lights at 8:00
trigger:
- platform: time
after: "08:00"
at: "08:00"
action:
- service: switch.turn_on
entity_id: switch.livingroom_window_lights
51 changes: 27 additions & 24 deletions configuration.yaml
Expand Up @@ -20,6 +20,7 @@ frontend:

# Add Alexa integration
emulated_hue:
host_ip: !secret emulated_hue_ip
listen_port: 80
# Google Home set up
# type: google_home
Expand All @@ -30,6 +31,12 @@ http:
# Uncomment this if you are using SSL or running in Docker etc
# base_url: example.duckdns.org:8123

# Tradfri
tradfri:
host: !secret tradfri_ip
api_key: !secret tradfri_api
allow_tradfri_groups: false

# Checks for available updates
updater:

Expand Down Expand Up @@ -78,35 +85,47 @@ mqtt:
username: !secret mqtt_username_mosquitto
password: !secret mqtt_password_mosquitto

# Trackers
# Georgi 6P tracker with Owntracks and cloudmqtt
# Device trackers
device_tracker:
- platform: owntracks
max_gps_accuracy: 200
consider_home: 180
# TODO: Work on the know devices list
- platform: netgear
host: !secret netgear_ip
username: !secret netgear_username
password: !secret netgear_password
interval_seconds: 10
consider_home: 180

# IFTT Maker channel
ifttt:
key: !secret ifttt_maker_key

# Notifications
notify:
- platform: pushbullet
name: YAR
api_key: !secret pushbullet_key

# Define zones for triggering actions
zone:
name: Sofi's Work
latitude: 60.2974852
longitude: 25.3298393
latitude: !secret sofi_work_latitude
longitude: !secret sofi_work_longitude
radius: 20
icon: mdi:beer

zone 2:
name: Georgi's Work
latitude: 60.1614637
longitude: 24.904713
latitude: !secret georgi_work_latitude
longitude: !secret georgi_work_longitude
icon: mdi:security

zone 3:
name: Mr. President
latitude: 60.167988
longitude: 24.9548917
latitude: !secret mr_president_latitude
longitude: !secret mr_president_longitude
icon: mdi:memory

###############################################
Expand Down Expand Up @@ -143,22 +162,6 @@ light: !include lights.yaml
# Scenes
scene: !include scenes.yaml

# Testing API.AI and Actions on Google
apiai:
intents:
GetTemperature:
speech: We have {{ states.sensor.office_temperature }} degrees
async_action: False
action:
service: notify.notify
data_template:
message: Api.ai has send a request

notify:
- platform: pushbullet
name: YAR
api_key: !secret pushbullet_key

input_slider:
porch_animation_speed:
name: Porch Animation Speed
Expand Down

0 comments on commit af3f364

Please sign in to comment.