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

Bfb93c5dc0fde76ddac605bba0e1b642?s=128

suci

July 06, 2019
Tweet

Transcript

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

  2. 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/
  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
  12. IFTTT IFTTT IFTTT IFTTT IFTTT IFTTT IFTTT IFTTT … Recipe

    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:/ /www.home-assistant.io/blog/2014/12/26/home-control-home-automation-and-the-smart-home/
  15. None
  16. old version https://www.home-assistant.io/demo/

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

  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 https://developers.home-assistant.io/en/

  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:/ /developers.home-assistant.io/docs/en/architecture_index.html ...
  24. https://www.home-assistant.io/components/

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

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

    in memory switch components
  27. 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
  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. 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
  31. 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

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

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

  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:/ /www.home-assistant.io/cloud/
  40. https://www.nabucasa.com/

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

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

    Assistant working on Hass.io 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 https://data.home-assistant.io/ event-driven!!
  48. 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
  49. https://community.home-assistant.io/t/sqlite-web/58398 https://www.home-assistant.io/docs/backend/database/#schema

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

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

  52. 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
  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 https://www.tomshardware.com/reviews/raspberry-pi-4-b,6193.html

  56. 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 • ….