Save 37% off PRO during our Black Friday Sale! »

Exploring Your Smart Home Data

Bfb93c5dc0fde76ddac605bba0e1b642?s=47 suci
July 06, 2019

Exploring Your Smart Home Data

Sharine at Taichung. Py



July 06, 2019


  1. Exploring Your Smart Home Data Shuhsi Lin Taichung.Py 2019

  2. Lurking in PyHug, 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
  3. • 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
  4. • 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
  5. Look familiar?

  6. None
  7. • Explore Your Data ◦ Data, libary, and examples This

    is a new session Photo by Harm Weustink on Unsplash
  8. Smart Home

  9. Smart Things communicate with each other at home 9

  10. Home Control Home Automation Smart Home location and time-based events

    10 connect and control devices Photo by Samuel Zeller on Unsplash
  11. 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

    if this then that Trigger Action
  13. 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
  14. •More IoT devices with different protocols •Many own apps •More

    data •More scenarios •Privacy and trust •Easy to use Challenges 14 https:/ /
  15. None
  16. old version


  18. 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
  19. Developer documentation

  20. • 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
  21. 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
  22. Architecture 2 2 Integration/Components Platform Integration/Components

  23. 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:/ / ...

  25. components/xiaomi_aqara/

  26. Entity Switch entity that keeps track of their state

    in memory switch components
  27. Automation Sun trigger Turn on the lights when the

    sun sets Check sensor value and (>10) show notification
  28. Getting-Started

  29. Getting-Started Installation (Raspberry Pi 3 , Linux or Mac) Configuration

    (Connect devices) Automation (Use it)
  30. Installation On Raspberry Pi 3 1. Raspbian 2. Hassbian 3.

    Mossbian (Chinese) 4. use this • HA UI • Ready to use (integrated 3rd part applications) • Easy to install and update (ResinOS and Docker) • Easy to extend by add-ons (Goolge Assistant...) Home Assistant

  32. http://localhost:8123 Home Assistant UI

  33. Configuration /config (~/.homeassistant/configuration.yaml)

  34. ADD-ON

  35. None
  36. ssh key

  37. Automation by built-in components

  38. Hey, Google

  39. Home Assistant Cloud • Google Assistant (Google Home) • Amazon

    Alexa (Amazon Echo) https:/ /


  42. Possible Scenario 42 Mi Home (China version) (gateway) text-based Google

    Assistant working on Home Assistant Cloud $5 USD/month yicamera (hacked)
  43. 大兵萊恩 一路直前 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 中文文檔
  44. Mac OS

  45. Mac OS

  46. What about data?

  47. 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 event-driven!!
  48. events states services context state_id domain state attributes recorder_runs

    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 run_id start end closed_incorrect created

  50. Initiated from 2017 Nov


  52. Getting started • User environment ◦ user ◦

    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
  53. • 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
  54. Home Assistant 1.0 Coming soon!

  55. Raspberry Pi 4,6193.html

  56. Overview and tutorials • (Developer documentation) • (Cookbook)

    • • (Chinese!) • (Another Chinese!) • 知乎:智能家居从零开始( 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 • • Google Home • (components/) • (via HA cloud) • with google assistant Data Science with HA • Smart Home • 智慧家庭實驗室 林祐祺 References not HA, but python with IoT • Homekit with Python • IoT in Home – Building a Toilet Vacancy Indicator • ….