Automate Your Life

Home-Assistant.io

Teagan Glenn

that@teagantotally.rocks

Teagan42

Denver Devs Slack: Teagan42

My Background

  • Been coding for 18 years, 10 professionally
  • Completed Bachelors Programs in
    • Physics
    • Mathematics
    • Computer Science
    • (Incomplete) Electrical Engineering
  • Self-Proclaimed Engineer of Laziness

My Automations

  • Alarm System via Presence detection
  • Notifications
  • Car Mode
  • Movie Mode
  • Voice Control
  • Thermostat via Presence Detection
  • Plant Monitoring and Watering
  • Weather Aware Sprinklers
  • Monitoring the Chicken Coop

Internet of Things

  • Devices
    • Switches
    • Lights
    • Thermostats
    • Trashcans
    • Garage Doors
  • Cloud Services
    • Wink
    • Insteon
    • Nest

Marketing

Enough Said

Forced Obsolescence

Revolv - A Wakeup Story

Revolv & Nest

October 2014: Nest Acquires Revolv.

February 2016: A quiet notice appears on the Revolv home page.

May 2016: Revolv hubs cease to function.

Standards and Protocols

Protocols

Protocols

So, what can I do?

Home-Assistant.io

Integrations

Open Source

Installation

Configuration

pip3 install homeassistant
hass --open-ui
homeassistant:
  name: Home Assistant
  latitude: 39.6323225
  longitude: -105.131914
  temperature_unit: F
  time_zone: America/Denver

sun:

frontend:

Modern UX

  • Material Design
    • Reactive
    • Polymer
  • Development Mode
  • Voice Control!

History

First Steps

  1. Configure your devices
    • Sensors
    • Switches
    • Lights
    • Etc.
  2. Use the System
    • No automation

The Fun Begins!

Let's Help The Planet

Sprinklers and Weather

Basic Ingredients

  • Raspberry Pi
    • 0, 1, 2, 3
  • Digital Relay Board
    • 1 Relay per Zone

Rain Sensor

# Configuration
sensor:
    platform: forecast
    api_key: {{YOUR KEY}}
    monitored_conditions:
      - precip_intensity

sensor:
    platform: openweathermap
    api_key: {{YOUR KEY}}
    forecast: 0 or 1 # Current or Forecast
    monitored_conditions:
      - rain

sensor:
    platform: yr
    monitored_conditions:
      - precipitation

Zone Trigger

# Configuration
switch:
  platform: rpi_gpio
  ports:
    4: Zone 1
    11: Zone 2
    12: Zone 3
    # Etc.
  invert_logic: false

# Trigger
alias: 'Zone 1'
trigger:
    platform: time
    hours: '/8'
    minutes: 0
condition:
    condition: numeric_state
    entity_id: sensor.weather_precip_intensity
    below: 1
action:
    service: switch.turn_on
    data:
        entity_id: switch.zone_1
# Is Not Raining
alias: 'Timer - Not Raining'
trigger:
    platform: state
    entity_id:
      - switch.zone_1
      - switch.zone_2
      - switch.zone_3
    state: 'on'
    for:
        minutes: 15
action:
    service: switch.turn_off
    data_template:
        entity_id: '{{ trigger.entity_id }}'

# Is Raining
alias: 'Timer - Raining'
trigger:
    platform: state
    entity_id:
      - switch.zone_1
      - switch.zone_2
      - switch.zone_3
    state: 'on'
    for:
        minutes: 5
condition:
    condition: numeric_state
    entity_id: sensor.weather_precip_intensity
    above: 1
action:
    service: switch.turn_off
    data_template:
        entity_id: '{{ trigger.entity_id }}'

Ways to Improve

  • Forecasted Precipitation
  • Adjust Duration for Hot/Cold Days
  • Add Soil Moisture Sensors

Feel More Secure

Intruder Alert

Basic Ingredients

  • Door Sensors
    • Hidden
    • Magnetic
  • Compatible Webcam
  • Smart Lights

Trigger

alias: 'Intruder Alert'
trigger:
    platform: state
    entity_id: group.door_sensors
    from: 'off'
    to: 'on'
condition:
    condition: state
    entity_id: group.family
    state: 'not_home'
action:
    service: script.intruder_alert

Intruder Alert Script

sequence:
  - service: notify.aws_sns
    data_template:
        message: >
          Someone is in the house.
          http://domain{{ camera.entry.attributes.entity_picture }}
        target: 'aws:arn:important'
        title: 'Possible Intruder Detected'
  - service: light.turn_on
    entity_id: light.all_lights

Ways to Improve

  • Flash Lights or Blast Audio Warning
  • Notify Authorities/Neighbors
  • Simulated Occupancy

Let's Save Some Money

HVAC and Presence Detection

Basic Ingredients

  • Thermostat
    • Compatible Smart Thermostat
    • Smart Switches w/ Temperature Sensor
  • Presence Detection
    • Compatible Router
    • OwnTracks/Locative

