Slide 1

Slide 1 text

Exploring Your Smart Home Data Shuhsi Lin Taichung.Py 2019

Slide 2

Slide 2 text

Lurking in PyHug, Taipei.py and various Meetup About Me 2 Scrum Master + Data Engineer in a manufacturing company Working with • data and people Focus on • Agile/Engineering culture • Streaming process • IoT applications • Data visualization Shuhsi Lin sucitw gmail.com https://medium.com/@suci/

Slide 3

Slide 3 text

● Smart home/home automation ○ What makes home automation hard ● Introduction of home-assistant ○ Basic concept and Architecture ● How to build your home automation system ○ Environment setup/Configuration/Possible scenarios ● Explore Your Data ○ Data, libary, and examples ● Summary What I Will Share Today 3

Slide 4

Slide 4 text

● Hacking hardware ● Basic configurations and use on Raspberry Pi ● Compare ecosystems for Amazon Alexa/ Google home/ Apple HomePod/ Mi home ….. ● Too many source code What I Will not Focus ( aka I don’t really know) 4

Slide 5

Slide 5 text

Look familiar?

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

● Explore Your Data ○ Data, libary, and examples This is a new session Photo by Harm Weustink on Unsplash

Slide 8

Slide 8 text

Smart Home

Slide 9

Slide 9 text

Smart Things communicate with each other at home 9

Slide 10

Slide 10 text

Home Control Home Automation Smart Home location and time-based events 10 connect and control devices Photo by Samuel Zeller on Unsplash

Slide 11

Slide 11 text

11 Internet of Things Home Control Information (ex, light is on) Commands (ex, turn light on) Home Automation: Start from a hub User Information Commands State ● Light = on ○ Brightness: 120 ○ Color: Yellow ● Sensor value ○ Temperature: 32 oC ● Switch ○ Power: turn_on Event ● State of switch has changed ○ Off -> on ● Motion detected ● Remote control TV

Slide 12

Slide 12 text

IFTTT IFTTT IFTTT IFTTT IFTTT IFTTT IFTTT IFTTT … Recipe if this then that Trigger Action

Slide 13

Slide 13 text

Home Automation Landscape 13 Internet of Things Home Control User Information (ex, light is on) Commands (ex, turn light on) Information Commands Information Commands Information Commands Home Automation Smart Home Rules (Configuration) Home Control, Automation & the Smart Home

Slide 14

Slide 14 text

•More IoT devices with different protocols •Many own apps •More data •More scenarios •Privacy and trust •Easy to use Challenges 14 https:/ /www.home-assistant.io/blog/2014/12/26/home-control-home-automation-and-the-smart-home/

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

old version https://www.home-assistant.io/demo/

Slide 17

Slide 17 text

https://demo.home-assistant.io/

Slide 18

Slide 18 text

Home Assistant ● Open source, Python 3 ● Active Community ○ 2 weeks release cycle ○ Chatrooms, forums, videos ● Supported many and many devices ● Configuration-based ○ Automation with no code change ● Cross platforms ● Local or remote and cloud is optional

Slide 19

Slide 19 text

Developer documentation https://developers.home-assistant.io/en/

Slide 20

Slide 20 text

● Platforms (collection) ○ Types of devices (ex, lights, sensors) ● Integration/Components (> 1400) Responsible for a specific domain within Home Assistant. ○ Interact with an Internet-of-Things domain ■ MQTT, Zwave, Zigbee ■ Lights (Hue, Tradfri) ■ Sensors ○ Respond to events that happen within Home Assistant ■ Small pieces of home automation logic or involve services that do common tasks within your house. ■ ex, device_sun_light_trigger component Wording in HA Event Bus: facilitates the firing and listening of events -- the beating heart of Home Assistant. State Machine: keeps track of the states of things and fires a state_changed event when a state has been changed. Service Registry: listens on the event bus for call_service events and allows other code to register services. Timer: sends a time_changed event every 1 second on the event bus

Slide 21

Slide 21 text

Home Automation Landscape 21 Internet of Things Home Control User Information (ex, light is on) Commands (ex, turn light on) Information Commands Information Commands Information Commands Home Automation Smart Home Rules (Configuration) Home Control, Automation & the Smart Home

Slide 22

Slide 22 text

Architecture 2 2 Integration/Components Platform Integration/Components

Slide 23

Slide 23 text

Components Architecture 23 State Machine Components service_called events call_service events set state Event Bus Service Registry Timer listen for events/ fire event state_changed events call event listeners time_changed events publish service call service modified from (component_interaction) https:/ /developers.home-assistant.io/docs/en/architecture_index.html ...

Slide 24

Slide 24 text

https://www.home-assistant.io/components/

Slide 25

Slide 25 text

https://www.home-assistant.io/ components/xiaomi_aqara/

Slide 26

Slide 26 text

https://developers.home-assistant.io/docs/en/entity_index.html Entity Switch entity that keeps track of their state in memory switch components

Slide 27

Slide 27 text

Automation https://www.home-assistant.io/getting-started/automation/ Sun trigger Turn on the lights when the sun sets Check sensor value and (>10) show notification

Slide 28

Slide 28 text

Getting-Started

Slide 29

Slide 29 text

Getting-Started Installation (Raspberry Pi 3 , Linux or Mac) Configuration (Connect devices) Automation (Use it)

Slide 30

Slide 30 text

