Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Smart Things + Home Assistant: build your own smart home

suci
June 01, 2018

Smart Things + Home Assistant: build your own smart home

Slides for pycon Taiwan 2018
https://tw.pycon.org/2018/zh-hant/events/talk/595662847891996847/

Our world will be composed of more and more connected devices. Smart things will enrich our life started from our home. However, with no standard in place for communication, devices are unable to recognize to each other and work together well.

An open source project, "Home Assistant", brings us into the practical home automation world. Building on Python, the home automation platform was implemented to take control of their houses, their data, and their privacy. In this talk, I will start by introducing a concept of home automation, the general concept of "Home Assistant" and it's components. Then, a sample demo will bring you a real scenario along with introducing configurations.

suci

June 01, 2018
Tweet

More Decks by suci

Other Decks in Programming

Transcript

  1. Smart Things + Home Assistant:
    build your own smart home
    Shuhsi Lin
    PyContw 2018

    View Slide

  2. About me
    Data engineer
    in a manufacturing company
    Working with
    • data and people
    Focus on
    • Streaming process
    • IoT applications
    • Engineer culture
    Shuhsi Lin
    Lurking in PyHug, Taipei.py and various Meetup
    sucitw gmail.com

    View Slide

  3. ● Smart home/home automation
    ○ What makes home automation hard
    ● Introduction of home-assistant
    ○ Basic concept of home-assistant
    ○ Architecture of home-assistant
    ● How to build your home automation system
    ○ Environment setup
    ○ Configuration
    ○ Possible scenario
    ● Summary
    What I will share today
    3

    View Slide

  4. ● Hacking hardware ( The next speaker may take care !?)
    ● Basic configurations and use on Raspberry Pi
    ● Compare ecosystems for Amazon Alexa/ Google home/ Apple
    HomePod/ Mi home …..
    ● Much source code
    What I will not focus ( aka I don’t know)
    4

    View Slide

  5. Smart Home

    View Slide

  6. Smart Things
    6
    home control home automation smart home
    location and time-based events
    communicate with
    each other
    at home

    View Slide

  7. 7
    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

    View Slide

  8. IFTTT
    IFTTT IFTTT IFTTT IFTTT IFTTT IFTTT IFTTT …
    Recipe
    if this then that
    Trigge
    r
    Action

    View Slide

  9. Home Automation Landscape
    9
    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

    View Slide

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

    View Slide

  11. 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

    View Slide

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

    View Slide

  13. ● Platforms
    ○ Types of devices (ex, lights, sensors)
    ● Components (> 1000)
    ○ 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

    View Slide

  14. Home Automation Landscape
    14
    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

    View Slide

  15. Architecture
    1
    5
    Components
    Platform
    Components

    View Slide

  16. Components Architecture
    16
    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.htm
    ...

    View Slide

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

    View Slide

  18. https://www.home-assistant.io/com
    ponents/xiaomi_aqara/

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  22. Getting-Started

    View Slide

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

    View Slide

  24. 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 0.70.0

    View Slide

  25. 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

    View Slide

  26. http://hassio.local:8123
    Home Assistant UI

    View Slide

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

    View Slide

  28. ADD-ON

    View Slide

  29. View Slide

  30. ssh key

    View Slide

  31. Automation by built-in components

    View Slide

  32. Hey, Google

    View Slide

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

    View Slide

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

    View Slide

  35. ● Smart Home
    ○ No standard/universal communication way between smart things
    (so far)
    ● Home assistant
    ○ as a Developer
    ○ as a User
    ● Hassio
    ● Home assistant cloud
    Take Home Messages

    View Slide

  36. 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://github.com/robmarkcole/HASS-data-science
    Smart Home
    ● 到底什麼是智慧音箱?為什麼亞馬遜、谷歌、蘋果都視其為後手機時代的決勝點?
    智慧家庭實驗室 林祐祺 20180409
    References

    View Slide