Cool When Home

alias: 'Thermostat - Occupied - Cool'
trigger:
  platform: template
  value_template: >
    {{
      (float(states.thermostat.main.attributes.current_temperature) > 77
      or (
        states.thermostat.main.attributes.system_mode == 'cool' and
        float(states.thermostat.main.state) != 77
      ))
        and group.family.state == 'home'
    }}
action:
  - service: thermostat.set_hvac_mode
    data:
      entity_id: thermostat.main
      hvac_mode: 'cool'
  - service: thermostat.set_temperature
    data:
      entity_id: thermostat.main
      temperature: 77

Reduce A/C When Away

alias: 'Thermostat - Away - Cool'
trigger:
  platform: template
  value_template: >
  {{
    (float(states.thermostat.main.attributes.current_temperature) > 82
    or (
      states.thermostat.main.attributes.system_mode == 'cool' and
      float(states.thermostat.breathosmart.state) != 82
    ))
    and group.family.state != 'home'
  }}
action:
  - service: thermostat.set_hvac_mode
    data:
      entity_id: thermostat.main
      hvac_mode: 'cool'
  - service: thermostat.set_temperature
    data:
      entity_id: thermostat.main
      temperature: 82

Nice and Toasty

alias: 'Thermostat - Occupied - Heat'
trigger:
  platform: template
  value_template: >
  {{
    (float(states.thermostat.main.attributes.current_temperature) < 69
    or (
      states.thermostat.main.attributes.system_mode == 'heat' and
      float(states.thermostat.main.state) != 69
    ))
    and group.family.state == 'home'
  }}
action:
  - service: thermostat.set_hvac_mode
    data:
      entity_id: thermostat.main
      hvac_mode: 'heat'
  - service: thermostat.set_temperature
    data:
      entity_id: thermostat.main
      temperature: 69

Reduce Heat When Away

alias: 'Thermostat - Away - Heat'
trigger:
  platform: template
  value_template: >
    {{
      (float(states.thermostat.main.attributes.current_temperature) < 65
      or (
        states.thermostat.main.attributes.system_mode == 'heat' and
        float(states.thermostat.main.state) != 65
      ))
      and group.family.state != 'home'
    }}
action:
  - service: thermostat.set_hvac_mode
    data:
      entity_id: thermostat.main
      hvac_mode: 'heat'
  - service: thermostat.set_temperature
    data:
      entity_id: thermostat.main
      temperature: 65

Ways to Improve

  • Implement Set Points with Sliders
  • GPS Device Tracking + Google Maps Travel Time
  • Adjust Set Points via Weather Forecast
  • Temperature Sensors

Entertain

Movie Mode

Basic Ingredients

  • Lights
    • Smart Light Fixture or Switch
    • Floorboard lights
  • Plex or Kodi Media Player
  • Smart Outlet for Popcorn

Media Player Trigger

alias: 'Movie Mode'
trigger:
    platform: state
    entity_id: media_player.default
    from: 'idle'
    to: 'playing'
action:
  - service: script.movie_mode

Movie Mode Script

sequence:
  - service: light.turn_off
    data:
        entity_id: light.living_room
  - service: light.turn_on
    data:
        entity_id: light.floorboards
  - condition: state
    entity_id: input_boolean.should_make_popcorn
    state: 'on'
  - service: switch.turn_on
    data:
        entity_id: switch.popcorn_machine
  - service: input_boolean.turn_off
    data:
        entity_id: input_boolean.should_make_popcorn
  - service: notify.aws_sns
    data:
        message: 'Your popcorn will be ready shortly.'
        target: 'aws:arn:address'
        title: 'Movie Time!'
  - delay: 00:05:00
  - service: switch.turn_off
    data:
        entity_id: switch.popcorn_machine

Ways to Improve

  • Hopper for Popcorn Kernels
  • Turn On the Lights When Done
  • Close Shutters/Blinds
  • Pause Movie if Someone Talks

Awesome!

But, it doesn't support my device...

No Problem!

Home-Assistant Component Architecture

A Platform Is...

The API used to talk to the physical device.

A Component is...

The representation of your physical device inside Home-Assistant.io

A Domain Is...

The type or category of a component

Domains Baked In

  • Alarm Control Panel
  • Binary Sensor
  • Camera
  • Device Tracker
  • Garage Door
  • Light
  • Lock
  • Roller/Shutter
  • Sensor
  • Switch
  • Thermostat

Questions

Resources

Home Assitant

http://home-assistant.io

Jinga2 Templates

http://jinja.pocoo.org/

Alexa Skills

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit

Home Assistant Help Chat Room

https://gitter.im/home-assistant/home-assistant

Automating Your Life - Home Automation

By Teagan Glenn

Automating Your Life - Home Automation

  • 7,428