
This is the configuration used in my Home Assistant (HA) setup. Runs as a virtual machine using Home Assistant Operating System.
Devices
Hubs
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
Climate
Sensors & Switches
Cameras
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 #74, #40, #15 and c013a7c on what was done.
There’s a bedtime automation that triggers the bedtime.yaml script which takes care of turning off services and devices that may have been forgotten on. Things like Sonos speakers forgotten on or camera snapshot notifications that were disabled.
The “white noise sound machine” is achieved using a Sonos speaker and playing a specific media on repeat. Once you find the perfect white noise media (a topic that’s very personal), use this process to record it in the automation:
- In the Sonos app:
- Add the media to your favorite by tapping the three dots button and then Save to Sonos Favorites.
- Navigate back to the home screen and tap on the media that was just saved under the Sonos Favorites section.
- Play it on the target Sonos device.
- In Home Assistant:
- Go to Developer tools.
- Filter for the media player device.
- Look at the Attributes for the device and copy the media_content_id value.
Using Sonos Favorites was the only way to get Sonos to recognize the media content without error.
Despite how it may seem contrary, the media_class metadata value will most likely be “music,” even though it’s not listed as a supported audio format under Sonos documentation. Depending on what type of music is chosen, this value may need to be changed however it wasn’t needed under my limited experience.
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:
- October: goulish sounds and howling wolf
- November: turkey gobble
- December: sleigh bells
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).
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;
}
}
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.
Air purifier isn’t smart but it’s plugged into a TP-Link Kasa smart plug. Turning the air purifier on is a manual process of pushing the button on the device; turning it off is achieved through turning off the smart plug although it needs to be turned back on again so that it’s ready for the manual process again. The air_purifier script handles this “turn off then back on again” case. Maintaining this automation to toggle power to the dumb air purifier is preferable to some of the much more expensive smart air purifiers out there.
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

Links
This repo tries to adhere to the YAML Style Guide at the Home Assistant Developer Docs.
Noted in the Home Assistant docs for the Frontend Icons is a helpful website to browse all available icons that are used for customizations: https://pictogrammers.com/library/mdi/
Other Noteable Configurations
Below is a list, in no special order, of other configurations that were particularly inspiring:
评论