Installation On Raspberry Pi 3 1. Raspbian 2. Hassbian 3. Mossbian (Chinese) 4. Hass.io use this ● HA UI ● Ready to use (integrated 3rd part applications) ● Easy to install and update (ResinOS and Docker) ● Easy to extend by Hass.io add-ons (Goolge Assistant...) Home Assistant

Slide 31

Slide 31 text

HOME ASSISTANT and HASS.IO https://www.home-assistant.io/blog/2018/04/22/hassio-2018/ https://developers.home-assistant.io/docs/en/architecture_hassio.html ResinOS

Slide 32

Slide 32 text

http://localhost:8123 Home Assistant UI

Slide 33

Slide 33 text

Configuration Hass.io: /config (~/.homeassistant/configuration.yaml) https://www.home-assistant.io/getting-started/configuration/

Slide 34

Slide 34 text

ADD-ON

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

ssh key

Slide 37

Slide 37 text

Automation by built-in components

Slide 38

Slide 38 text

Hey, Google

Slide 39

Slide 39 text

Home Assistant Cloud • Google Assistant (Google Home) • Amazon Alexa (Amazon Echo) https:/ /www.home-assistant.io/cloud/

Slide 40

Slide 40 text

https://www.nabucasa.com/

Slide 41

Slide 41 text

https://www.nabucasa.com/config/

Slide 42

Slide 42 text

Possible Scenario 42 Mi Home (China version) (gateway) text-based Google Assistant working on Hass.io Home Assistant Cloud $5 USD/month yicamera (hacked)

Slide 43

Slide 43 text

大兵萊恩 一路直前 a. Home Assistant, (1) 系統安裝與簡單上手 (Internet of Things, Home Assistant) b. Home Assistant, (2) 遙控小米開關與條件式自動化 (Internet of Things, Home Assistant) c. Home Assistant, (3) 安裝 InfluxDB 與 Grafana 套件 (Internet of Things, Home Assistant) d. Home Assistant, (4) 安裝 Mosquitto 套件與建立 MQTT 開關 (Internet of Things, Home Assistant) More Step by Step!! ● 新手上路 Home Assistant 中文文檔

Slide 44

Slide 44 text

Mac OS

Slide 45

Slide 45 text

Mac OS

Slide 46

Slide 46 text

What about data?

Slide 47

Slide 47 text

events Explore Your Data states services context state_changed automation_triggered script_started service_registered recorder_runs 1. Complete ownership of your personal data 2. Optimise automation SQL https://data.home-assistant.io/ event-driven!!

Slide 48

Slide 48 text

events states services context state_id domain state attributes recorder_runs https://data.home-assistant.io/docs/data_states Entity States event_id last_changed last_updated created context_id context_user_id events states services context context_id user_id recorder_runs refresh_token_id not stored in their own table https://data.home-assistant.io/docs/data_context https://data.home-assistant.io/docs/data_recorder_runs run_id start end closed_incorrect created

Slide 49

Slide 49 text

https://community.home-assistant.io/t/sqlite-web/58398 https://www.home-assistant.io/docs/backend/database/#schema

Slide 50

Slide 50 text

https://community.home-assistant.io/t/data-science-with-home-assistant/32125 Initiated from 2017 Nov

Slide 51

Slide 51 text

https://data.home-assistant.io/

Slide 52

Slide 52 text

Getting started ● User environment ○ Hass.io user ○ non-hass.io users ■ Quick start on Ubuntu ■ Docker ● kylerw/hass-data-detective ● Jupyter notebooks for Home Assistant ○ DataExploration-1 and -2 ● HASS-data-detective/notebooks ● Sample data HASS Data Detective Home Assistant notebooks Explore Your Data More Possibilities ● AI in smart home ○ To learn when to switch on the lights in the living room

Slide 53

Slide 53 text

● Smart Home ○ No standard/universal communication way between smart things (so far) ● Home assistant ○ as a Developer ○ as a User ● Hassio ( + Raspberry Pi) ● Home assistant cloud ● Try it with blog tutorials ● Play data from HA Take Home Messages

Slide 54

Slide 54 text

Home Assistant 1.0 Coming soon!

Slide 55

Slide 55 text

Raspberry Pi 4 https://www.tomshardware.com/reviews/raspberry-pi-4-b,6193.html

Slide 56

Slide 56 text

Overview and tutorials ● https://developers.home-assistant.io/ (Developer documentation) ● https://www.home-assistant.io/cookbook/ (Cookbook) ● https://www.home-assistant.io/getting-started/ ● https://www.hachina.io/ (Chinese!) ● https://home-assistant.cc (Another Chinese!) ● https://zhuanlan.zhihu.com/c_138110024 知乎:智能家居从零开始( Home Assistant) ● Xiaomi Smart Home Ecosystem list VIDEOS, TALKS, WORKSHOPS AND ALIKE ● Paulus Schoutsen - Awaken your home: Python and the Internet of Things - PyCon 2016 ● Automating your Home with Home Assistant: Python’s Answer to the Internet of Things Hassio ● https://www.home-assistant.io/hassio/ ● https://www.home-assistant.io/blog/2017/07/25/introducing-hassio/ Google Home ● https://www.home-assistant.io/components/google_assistant/ (components/) ● https://www.home-assistant.io/cloud/google_assistant/ (via HA cloud) ● https://www.youtube.com/watch?v=NfyavpAg4as with google assistant Data Science with HA ● https://data.home-assistant.io/ Smart Home ● 智慧家庭實驗室 林祐祺 References not HA, but python with IoT ● Homekit with Python ● IoT in Home – Building a Toilet Vacancy Indicator ● ….