tetsuo13 / home-assistant-config

Home Assistant configuration
MIT License
2 stars 0 forks source link
home-assistant home-assistant-config home-assistant-configuration home-automation homeassistant homeassistant-config homeassistant-configuration

Continuous integration

This is the configuration used in my Home Assistant (HA) setup.

Runs on a Raspberry Pi 3B using Home Assistant Operating System.

Devices

Hubs

Device Connection Home Assistant
Aeotec Z-Stick Gen5 (ZW090-A) USB Z-Wave JS
Philips Hue Bridge Ethernet Philips Hue

The Hue Bridge is easily the most troublesome device in use. Requires power cycling about once a week otherwise it becomes completely unresponsive from Home Assistant.

Lighting

Device Connection Home Assistant
Litake LED Strip Lights (WIFIDD328) Wi-Fi Flux LED/MagicLight
Philips Hue white and color ambience bulb Hue Hub (Zigbee) Philips Hue
Philips Hue white ambience bulb Hue Hub (Zigbee) Philips Hue

Climate

Device Connection Home Assistant
Ecobee 4 (EB-STATE4-01) Wi-Fi ecobee
Ecobee room sensor ecobee ecobee

Sensors & Switches

Device Connection Home Assistant
Belkin Wemo Mini Smart Plug (F7C063fc) Wi-Fi Belkin WeMo
Ecolink Door & Window Sensor (DW-ZWAVE2.5-ECO) Z-Wave JS Z-Wave JS
Fibaro Z-Wave Flood Sensor (FGFS-101) Z-Wave JS Z-Wave JS
First Alert Smoke & CO Alarm Z-Wave JS Z-Wave JS
GE Enbrighten Z-Wave In-Wall Smart Switch Z-Wave JS Z-Wave JS
GE Z-Wave In-Wall Smart Fan Control Z-Wave JS Z-Wave JS
TP-Link Kasa Smart Plug (HS103VS) Wi-Fi TP-Link
ZOOZ 4-in-1 sensor (ZSE40) Z-Wave JS Z-Wave JS
ZOOZ Double Switch (ZEN30) Z-Wave JS Z-Wave JS

Cameras

Device Connection Home Assistant
Amcrest PoE Camera (IP5M) Ethernet Dahua
Amcrest Video Doorbell (AD410) Wi-Fi Amcrest

Media

Device Connection Home Assistant
Sonos WiFi bookshelf speaker (SYMFONISK) Wi-Fi Sonos

Automations

Christmas lights automations aren't available year-round (they're added when the tree goes up, removed again when the tree goes down). See previous years in #40, #15 and c013a7c on what was done.

The bedtime.yaml handles turning off services and devices that may have been forgotten on. There's an associated automation to trigger the script late at night.

Door Automations

Opening and closing doors causes an announcement to be made through all of the Sonos speakers. A chime is played first to grab attention followed by a TTS announcement. See the sonos_say script on how this is done.

The primary automation is to announce which door was used however this is overridden during several months where a the TTS announcement is replaced by playing an audio file from the www/audio directory instead. The months are:

There's also the birthday binary sensor which, when enabled, causes a birthday jingle to be played instead of the TTS announcement or special month sound. This binary sensor should take precedence over all other events. The days are held in secrets.yaml.dist in the birthday_evaluator key, as a Python array of month and day values. Since it wasn't possible to parse a secret value into a template, the entire template was set as the secret value.

The sonos_play_file script used to play audio files to all Sonos speakers. It has logic to never broadcast to the office speaker during business hours (Monday - Friday, 8am - 5pm).

Motion Automations

Guest bathroom lights turn on when motion is detected, they turn back off after a few minutes of no motion. Overnight, the lights only turn on at a low brightness to prevent blindness. If the fan is on, it'll turn off after a few minutes after the lights have turned off.

Motion Detection with Cameras

The front door camera takes care of sending notifications using the Amcrest Smart Home app (one of the few services connected to the cloud). The icon shown on the automations tab of the dashboard just controls whether or not the camera should notify the Amcrest app.

For the other camera, when motion is detected a snapshot is taken and a notification is sent to the Companion App using a URL to the snapshot that's accessible from the Internet. By default these snapshots are only accessible from the intranet which makes them largely useless when not at home (see standard attachments documentation for Companion App). The snapshots are created in the www/images/snapshots directory so that viewing them doesn't require authentication. Considering that authentication isn't a requirement and an attacker could potentially guess filenames by iterating through past date and times should they discover the publically accessible URL to the server, an additional component is added to the filename to dramatically increase the possible combinations of characters. This doesn't stop a motivated attacker from eventually finding a valid filename, just makes it more apparent in the logs of a brute-force attack.

Camera snapshots are made available for review in the Media section of Home Assistant. This was done because notifications sent to the Companion App are ephemeral: you view them at the moment of notification, swipe it away, and have no ability to view it again unless going to the NVR. While the images from the Media browser can be manually deleted there's a scheduled shell script that will automatically delete images older than a few days.

The Home Assistant server isn't on the Internet but instead sits behind a reverse proxy with only the camera snapshots directory exposed. Example relevant Nginx config:

server {
  location ~ ^/snapshots/([a-z\.\-0-9_]+\.jpg)$ {
    proxy_pass            http://192.168.1.1:8123/local/images/snapshots/$1;
    proxy_set_header      X-Real-IP        $remote_addr;
    proxy_set_header      X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_set_header      Host             $http_host;
  }

  # Fallback for all other requests. Return 403 Forbidden.
  location / {
    return 403;
  }
}

Smoke Alarm Automations

When a smoke alarm detects smoke or carbon monoxide, an announcement is made over all Sonos speakers, an email is sent, and a notification on the mobile app is sent. Then all available lights are turned on.

Fan Automations

Air purifier isn't smart but it's plugged into a Wemo smart plug. Air purifier is intended to run overnight. Automation cuts power in the morning to turn it off and another automation task turns power back on however someone must still manually press the "on" button on the air purifier unit to actually turn it on. Toggling power to the dumb air purifier is preferable to some of the much more expensive smart air purifiers out there.

Light Automations

There are automations to gradually fade on bedside lamps on weekday mornings, turn off before leaving for work, gradually fade on again at sundown, and gradually fade off by bedtime. Similar automations to handle outside lights.

The "Live" light is a bulb connected to a Wi-Fi switch that's meant to be on when Microsoft Teams is in a call. Determining the status of Teams is done by calling a RESTful service which returns a simple JSON result that's interpretted as either true or false. The responsibility of determining the status of Teams is offloaded to Teams Status Pub.

Custom Components

There are some custom components in use. See the README file in the custom_components directory for more details.

Screenshots

UI UI

Links

This repo tries to adhere to the YAML Style Guide at the Home Assistant Developer Docs.

Other Noteable Configurations

Below is a list, in no special order, of other configurations that were particularly inspiring: