├── images ├── aeotec.jpg ├── sonoff.jpg ├── state1.png ├── state2.png ├── xiaomi.jpg ├── HA_logo.jpeg ├── HA_update.png ├── node-red.png ├── wemosD1.jpg ├── amazondash.jpg ├── floorplan1.jpg ├── floorplan2.png ├── floorplan3.jpg ├── HA_dashboard.png ├── frontend_dark.jpg ├── frontend_full.png ├── frontend_map.png ├── state_darksky.png ├── frontend_lights.png ├── frontend_mobile.png ├── frontend_travel.png ├── frontend_weather.png └── frontend_switches.png └── README.md /images/aeotec.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/aeotec.jpg -------------------------------------------------------------------------------- /images/sonoff.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/sonoff.jpg -------------------------------------------------------------------------------- /images/state1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/state1.png -------------------------------------------------------------------------------- /images/state2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/state2.png -------------------------------------------------------------------------------- /images/xiaomi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/xiaomi.jpg -------------------------------------------------------------------------------- /images/HA_logo.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/HA_logo.jpeg -------------------------------------------------------------------------------- /images/HA_update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/HA_update.png -------------------------------------------------------------------------------- /images/node-red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/node-red.png -------------------------------------------------------------------------------- /images/wemosD1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/wemosD1.jpg -------------------------------------------------------------------------------- /images/amazondash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/amazondash.jpg -------------------------------------------------------------------------------- /images/floorplan1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/floorplan1.jpg -------------------------------------------------------------------------------- /images/floorplan2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/floorplan2.png -------------------------------------------------------------------------------- /images/floorplan3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/floorplan3.jpg -------------------------------------------------------------------------------- /images/HA_dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/HA_dashboard.png -------------------------------------------------------------------------------- /images/frontend_dark.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/frontend_dark.jpg -------------------------------------------------------------------------------- /images/frontend_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/frontend_full.png -------------------------------------------------------------------------------- /images/frontend_map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/frontend_map.png -------------------------------------------------------------------------------- /images/state_darksky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/state_darksky.png -------------------------------------------------------------------------------- /images/frontend_lights.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/frontend_lights.png -------------------------------------------------------------------------------- /images/frontend_mobile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/frontend_mobile.png -------------------------------------------------------------------------------- /images/frontend_travel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/frontend_travel.png -------------------------------------------------------------------------------- /images/frontend_weather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/frontend_weather.png -------------------------------------------------------------------------------- /images/frontend_switches.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnaudLoos/HomeAssistant-Presentation/HEAD/images/frontend_switches.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | **Home Assistant** is an open-source home automation platform written in Python ([Github](https://github.com/home-assistant/home-assistant)) on the backend, and [Polymer](https://www.polymer-project.org/) on the frontend. When combined with hardware it makes an open hub for managing the state of home automation devices and triggering automations. 6 | 7 | [Presented on February 13, 2018 @ Code & Supply, Pittsburgh](https://www.youtube.com/watch?v=jbQftoWDe8o) 8 | 9 | [Documentation](https://home-assistant.io/docs/) 10 | [Installation](https://home-assistant.io/docs/installation/) 11 | [Components](https://home-assistant.io/components/) 12 | [Demo](https://home-assistant.io/demo/) 13 | 14 | 15 | 16 | 17 | 18 | 19 | #### HA Advantages: 20 | 21 | * Speed of development - updates generally released bi-weekly 22 | * Over 1,000 integrations 23 | * Runs on Raspberry Pi, Synology NAS, or any computer running python 24 | * Not dependent on cloud services (many components), all data stored locally in sqllite DB 25 | * Ability to use disparate hardware 26 | * Can work in conjunction with hubs from other manufacturers. Add HA in front of Smartthings 27 | * Integrates with Amazon Echo, Google Assistant, and HomeKit for voice 28 | * Helpful community - active [Discord](https://discord.gg/c5DvZ4e) channel and [Forum](https://community.home-assistant.io/) 29 | * [iOS app](https://home-assistant.io/docs/ecosystem/ios/), or easily accessible through a responsive [web interface](https://home-assistant.io/docs/frontend/mobile/) 30 | 31 |
32 | 33 | > In many cases, the adoption of the technology [IoT] is being driven 34 | by businesses eager to gain valuable data from citizens, with 35 | little concern for their privacy or the protection of that data. 36 | All of the analysts consulted pointed out that personal data 37 | from the connected home will often be bought and sold 38 | with consumers largely remaining oblivious to potential 39 | implications. 40 | [Internet of Things: Pinning down the IoT](https://fsecureconsumer.files.wordpress.com/2018/01/f-secure_pinning-down-the-iot_final.pdf) 41 | 42 |
43 | 44 | >Blink disables support for Smartthings in preparation for sale to Amazon 45 | [Hacker News](https://news.ycombinator.com/item?id=15989302) 46 | 47 |
48 | 49 | >Overall, my takeaway is that the smart home is going to create a new stream of information about our daily lives that will be used to further profile and target us. The number of devices alone that are detected chattering away will be used to determine our socioeconomic status. Our homes could become like internet browsers, with unique digital fingerprints, that will be mined for profit just like our daily Web surfing is. If you have a smart home, it’s open house on your data. 50 | [The House that Spied on Me](https://gizmodo.com/the-house-that-spied-on-me-1822429852) 51 | 52 | #### Competitors: 53 | 54 | * Samsung Smartthings 55 | * Wink 2 56 | * Apple Homepod 57 | * Belkin Wemo 58 | * Amazon Echo 59 | * Google Home 60 | * OpenSource: OpenHAB, Domoticz 61 | 62 | 63 | ## Home Automation Protocols 64 | 65 | #### [Z-Wave](https://home-assistant.io/docs/z-wave/installation/) 66 | Mesh networking with master-slave model 67 | Up to 232 devices 68 | Range up to 100m, 200m when meshed (adding more devices helps with communication) 69 | Supports AES encryption 70 | Low-latency transmission, up to 100 kbit/s 71 | Nodes can be up to 30m apart, transmissions can hop nodes up to 4 times (adds delay) 72 | Operates on 908MHz band, no interference from 2.4GHz (ISM) devices 73 | Has interoperability layer to ensure all Z-Wave hardware and software work together 74 | [Z-Wave Plus](https://inovelli.com/z-wave-home-automation/z-wave-plus/) - Fifth gen Z-Wave, improved battery life(~50%), range(167m instead of 100m), bandwidth(250%), OTA firmware updates. Need primary controller to be Z-Wave plus for full benefits 75 | In HA, Z-Wave support is provided by python-openzwave 76 | [Additional hints on optimizing a Z-Wave network](https://drzwave.blog/2017/01/20/seven-habits-of-highly-effective-z-wave-networks-for-consumers/) 77 | 78 | #### Zigbee 79 | Also a mesh network topology 80 | No guaranteed interoperability between devices of different manufacturers 81 | Data transmission at max 250 kbit/s 82 | 10m to 20m range 83 | Operates in 2.4 GHz ISM band 84 | Generally cheaper than Z-Wave 85 | 86 | #### 433MHz or 315MHz RF 87 | Good for transmitting one way - doorbells, fans, weather stations 88 | Sonoff switches are available in RF versions 89 | [Broadlink RM Pro](http://www.ibroadlink.com/rm/) - controller 90 | 91 | #### Wifi devices 92 | Easiest to configure 93 | Consumes a lot of power relative to other protocols 94 | 95 | #### IR devices 96 | Can control anything that accepts a signal from a remote (tv, amplifier, etc) 97 | [Broadlink RM Mini3](http://www.ibroadlink.com/rmMini3/) 98 | 99 | #### Bluetooth 100 | Good up to 10m 101 | 102 | 103 | ## [Installation](https://home-assistant.io/docs/installation/) 104 | 105 | Installation of Home Assistant on a Raspberry Pi is accomplished by flashing the micro SD card with a downloaded image. 106 | 107 | ***After first boot an installer will download the latest HA build and install in the background.*** 108 | 109 | Home Assistant ***is not*** installed by flashing the SD card. On first boot make sure your device has an active Internet connection otherwise the download and installation of HA will fail. Either plug in an ethernet cable or configure wireless settings before booting. It takes around 15 minutes to complete the installation, and afterwards the Home Assistant interface will be available at ```http://:8123``` 110 | 111 | ### [Hassbian](https://home-assistant.io/docs/installation/hassbian/) 112 | Install HomeAssistant core on a full Debian OS. No add-on packages available natively, but includes a tool called [hassbian-config](https://home-assistant.io/docs/installation/hassbian/customization/) to aid with the installation of some common packages. 113 | 114 | Has the benefit and/or drawback of running a full OS. This is beneficial if you want to run additional programs on the machine which are not integrated into the HA ecosystem. 115 | 116 | Upgrades are accomplished through a pip3 package update. 117 | 118 | ``` 119 | $ sudo su -s /bin/bash homeassistant 120 | $ source /srv/homeassistant/bin/activate 121 | $ pip3 install --upgrade homeassistant 122 | ``` 123 | 124 | 125 | ### [Hass.io](https://home-assistant.io/hassio/) 126 | HomeAssistant running in a Docker container on ResinOS (soon to be replaced by a custom [buildroot OS](https://buildroot.org/) ) 127 | 128 | 129 | 130 | * Simple built-in updater 131 | * No need to manage underlying OS 132 | * Integrated app store for simple add-on installation and updating 133 | * Ability to integrate [community add-ons](https://github.com/hassio-addons) (web terminal, homebridge, pi-hole) and [third-party repositories](https://home-assistant.io/hassio/installing_third_party_addons/) 134 | 135 | ## Home Assistant Basics 136 | Home Assistant organizes all the components that comprise your home automation network. This includes information pulled from the Internet (weather forecast, traffic cam image, bitcoin price), the state of a switch or light (on/off), presence detection (home/away), and more. 137 | 138 | For each [component](https://home-assistant.io/components/) that you want to use in Home Assistant, you add an entry to your ```configuration.yaml``` file and specify its settings. 139 | 140 | The configuration file is written in [YAML](https://home-assistant.io/docs/configuration/yaml/). YAML is a markup language that utilizes block collections of key:value pairs. It is heavily dependant on indentation and if there is an error in your configuration file it is likely due to incorrect indentation. You can check your config with an [online YAML parser](https://yaml-online-parser.appspot.com/). 141 | 142 | It is possible to edit YAML files from within Home Assistant using the [HASS Configuration UI](https://home-assistant.io/docs/ecosystem/hass-configurator/) 143 | 144 | 145 | ```yaml 146 | homeassistant: 147 | name: Pittsburgh 148 | unit_system: imperial 149 | time_zone: America/New_York 150 | latitude: !secret latitude 151 | longitude: !secret longitude 152 | elevation: 330 153 | 154 | frontend: 155 | logbook: 156 | exclude: 157 | entities: 158 | - sensor.dark_sky_summary 159 | - sensor.dark_sky_daily_high_temperature 160 | - sensor.dark_sky_daily_low_temperature 161 | discovery: 162 | updater: 163 | sun: 164 | map: 165 | config: 166 | history: 167 | recorder: 168 | purge_interval: 2 169 | purge_keep_days: 7 170 | logger: 171 | default: warning 172 | http: 173 | api_password: my_password 174 | 175 | light: 176 | - platform: osramlightify 177 | host: 192.168.1.5 178 | 179 | sensor: 180 | - platform: darksky 181 | api_key: !secret darksky_api 182 | units: auto 183 | monitored_conditions: 184 | - summary 185 | - temperature 186 | - temperature_max 187 | - temperature_min 188 | - precip_type 189 | - precip_probability 190 | ``` 191 | 192 | Each of these items is an entity with a state value and can be seen on the States page in [Developer Tools](https://home-assistant.io/docs/tools/dev-tools/) in its raw form 193 | 194 | 195 | 196 | and displayed on the frontend for easy viewing. 197 | 198 | 199 | 200 | Additional sensors can be added by defining the new component in your ```configuration.yaml``` file. The bitcoin price sensor can be added with the following: 201 | 202 | 203 | ```yaml 204 | - platform: bitcoin 205 | display_options: 206 | - market_price_usd 207 | ``` 208 | 209 | Adding a switch component like a power plug or light will automatically cause an entity with a toggle switch to be defined in the frontend, allowing you to turn the switch on or off manually. 210 | 211 | 212 | 213 |
214 | 215 | ### The power of home automation however comes from the automations! 216 | 217 | 218 | Automations in Home Assistant are defined as trigger, condition, action. 219 | 220 | ``` 221 | (trigger) When I arrive home 222 | (condition) and it is after sunset 223 | (action) Turn the lights in the living room on 224 | ``` 225 | With trigger and action being mandatory and condition being optional. 226 | 227 | A trigger will look at events happening in the system while a condition only looks at how the system looks right now. A trigger can observe that a switch is being turned on. A condition can only see if a switch is currently on or off. 228 | 229 | An example automation to turn on a porch light at sunset. 230 | The ```id``` attribute is necessary only if you manage automations from within Home Assistant using the [Automation Editor](https://home-assistant.io/docs/automation/editor/), which I don't recommend. 231 | 232 | ```yaml 233 | - id: '0001' 234 | alias: 'Outside light ON at sunset' 235 | hide_entity: true 236 | trigger: 237 | - platform: state 238 | entity_id: sun.sun 239 | from: above_horizon 240 | to: below_horizon 241 | action: 242 | - service: light.turn_on 243 | entity_id: light.front_porch 244 | ``` 245 | Send me a text message (using the twilio component) if the water detector by my hot water tank registers water. 246 | 247 | ``` 248 | - id: '0002' 249 | alias: 'Notify of water heater leak' 250 | hide_entity: true 251 | trigger: 252 | - platform: state 253 | entity_id: sensor.everspring_st812_flood_detector_flood 254 | from: '0' 255 | to: '255' 256 | action: 257 | service: notify.twilio 258 | data: 259 | message: 'Water detected by water heater!' 260 | target: 261 | - +1412xxxxxxx 262 | ``` 263 | My security alarm. If my hall motion detector registers motion, and nobody is home, and I have security enabled, then send me a text. 264 | 265 | ``` 266 | - id: '0003' 267 | alias: 'Security - Motion detected' 268 | hide_entity: true 269 | trigger: 270 | - platform: state 271 | entity_id: binary_sensor.ecolink_motion_sensor_sensor 272 | from: 'off' 273 | to: 'on' 274 | condition: 275 | - condition: state 276 | entity_id: group.all_devices 277 | state: 'not_home' 278 | - condition: state 279 | entity_id: input_boolean.enable_security 280 | state: 'on' 281 | action: 282 | service: notify.twilio 283 | data: 284 | message: 'Movement detected!' 285 | target: 286 | - +1412xxxxxxx 287 | ``` 288 | 289 | In the above example I check the state of an ```input_boolean``` named ```enable_security``` and only execute the action if the state is ```ON``` 290 | 291 | This is a toggle switch on the frontend that I can manually set, or set through a different automation. 292 | 293 | 294 | 295 | How do I get this toggle switch? I create it. 296 | 297 | ```yaml 298 | input_boolean: 299 | enable_security: 300 | name: Alarm Enabled 301 | icon: mdi:shield-outline 302 | initial: on 303 | ``` 304 | 305 | I define different ```input_boolean``` and use them as conditionals to ensure my automations only fire exactly when I want them to. 306 | 307 | ### Scripts and Scenes 308 | 309 | If the action you wish your automation to perform is simple, like turning on a light, then you can call the service ```light.turn_on``` directly and pass the ```entity_id```. If, however, you wish to trigger a more complex action then it may be necessary for your action to call ```script.turn_on``` or ```scene.turn_on``` with the ```entity_id``` being the name of the script or scene to execute. 310 | 311 | ***[Scripts](https://home-assistant.io/docs/scripts/)*** are a sequence of actions that Home Assistant will execute. 312 | 313 | ```yaml 314 | script: 315 | example_script: 316 | sequence: 317 | - service: light.turn_on 318 | entity_id: light.kitchen 319 | - service: light.turn_on 320 | entity_id: light.bedroom 321 | - service: notify.notify 322 | data: 323 | message: 'Lights are on!' 324 | ``` 325 | 326 | ***[Scenes](https://home-assistant.io/components/scene/)*** capture the states you want certain entities to be. 327 | 328 | ```yaml 329 | scene: 330 | - name: Romantic 331 | entities: 332 | light.tv_back_light: on 333 | light.ceiling: 334 | state: on 335 | xy_color: [0.33, 0.66] 336 | brightness: 200 337 | - name: Movies 338 | entities: 339 | light.tv_back_light: 340 | state: on 341 | brightness: 100 342 | light.ceiling: off 343 | media_player.sony_bravia_tv: 344 | source: HDMI 1 345 | ``` 346 | 347 | An add-on project named [scenegen](https://home-assistant.io/docs/ecosystem/scenegen/) can be used to create scenes by reading the current state of devices and outputting a corresponding scene. 348 | 349 | ### Additional Config 350 | 351 | ***[Splitting up the configuration](https://home-assistant.io/docs/configuration/splitting_configuration/)*** 352 | 353 | You can move sections of your ```configuration.yaml``` to separate files and import them like so: 354 | 355 | ``` 356 | group: !include groups.yaml 357 | automation: !include automations.yaml 358 | scene: !include scenes.yaml 359 | input_boolean: !include input_boolean.yaml 360 | script: !include scripts.yaml 361 | ``` 362 | 363 | ***Grouping devices*** 364 | 365 | Devices can be members of multiple groups. Some groups will be used to display devices together on the frontend. Other groups can be hidden (so they're not displayed on the frontend) and called within automations and scripts. 366 | 367 | ``` 368 | Lights: 369 | - light.front_door 370 | - light.hallupper 371 | - light.halllower 372 | - light.living_room 373 | - light.bedroom 374 | Inside_Lights: 375 | - light.halllower 376 | - light.hallupper 377 | - light.living_room 378 | - light.bedroom 379 | Downstairs_Lights: 380 | - light.halllower 381 | - light.living_room 382 | Upstairs_Lights: 383 | - light.bedroom 384 | - light.hallupper 385 | ``` 386 | ***[Customizing](https://home-assistant.io/docs/configuration/customizing-devices/)*** 387 | 388 | Rename entities, hide entities, add [icons](https://materialdesignicons.com/), and more. 389 | 390 | ``` 391 | sensor.dark_sky_summary: 392 | friendly_name: Conditions 393 | sensor.dark_sky_temperature: 394 | friendly_name: Temp 395 | sensor.dark_sky_daily_high_temperature: 396 | friendly_name: Daily High 397 | sensor.dark_sky_daily_low_temperature: 398 | friendly_name: Daily Low 399 | sensor.dark_sky_precip: 400 | friendly_name: Precipitation 401 | sensor.market_price: 402 | friendly_name: BTC 403 | icon: mdi:currency-btc 404 | binary_sensor.ecolink_doorwindow_sensor_sensor: 405 | hidden: true 406 | binary_sensor.ecolink_doorwindow_sensor_sensor_2: 407 | hidden: true 408 | binary_sensor.ecolink_motion_sensor_sensor: 409 | hidden: true 410 | ``` 411 | 412 | 413 | ***[Device Tracking](https://home-assistant.io/components/device_tracker/)*** 414 | 415 | Home Assistant can trigger automations based on your location and show your location on its map. 416 | 417 | Location tracking can be done in many different ways, with varying precision: 418 | 419 | * iOS App 420 | * iCloud 421 | * Owntracks 422 | * NMap scan 423 | * Many others 424 | 425 | Once the first device is discovered HA will create a file named ```known_devices.yaml``` where it will track all the devices it knows about. If you want to rename a device, add a picture, or stop tracking a device, make the change in this file. For each tracked device HA will create a ```device_tracker.device_name``` entity which can be displayed on the frontend. 426 | 427 | You can also define zones such that events will trigger when you enter or leave the zone. 428 | 429 | Define a zone like so: 430 | 431 | ```yaml 432 | - name: Code_&_Supply 433 | latitude: 40.46001 434 | longitude: -79.93072 435 | radius: 150 436 | icon: mdi:desktop-classic 437 | ``` 438 | 439 | 440 | 441 | You even have the option of triggering events based on the direction of travel with the [proximity](https://home-assistant.io/components/proximity/) component. You can have the thermostat raise the temperature as you approach home. 442 | 443 | For more precise location detection Owntracks supports the use of iBeacons. You can [turn your Raspberry Pi into an iBeacon](https://andrewmemory.wordpress.com/2016/03/29/turning-a-raspberry-pi-3-into-an-ibeacon/) with a large radius to trigger automations reliably when arriving in your home zone, or place iBeacons in each room of your house to trigger presence based actions at the room level. 444 | 445 | ## [Add-ons](https://home-assistant.io/addons/) 446 | 447 | 448 | ### SSH, Samba, Git 449 | Add-ons for updating configurations: 450 | 451 | * ***Samba*** - Manage Home Assistant files exposed over an SMB share 452 | * ***Git*** - Load and update configuration files for Home Assistant from a Git repository 453 | * ***SSH*** - Enables easy ssh access for controlling the host 454 | * [hass](https://home-assistant.io/docs/tools/hass/) - command line control over Hass.io (reload, start/stop services, check config) 455 | * [hassctl](https://github.com/dale3h/hassctl) add-on for controlling hassbian 456 | * Can also control through GUI 457 | 458 | ### Duck DNS 459 | Dynamic DNS to access Home Assistant on the Internet. 460 | 461 | ***Secure your installation if it is publicly exposed!*** 462 | 463 | Consider not publicly exposing your Home Assistant installation to the world and instead keeping it secure inside your network. Various access methods such as OpenVPN, [TOR](https://home-assistant.io/docs/ecosystem/tor/), or [ZeroTier](https://www.zerotier.com/) exist which allow for more secure access. Setup instructions for ZeroTier on Raspberry Pi can be found [here](https://iamkelv.in/blog/2017/06/zerotier.html). 464 | 465 | ### Let's Encrypt 466 | Easily and automatically add a free SSL certificate 467 | 468 | ### Mosquitto 469 | Enables a local MQTT broker. 470 | 471 | [MQTT](https://home-assistant.io/components/mqtt/) is a machine-to-machine or “Internet of Things” connectivity protocol on top of TCP/IP. It allows extremely lightweight publish/subscribe messaging transport. 472 | Network devices can either publish simple information to an MQTT topic or subscribe to a topic to consume the data published there by another device. 473 | The main advantage of MQTT is that it is a common protocol in the IoT space and allows easy sharing of information across devices that would otherwise be unable to communicate with each other. 474 | 475 | Example: I can build a simple [temperature and humidity sensor](https://home-assistant.io/blog/2015/10/11/measure-temperature-with-esp8266-and-report-to-mqtt/) utilizing cheap microcontrollers like an [ESP8266](https://www.sparkfun.com/products/13678) or a [Wemos D1 mini](https://wiki.wemos.cc/products:d1:d1_mini). These controllers will read the temperature from an attached sensor and have the ability to communicate over Wi-Fi. But how do we get these values into Home Assistant? MQTT. There are MQTT libraries available for many platforms, including Arduino. You configure your sensor with the IP of your MQTT broker as well as the topic you wish to publish to. Topics and sub-topics can be created on the fly. So for instance, if I place my new sensor in my bedroom I can tell it to publish to the ```home/temp/bedroom/master/``` topic or if I wish to organize it differently I could instead publish to ```/home/bedroom/master/temp/```. 476 | 477 | Then, after I add the MQTT component to my configuration, 478 | 479 | ``` 480 | mqtt: 481 | broker: 127.0.0.1 482 | port: 1883 483 | client_id: home-assistant-1 484 | keepalive: 60 485 | username: !secret mqtt_user 486 | password: !secret mqtt_pass 487 | ``` 488 | 489 | I define a sensor to read that particular value. 490 | 491 | ```yaml 492 | - platform: mqtt 493 | name: "Bedroom Temp" 494 | state_topic: "home/bedroom/master/temp" 495 | unit_of_measurement: "ºF" 496 | ``` 497 | And now inside Home Assistant I have a component named `sensor.bedroom_temp` with a value being updated as the MQTT topic gets updated. 498 | 499 | ***Pro tip:*** Home Assistant just pulls data from the MQTT topics you tell it to. If the information HA is disaplying seems incorrect or inconsistent it could be that the data being sent to Mosquitto is incorrect and not that it's an issue with HA. To troubleshoot these issues it can be beneficial to see the data being fed into Mosquitto from your sensors in real-time. To accomplish this I use the ```mosquitto_sub``` command with verbose output to subscribe to the ```#``` (all) topic. Omit ```--cafile``` if not using certificates. 500 | 501 | ```mosquitto_sub -t "#" -v --cafile /etc/mosquitto/certs/ca.crt -p 8883 -u -P ``` 502 | 503 | ### [TOR](https://home-assistant.io/docs/ecosystem/tor/) 504 | The ability to access your frontend through an onion address on the TOR network. With this enabled, you do not need to open your firewall ports or setup HTTPS to enable secure remote access. 505 | 506 | 507 | 508 | ## Examples 509 | 510 | Additional security automations. 511 | 512 | ```yaml 513 | - id: '0005' 514 | alias: 'Security - Sliding Door opened while in bed' 515 | hide_entity: true 516 | trigger: 517 | - platform: state 518 | entity_id: sensor.ecolink_binary 519 | from: 'Closed' 520 | to: 'Open' 521 | condition: 522 | - condition: state 523 | entity_id: input_boolean.in_bed 524 | state: 'on' 525 | - condition: state 526 | entity_id: input_boolean.enable_security 527 | state: 'on' 528 | action: 529 | service: script.turn_on 530 | entity_id: script.sound_the_alarm 531 | ``` 532 | 533 | Script to sound the alarm. 534 | 535 | ```yaml 536 | sound_the_alarm: 537 | alias: Alarm Activated 538 | sequence: 539 | - service: light.turn_on 540 | entity_id: group.inside_lights 541 | - service: notify.twilio 542 | data: 543 | message: "Alarm activated!!" 544 | target: 545 | - +1412xxxxxxx 546 | - service: tts.google_say 547 | entity_id: media_player.chromecast 548 | data: 549 | message: "Alarm alarm alarm alarm alarm alarm" 550 | ``` 551 | 552 | [Dasher](https://github.com/maddox/dasher) is a simple way to bridge your Amazon Dash buttons to HTTP services. It is a Node application that listens on the network for Amazon Dash button presses and sends a post command to the Home Assistant REST API. I have one by my bed that I press when I get up in the morning and when I go to bed at night. 553 | 554 | ***UPDATE:*** Dasher appears to have fallen out of date and no longer correctly runs on a Raspberry Pi. The [Amazon-Dash](https://github.com/nekmo/amazon-dash) project appears to be a working implementation. 555 | 556 |

557 | 558 |

559 | 560 | Amazon Dash buttons can be good, cheap, battery powered buttons. You need to be an Amazon Prime member however to configure it. 561 | 562 | 563 | Only one of the following automations will kick off depending on the time of day I press the button. 564 | 565 | ```yaml 566 | - id: '0006' 567 | alias: 'Bedroom Dash Button - Good Morning' 568 | hide_entity: true 569 | trigger: 570 | - platform: state 571 | entity_id: input_boolean.dash_bedroom 572 | from: 'off' 573 | to: 'on' 574 | condition: 575 | - condition: time 576 | after: '05:00:00' 577 | before: '12:00:00' 578 | action: 579 | service: script.turn_on 580 | entity_id: script.good_morning 581 | 582 | - id: '0007' 583 | alias: 'Bedroom Dash Button - Good Night' 584 | hide_entity: True 585 | trigger: 586 | - platform: state 587 | entity_id: input_boolean.dash_bedroom 588 | from: 'off' 589 | to: 'on' 590 | condition: 591 | - condition: time 592 | after: '17:00:00' 593 | before: '04:00:00' 594 | action: 595 | service: script.turn_on 596 | entity_id: script.good_night 597 | ``` 598 | 599 | script.good_morning 600 | 601 | ``` 602 | good_morning: 603 | alias: "Trigger Morning routine" 604 | sequence: 605 | - service: scene.turn_on 606 | entity_id: scene.good_morning 607 | - service: input_boolean.turn_off 608 | entity_id: input_boolean.dash_bedroom 609 | - service: input_boolean.turn_off 610 | entity_id: input_boolean.in_bed 611 | ``` 612 | 613 | scene.good_morning 614 | 615 | ``` 616 | - name: Good Morning 617 | entities: 618 | light.bedroom: 619 | state: on 620 | brightness_pct: 70 621 | color_temp: 400 622 | transition: 30 623 | light.living_room: 624 | state: on 625 | light.halllower: 626 | state: on 627 | ``` 628 | 629 | ## Openness and ability to extend 630 | 631 | ESP8266, Arduino based devices, and many others can communicate via MQTT 632 | 633 | 634 | 635 | There exists an [HA component](https://home-assistant.io/components/thethingsnetwork/) for [The Things Network](https://www.thethingsnetwork.org/) to tie in to a global IoT network based on LoRaWAN. LoRaWAN hubs cover an area 5 - 15 km to provide wide-area network coverage for low-bandwidth sensors and allow querying of these sensors world-wide. Home Assistant could, for example, read from all the LoRaWAN sensors connected to a private hub monitoring a 30 acre farm. 636 | 637 | [Graphing with Grafana and InfluxDB](https://philhawthorne.com/getting-started-with-grafana-influxdb-for-home-assistant/) - display graphs and dashboards of time series data 638 | 639 | And APIs to integrate with everything. 640 | 641 | * [Python API](https://dev-docs.home-assistant.io/en/dev/) 642 | * [Websocket API](https://home-assistant.io/developers/websocket_api/) 643 | * [REST API](https://home-assistant.io/developers/rest_api/) 644 | * [Python REST API](https://home-assistant.io/developers/python_api/) 645 | 646 | #### Additional examples from the community 647 | 648 | >I replaced a mechanical controller on my whole house wood burner with an Arduino using a thermocouple to read the temperatures in the plenum. 649 | Community member ericleejoe 650 | 651 |
652 | 653 | >I have an electric water heater, so I control the time when it’s on/off optimizing the cost based on my habits (including different pricing for the electricity during the day). 654 | Community member ardeus 655 | 656 | ## Advanced Config 657 | ***[Templating](https://home-assistant.io/docs/configuration/templating/)*** 658 | 659 | Early on Home Assistant introduced templating which allows variables in scripts and automations. This makes it possible to create conditions or actions based on variables. 660 | 661 | ```yaml 662 | - id: '0008' 663 | alias: 'Daily Update' 664 | hide_entity: true 665 | trigger: 666 | - platform: state 667 | entity_id: input_boolean.daily_update 668 | from: 'off' 669 | to: 'on' 670 | action: 671 | - service: tts.google_say 672 | entity_id: media_player.chromecast 673 | data_template: 674 | message: > 675 | The temperature is currently {{states ('sensor.dark_sky_temperature') | round(0) }} degrees and bitcoin is trading at {{states ('sensor.market_price') | round(0) }} dollars 676 | - service: input_boolean.turn_off 677 | entity_id: input_boolean.daily_update 678 | ``` 679 | 680 | Templating can be a great way to ensure the robustness and accuracy of your automations. For example, if you rely heavily on presence detection to trigger automations it can be problematic if your phone GPS glitches and places you 200m away from your actual location for a brief period of time. Now your "Away from home" automations kick-off and the lights turn off. 681 | In this case you can track your presence using multiple sensors (Owntracks, nmap scan, iCloud) and use a template to define the state of a new ```input_boolean```. The template reads the state of all 3 device trackers and only if 2 out of 3 report you as not_home does it set the state of ```input_boolean.User_home``` to ```OFF```. Now use this component in your automations instead of the individual device trackers. 682 | 683 | An example of a more complex template: 684 | 685 | ``` 686 | - platform: template 687 | sensors: 688 | status_smoke_co_alarm: 689 | value_template: '{%- if is_state("sensor.first_alert_zcombo_smoke_and_carbon_monoxide_detector_alarm_level", "0") %} 690 | Idle 691 | {%else%} 692 | {%- if is_state("sensor.first_alert_zcombo_smoke_and_carbon_monoxide_detector_alarm_type", "1") %} 693 | Fire 694 | {%- elif is_state("sensor.first_alert_zcombo_smoke_and_carbon_monoxide_detector_alarm_type", "2") %} 695 | CO 696 | {%- elif is_state("sensor.first_alert_zcombo_smoke_and_carbon_monoxide_detector_alarm_type", "12") %} 697 | Testing 698 | {%- elif is_state("sensor.first_alert_zcombo_smoke_and_carbon_monoxide_detector_alarm_type", "13") %} 699 | Idle 700 | {% else %} 701 | Unknown 702 | {%- endif %} 703 | {%endif%}' 704 | friendly_name: 'Smoke/CO Alarm' 705 | ``` 706 | 707 | ***[Themes](https://community.home-assistant.io/c/projects/themes)*** 708 | 709 | It is possible to extensively customize Home Assistant's look from within your ```configuration.yaml``` 710 | 711 | ```yaml 712 | themes: 713 | dark_theme: 714 | # Main colors 715 | primary-color: '#5294E2' # Header 716 | accent-color: '#E45E65' # Accent color 717 | dark-primary-color: 'var(--accent-color)' # Hyperlinks 718 | light-primary-color: 'var(--accent-color)' # Horizontal line in about 719 | # Text colors 720 | primary-text-color: '#FFFFFF' # Primary text colour, here is referencing dark-primary-color 721 | text-primary-color: 'var(--primary-text-color)' # Primary text colour 722 | secondary-text-color: '#5294E2' # For secondary titles in more info boxes etc. 723 | disabled-text-color: '#7F848E' # Disabled text colour 724 | label-badge-border-color: 'green' # Label badge border, just a reference value 725 | # Background colors 726 | primary-background-color: '#383C45' # Settings background 727 | secondary-background-color: '#383C45' # Main card UI background 728 | divider-color: 'rgba(0, 0, 0, .12)' # Divider 729 | # Table rows 730 | table-row-background-color: '#353840' # Table row 731 | table-row-alternative-background-color: '#3E424B' # Table row alternative 732 | # Nav Menu 733 | paper-listbox-color: '#5294E2' # Navigation menu selection hoover 734 | paper-listbox-background-color: '#2E333A' # Navigation menu background 735 | paper-grey-50: 'var(--primary-text-color)' 736 | paper-grey-200: '#414A59' # Navigation menu selection 737 | ``` 738 | 739 | 740 | 741 | #### [AppDaemon](https://home-assistant.io/docs/ecosystem/appdaemon/) 742 | AppDaemon is a loosely coupled, multithreaded, sandboxed python execution environment for writing automation apps for Home Assistant. AppDaemon allows for writing more complex automations but is still based on state changes monitored by Home Assistant. 743 | 744 | For example I have a script checking my commute time to work in the morning and back home in the afternoon. This is possible because I use [Owntracks](https://home-assistant.io/components/device_tracker.owntracks/) to track my location. Essentially my current coordinates and the coordinates of my destination are passed to Google Maps via an API to determine travel time. This is done continuously in the background by the Google Travel Time component. 745 | 746 | ```yaml 747 | - platform: google_travel_time 748 | name: Time to Home 749 | api_key: xxxxxxxxxxxxx 750 | origin: device_tracker.my_iphone 751 | destination: zone.home 752 | options: 753 | mode: driving 754 | ``` 755 | 756 | 757 | 758 | This script merely checks that component's state value at a specific time, and if it is greater than my defined threshold then it sends me a text. 759 | 760 | First I define my apps in ```apps.yaml``` 761 | Defining apps this way allows me to reuse my code to trigger both alerts with different variables. 762 | 763 | 764 | ``` 765 | commute_work: 766 | module: commute 767 | class: Commute 768 | time: "8:00:00" 769 | limit: 30 770 | sensor: sensor.time_to_work 771 | tracker: device_tracker.my_iphone 772 | 773 | commute_home: 774 | module: commute 775 | class: Commute 776 | time: "16:50:00" 777 | limit: 30 778 | sensor: sensor.time_to_home 779 | tracker: device_tracker.my_iphone 780 | ``` 781 | And now I write my ```commute.py``` app. 782 | 783 | ```python 784 | import appdaemon.appapi as appapi 785 | 786 | class Commute(appapi.AppDaemon): 787 | 788 | def initialize(self): 789 | time = self.parse_time(self.args["time"]) 790 | self.run_daily(self.check_travel, time) 791 | 792 | def check_travel(self, kwargs): 793 | commute = int(self.get_state(self.args["sensor"])) 794 | currentLocation = str(self.get_state(self.args["tracker"])) 795 | self.log(commute) 796 | self.log(currentLocation) 797 | if commute > int(self.args["limit"]): 798 | if currentLocation == 'Work': 799 | message = "Current travel time from work to home is {} minutes".format(commute) 800 | self.log(message) 801 | self.call_service("notify/twilio", title="Commute Warning", message = message, target="+1412xxxxxxx") 802 | elif currentLocation == 'home': 803 | message = "Current travel time from home to work is {} minutes".format(commute) 804 | self.log(message) 805 | self.call_service("notify/twilio", title="Commute Warning", message = message, target="+1412xxxxxxx") 806 | else: 807 | message = "Location unknown so no message sent" 808 | self.log(message) 809 | ``` 810 | 811 | #### [HA Dashboard](https://home-assistant.io/docs/ecosystem/hadashboard/) 812 | HA Dashboard is a modular, skinnable dashboard for Home Assistant that is intended to be wall mounted, and is optimized for distance viewing. Perfect for displaying on a cheap Android tablet or Kindle Fire. 813 | 814 | 815 | 816 | 817 | #### [Floorplan](https://community.home-assistant.io/c/third-party/floorplan) 818 | Floorplan is a custom integration which allows you to show a floorplan of your home and overlay device control over top. It is very customizable. 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | iOS app to create a floorpan template - [magicplan](https://itunes.apple.com/us/app/magicplan/id427424432?mt=8) 827 | 828 | #### [Node Red](https://nodered.org/) 829 | Node Red is a visual workflow development tool, allowing the creation of complex workflows to control Home Assistant devices. 830 | 831 | 832 | 833 | 3-part series on using Node Red to create Home Assistant automations. 834 | [Part 1](http://diyfuturism.com/index.php/2017/11/26/the-open-source-smart-home-getting-started-with-home-assistant-node-red/), 835 | [Part 2](http://diyfuturism.com/index.php/2017/12/14/basic-node-red-flows-for-automating-lighting-with-home-assistant/), 836 | [Part 3](http://diyfuturism.com/index.php/2018/01/18/going-further-with-home-automations-in-node-red/) 837 | 838 | ## Recommendations for starting out 839 | Hass.io running on a [Raspberry Pi 3](https://www.amazon.com/gp/product/B01C6EQNNK/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B01C6EQNNK&linkCode=as2&tag=solo07e-20&linkId=0305fc19669ba6f80b8813bdde12c5df) - $50 with power and case. 840 | 841 | Many people start with automating lights. Many lights are either wifi controlled or come with their own hub with a proprietary zigbee radio inside. You also should decide if you want white-only bulbs or color. I've found I prefer white bulbs that can display a range of white from cool to warm. I find the white color projected from color bulbs to be unpleasant. Color LED strips work well for adding a splash of color and effects. 842 | 843 | [Yeelight](https://www.amazon.com/YEELIGHT-YLDP03YL-Dimmable-Equivalent-Assistant/dp/B01LRTWQJ0/) Wi-Fi color bulb - $35 844 | 845 | [IKEA Tradfri](http://www.ikea.com/us/en/catalog/categories/departments/lighting/36815/) gateway kit with hub and two white bulbs - $80 846 | 847 | [Hue](https://www.amazon.com/gp/product/B07353SKDD/ref=as_li_qf_asin_il_tl?ie=UTF8&tag=solo07e-20&creative=9325&linkCode=as2&creativeASIN=B07353SKDD&linkId=771af38f2eedf74f476064f5b5090963) starter kit with hub and four white bulbs - $140 848 | 849 | Osram Lightify - [Hub](https://www.amazon.com/gp/product/B00R1PB2T0/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B00R1PB2T0&linkCode=as2&tag=solo07e-20&linkId=988d7444b9635be6c56440b7780a9ed9) $30, [White bulb](https://www.amazon.com/gp/product/B00R3ID2BG/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B00R3ID2BG&linkCode=as2&tag=solo07e-20&linkId=06e21b6fe1d65bf7fec7633c6799629c) $19 850 | 851 | Adding door/window sensors, motion detectors, fire alarms, water leak detectors, etc. requires investment in either Zigbee or Z-Wave. 852 | 853 | A cheap, popular, Zigbee based starter kit is the [Xiaomi Security Kit](https://www.gearbest.com/alarm-systems/pp_659225.html) for $60 which includes a Zigbee hub, two door/window sensors, and a push button. The trade-off is that it's meant for Chinese use only. This means the kit is shipped from China, you must purchase a power adapter, and run through the setup process in Chinese. Having done this myself it's actually pretty simple. 854 | 855 | 856 | 857 | 858 | [Sonoff switches](https://www.itead.cc/sonoff-wifi-wireless-switch.html) ($5 - $10) are a good option for automating power on/off. You can splice one to the cable of any lamp or to any extension cord to make it controllable. They are available in either Wi-Fi or RF versions. [Amazon link](https://www.amazon.com/gp/product/B074N22WFT/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B074N22WFT&linkCode=as2&tag=solo07e-20&linkId=1dca0516faaca5d6e46eb26ea7e87597) 859 | 860 | 861 | 862 | Flash the Sonoff with [Tasmota](https://github.com/arendst/Sonoff-Tasmota) or [ESPurna](https://bitbucket.org/xoseperez/espurna) third-party firmware. 863 | These firmware provide OTA updates and MQTT support. 864 | 865 | There is a large ecosystem of Z-Wave enabled devices and sensors, and some sensors may only be available in Z-Wave versions. To proceed with Z-Wave you need a Z-Wave hub and the Aeotec Z-Stick (Z-Wave plus version) is a popular option for the Raspberry Pi. 866 | 867 | [Aeotec Z-Stick Gen5](https://www.amazon.com/gp/product/B00X0AWA6E/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B00X0AWA6E&linkCode=as2&tag=solo07e-20&linkId=53feaaf88db404e3044607f1ff6e611a) - $45 868 | 869 | 870 |
871 |

872 | Happy Automating! 873 |

--------------------------------------------------------------------------------