So I made a small post about if this was a valid topic in the musing thread but finally got it mostly done setup (there is no done) so figured I'd make a post.
So to start these are the definitions that I use
Smart Device = any device that allows remote control of any type including voice via Alexa/Google Home, This is what most people think when someone says smart home.
Smart House = uses sensors & automation to control Smart Devices
WAF = Wife Approval Factor = How Non-techies approve of the smart home
Also my current devices make use of the following protocols Wifi / Z-wave / Zigbee / MQTT
Some history I got started on the smart home thing last christmas (2017) when my wife bought me a Smartthings hub and 4 sengled white light bulbs. I expanded this to a couple motion sensors to control the lights and then quickly realized that while Smartthings is good for simple things if you want to do more complex things or use multiple conditions to trigger things you need to use their webcore platform which shifts all the logic to the cloud and honestly I'd rather have my house controlled from my house. So this recent August (2018) I built an actual server for various things (plex / nextcloud / NAS) and bought a zwave & zigbee usb stick so I could eventually replace the Smartthings hub. The server is running Unraid for the base OS and everything runs in docker containers so it should be runnable anywhere.
Anyways I decided to use Home Assistant (HA from now on) as the brains for my house. It is an open sourced python software that uses Yaml files (text files with formatting requirements) to configure everything and has components to interface with pretty much any product you could want. Bonus points every single thing runs locally on the server (There is a cloud component but the logic still runs locally). Since everything runs on text files I can use Github to store my config in.
So to get into my full set up this is the hardware I currently have
Smart Plugs
3 Wemo mini plugs (wifi)
3 Gosund (wifi) (not in use yet)
Lights
4 Sengled Light bulbs (Zigbee)
Switches
2 Zooz dimmer switches (Z-wave)
Sensors
2 Bosch Motion sensors (Zigbee),
2 Zooz 4-in-1 sensors (Z-wave),
2 smartthings door sensor (Zigbee)
Speakers
Sonos speakers (wifi)
Media Players
3 Chromecast (wifi),
Samsung Smart TV (wifi)
Other
Xiaomi Smart Cube (Zigbee),
SmartThings Hub (Wired),
Tomato Router (Wired),
3 Pixel Phones (Wifi),
1 Amazon Echo Dot (Wifi)
On top of the hardware I have a few notable software pieces in use. I'm using Owntracks which sends gps from the pixel phones back to a secured MQTT broker running on my server which then sends to an unsecured internal only MQTT server (the smartthings bridge doesn't support authentication) which HA then reads. I use MariaDB to store all the data from HA (purging at 5 days old) I also have a few other software tied into HA that I don't do anything with (I'm still in get all the data setup mode ) Plex, Tautulli (plex monitor), qBittorrent, Transmission.
Also have a bunch of components not currently being used (same logic not sure what I'll end up wanting), ISS (let me know when ISS is overhead), Space Launch (Lets me know when the next launch is), Moon/Sun/Season (Moon Phase/Sun rise&set/Season), YR (Weather from Norwegian Meteorological Institute), Darksky (weather from darksky)
So I do still use the Smartthing Hub but I found a piece of software that takes events from Smartthings and sends it via MQTT to HA and then sends things from HA back to Smartthings. This is due to the fact that zigbee IMO sucks as a protocol since it is open for anyone to modify you end up with each developer making a slightly different version so getting them to talk to each other isn't the easiest and while the light bulbs should in theory work directly from what I've been able to find online the motion sensors don't currently so I just left them all on the Smartthings hub for now.
Since they are somewhat odd these are the setups for my living room lights coming from smart things
So smartthings post on the state topics and then HA posts on the command topics, HA uses a brightness scale of 0-255 while Smartthings uses 0-100 so need to set that
When I was just starting to set this up I luckily found someone else who had set up the files in a way that make sense and split them up so each file does 1 thing, since the standard way of doing the config for HA is to just use 1 or possible 2 files. Since I didn't have many files done yet I converted and it is so much neater. HA does have a nice way of storing "secrets" in a separate file that you can then reference which is useful when posting them online or getting debugging help so there are several times in the files where I have !secret X that means it will go to the file and get that key and replace it.
Anyways I'm not going to post all of my setup files here but I'll post some of my automations.
So these two automations work together (and I need to tweak since they currently have a low WAF hence initial_state: 'off') with the two scenes to when we start playing something on the chromecast in the living room it will dim the lights to 35% and then when we stop it will put them back on at 100% This is something that was not possible with smartthings.
Another automation I have slowly fades in bedroom (and my kids bedrooms) lights on over 30 mins (for me and 5 for the kids) using a python script (its not natively supported by the lights I have)
This makes use of a condition and the Workday sensor which takes into account holidays and weekends to know when it is a normal work day (it doesn't account for vacations) and I need to actually wake up
And the actual python script
So it takes as input the entity_id (all devices in HA have an entity_id to define them) (light.master_bedroom in this case), a start / end % (5/100), how much to increase each time (1 % in this case), and how often to increase (18 for this one)
So that is the basic config / automations done and at this point I've replicated everything that Smartthings was doing (and then some extra) so I still need to do the UI aspect (again via text files, I've been the only one looking at it the others in the house just want it to work) but HA lets you have multiple UIs and I've seen a few examples I'll probably be going over again to get ideas.
Along with HA I also have plans to go making some arduino sensors which talk over radio (nrf24L01) and to a controller and then over MQTT so I can get more data about my house and whats going on in it. I also want to get some raspberry pi zeros and use those for room presence detection. This is all in addition to buying more lights and motions sensors to go along with them.
Anyways this is getting long enough already so I'll end it here but if anyone has any questions or comments I'd gladly answer them the best I can.
So to start these are the definitions that I use
Smart Device = any device that allows remote control of any type including voice via Alexa/Google Home, This is what most people think when someone says smart home.
Smart House = uses sensors & automation to control Smart Devices
WAF = Wife Approval Factor = How Non-techies approve of the smart home
Also my current devices make use of the following protocols Wifi / Z-wave / Zigbee / MQTT
Some history I got started on the smart home thing last christmas (2017) when my wife bought me a Smartthings hub and 4 sengled white light bulbs. I expanded this to a couple motion sensors to control the lights and then quickly realized that while Smartthings is good for simple things if you want to do more complex things or use multiple conditions to trigger things you need to use their webcore platform which shifts all the logic to the cloud and honestly I'd rather have my house controlled from my house. So this recent August (2018) I built an actual server for various things (plex / nextcloud / NAS) and bought a zwave & zigbee usb stick so I could eventually replace the Smartthings hub. The server is running Unraid for the base OS and everything runs in docker containers so it should be runnable anywhere.
Anyways I decided to use Home Assistant (HA from now on) as the brains for my house. It is an open sourced python software that uses Yaml files (text files with formatting requirements) to configure everything and has components to interface with pretty much any product you could want. Bonus points every single thing runs locally on the server (There is a cloud component but the logic still runs locally). Since everything runs on text files I can use Github to store my config in.
So to get into my full set up this is the hardware I currently have
Smart Plugs
3 Wemo mini plugs (wifi)
3 Gosund (wifi) (not in use yet)
Lights
4 Sengled Light bulbs (Zigbee)
Switches
2 Zooz dimmer switches (Z-wave)
Sensors
2 Bosch Motion sensors (Zigbee),
2 Zooz 4-in-1 sensors (Z-wave),
2 smartthings door sensor (Zigbee)
Speakers
Sonos speakers (wifi)
Media Players
3 Chromecast (wifi),
Samsung Smart TV (wifi)
Other
Xiaomi Smart Cube (Zigbee),
SmartThings Hub (Wired),
Tomato Router (Wired),
3 Pixel Phones (Wifi),
1 Amazon Echo Dot (Wifi)
On top of the hardware I have a few notable software pieces in use. I'm using Owntracks which sends gps from the pixel phones back to a secured MQTT broker running on my server which then sends to an unsecured internal only MQTT server (the smartthings bridge doesn't support authentication) which HA then reads. I use MariaDB to store all the data from HA (purging at 5 days old) I also have a few other software tied into HA that I don't do anything with (I'm still in get all the data setup mode ) Plex, Tautulli (plex monitor), qBittorrent, Transmission.
Also have a bunch of components not currently being used (same logic not sure what I'll end up wanting), ISS (let me know when ISS is overhead), Space Launch (Lets me know when the next launch is), Moon/Sun/Season (Moon Phase/Sun rise&set/Season), YR (Weather from Norwegian Meteorological Institute), Darksky (weather from darksky)
So I do still use the Smartthing Hub but I found a piece of software that takes events from Smartthings and sends it via MQTT to HA and then sends things from HA back to Smartthings. This is due to the fact that zigbee IMO sucks as a protocol since it is open for anyone to modify you end up with each developer making a slightly different version so getting them to talk to each other isn't the easiest and while the light bulbs should in theory work directly from what I've been able to find online the motion sensors don't currently so I just left them all on the Smartthings hub for now.
Since they are somewhat odd these are the setups for my living room lights coming from smart things
Code:
---
#
# MQTT virtual light from smartthings
#
platform: mqtt
name: "Living Room"
unique_id: "Living Room"
state_topic: "smartthings/Living Room/switch/state"
command_topic: "smartthings/Living Room/switch/cmd"
brightness_state_topic: "smartthings/Living Room/level/state"
brightness_command_topic: "smartthings/Living Room/level/cmd"
brightness_scale: 100
payload_on: "on"
payload_off: "off"
retain: true
So smartthings post on the state topics and then HA posts on the command topics, HA uses a brightness scale of 0-255 while Smartthings uses 0-100 so need to set that
When I was just starting to set this up I luckily found someone else who had set up the files in a way that make sense and split them up so each file does 1 thing, since the standard way of doing the config for HA is to just use 1 or possible 2 files. Since I didn't have many files done yet I converted and it is so much neater. HA does have a nice way of storing "secrets" in a separate file that you can then reference which is useful when posting them online or getting debugging help so there are several times in the files where I have !secret X that means it will go to the file and get that key and replace it.
Anyways I'm not going to post all of my setup files here but I'll post some of my automations.
Code:
---
#
# Code to dim the living room lights when I start playing a video
#
id: Wacth the Movies
alias: "Media player playing"
initial_state: 'off'
trigger:
- platform: state
entity_id: media_player.living_room_tv
to: 'playing'
from: 'off'
- platform: state
entity_id: media_player.living_room_tv
to: 'playing'
from: 'paused'
- platform: state
entity_id: media_player.living_room_tv
to: 'playing'
from: 'idle'
action:
service: scene.turn_on
entity_id: scene.movie_mode_on
---
#
# Code to return the living room lights to normal after playing a video
#
id: The player Stopped
alias: "Media player paused/stopped"
initial_state: 'off'
trigger:
- platform: state
entity_id: media_player.living_room_tv
from: 'playing'
to: 'idle'
- platform: state
entity_id: media_player.living_room_tv
from: 'playing'
to: 'paused'
- platform: state
entity_id: media_player.living_room_tv
from: 'playing'
to: 'off'
action:
service: scene.turn_on
entity_id: scene.movie_mode_off
Code:
---
#
# Scene to dim the lights when watching movies
#
name: Movie Mode On
entities:
light.living_room:
state: on
brightness_pct: 35
---
#
# Scene to return the lights to normal
#
name: Movie Mode Off
entities:
light.living_room:
state: on
brightness_pct: 100
Another automation I have slowly fades in bedroom (and my kids bedrooms) lights on over 30 mins (for me and 5 for the kids) using a python script (its not natively supported by the lights I have)
This makes use of a condition and the Workday sensor which takes into account holidays and weekends to know when it is a normal work day (it doesn't account for vacations) and I need to actually wake up
Code:
---
#
# Fade in the master bedroom lights over 15 mins
#
id: Master Bedroom Wake up
alias: Master Bedroom Light Fade In
trigger:
- platform: time
at: "05:30:00"
condition:
condition: state
entity_id: 'binary_sensor.workday_sensor'
state: 'On'
action:
- service: python_script.fade_in_light
data:
entity_id: light.master_bedroom
delay_in_sec: 18
start_level_pct: 5
end_level_pct: 100
step_in_level_pct: 1
And the actual python script
Code:
entity_id = data.get('entity_id')
sleep_delay = int(data.get('delay_in_sec'))
start_level_pct = int(data.get('start_level_pct'))
end_level_pct = int(data.get('end_level_pct'))
step_pct = int(data.get('step_in_level_pct'))
start_level = int(255*start_level_pct/100)
end_level = int(255*end_level_pct/100)
step = int(255*step_pct/100)
new_level = start_level
while new_level < end_level :
states = hass.states.get(entity_id)
current_level = states.attributes.get('brightness') or 0
if (current_level > new_level) :
logger.info('Exiting Fade In')
break;
else :
logger.info('Setting brightness of ' + str(entity_id) + ' from ' + str(current_level) + ' to ' + str(new_level))
data = { "entity_id" : entity_id, "state" : on, "brightness" : new_level }
hass.services.call('light', 'turn_on', data)
new_level = new_level + step
time.sleep(sleep_delay)
So it takes as input the entity_id (all devices in HA have an entity_id to define them) (light.master_bedroom in this case), a start / end % (5/100), how much to increase each time (1 % in this case), and how often to increase (18 for this one)
So that is the basic config / automations done and at this point I've replicated everything that Smartthings was doing (and then some extra) so I still need to do the UI aspect (again via text files, I've been the only one looking at it the others in the house just want it to work) but HA lets you have multiple UIs and I've seen a few examples I'll probably be going over again to get ideas.
Along with HA I also have plans to go making some arduino sensors which talk over radio (nrf24L01) and to a controller and then over MQTT so I can get more data about my house and whats going on in it. I also want to get some raspberry pi zeros and use those for room presence detection. This is all in addition to buying more lights and motions sensors to go along with them.
Anyways this is getting long enough already so I'll end it here but if anyone has any questions or comments I'd gladly answer them the best I can.