element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi IoT
  • Challenges & Projects
  • Design Challenges
  • Pi IoT
  • More
  • Cancel
Pi IoT
Blog Pi Control Hub: Setting up Home Assistant+Controlling  Philips hue
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: carmelito
  • Date Created: 19 Aug 2016 4:29 PM Date Created
  • Views 2404 views
  • Likes 5 likes
  • Comments 6 comments
  • home automation
  • picontrolhub
  • piiot
  • raspberry-pi3
  • raspberry pi3
  • iot
  • piiot challenge
Related
Recommended

Pi Control Hub: Setting up Home Assistant+Controlling  Philips hue

carmelito
carmelito
19 Aug 2016

After designing and putting together  3 SPOKES which you can take up as individual projects. It is now time ! to put them all together and have them communicate with each other via the HUB. To have the spokes and the Hub communicate with each other and other IoT and entertainment things! around the house we are going to use  Home-Assistant.io, which is an open-source home automation platform running on Python 3, and we are going to install this on the Raspberry Pi 3.Here a demo video, controlling Hue bulbs using the Home-Assistant dashboard.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Here are the links to the blog post for all the 3 Spokes

Pi Control Hub: Spoke 1 :Security Camera

Pi Control Hub:Spoke2:Blinds Automation Using the Enocean Sensor Kit

Pi Control Hub:Spoke3: Keyless Door entry

 

As part of this blog post we are going to setup Home Assistant on the Pi 3 and have it control Phillips Hue light and in addition

  • Get the weather from the Yahoo weather API to display on Home-Assistant Dashboard as shown in video below
  • Check the CPU usage of you Raspberry Pi 3
  • Check on the exchange rate for BitCoin
  • Check on if you favorite Twitch channels are online
  • Perform speed test of your network.
  • Take advantage of the Bluetooth on the Pi to check if your phone "aka you are at home , which then turns on you Lights

 

{gallery} Home Assistant controlling  Philips hue

image

Home Assistant setup on the Pi3 controlling Philips Hue bulbs

image

Picking a color for the Philips Hue bulb for my living room

image

Screenhot of color picker for the Hue bulb

image

Temperature from the Yahoo weather API

image

Humidity from the Yahoo weather API

image

Bitcoin value

image

CPU usage of the raspberry Pi3

image

Download bandwidth speed test

image

Monitoring Twitch channel at - https://www.twitch.tv/

image

Checking if you are Home or Away by checking if the Pi3 detect the Bluetooth of the phone

image

Checking the History of the various devices and sensors

 

Some more history, in a fancy graphical form

image

LogBook - And even more History , sorted by time..

 

Here are the steps to follow to setup things shown in the video demo above

#1 To install Home-Assistant.io you are going to need to install Python 3 on your Raspberry Pi

     update Rasbian packages

         sudo apt-get update

         sudo apt-get upgrade

       Install python 3 and python's package manager PIP for python3

          sudo apt-get install python3 python3-pip

Note: I am using the Raspbian Jessie on a 16GB SD card on a Raspberry Pi 3

#2 install Home-assistant using pip

         sudo pip3 install homeassistant

image

For more info refer to the awesome documentation on the Home-Assistant site - https://home-assistant.io/getting-started/

 

#3 Setup Home-Assistant to auto-start on boot

     Before we setup home-assistant to auto start check if  evening thing with you install went fine by typeing in the command

         sudo hass --demo-mode

     and then open on a browser on you laptop open - http://IpaddressofPi:8123 , this should load up the demo app of home assistant and gives you an overview of all the things you can setup           with home assistant

     Now if that was successful, use the following commands to setup home-assistant  

        sudo wget https://raw.githubusercontent.com/home-assistant/home-assistant/master/script/home-assistant%40.service -O /etc/systemd/system/home-assistant@pi.service

     check the path of the install of home-assistant,using

        whereis hass     

     then update the home-assistant@pi.service file with

         cd /etc/systemd/system/

         sudo nano home-assistant@pi.service

      in the nano editor check and validate that ExecStart point to the path which is got as part of the whereis hass command, which in my case is

         " ExecStart=/usr/local/bin/hass --runner "

 

       Once done you will need to reload systemd to make the daemon aware of the new configuration. Enable and launch Home Assistant after that, using the commands

          sudo systemctl --system daemon-reload

           sudo systemctl enable home-assistant@pi

           sudo systemctl start home-assistant@pi

      image

          Note: in the picture above i had my google chromecast on and connected to my Television called ChromeMainTV which was auto discovered in the Home-Assistant App

 

         Now when you reboot the Home-Assistant should start automatically

         for more info on the general instruction refer to https://home-assistant.io/getting-started/autostart-systemd/

#4  Setting up current weather conditions to show up on Home-Assistant

        To setup weather condition , you will have to edit the configuration.yaml , for this you will need to familiarize yourself with the YAML syntax, but if you've worked with python this should be a           breeze image , given you are already aware of the importance of indentation..

        the  configuration.yaml can be found at

           cd ~/.homeassistant

        the edit the file add the following to the end of the file

          sudo nano configuration.yaml

     

sensor:
- platform: yweather
  woeid: 4118
  monitored_conditions:
   - weather
   - humidity
   - temperature

       

           To read more about the yahoo weather components check out - https://home-assistant.io/components/sensor.yweather/

           For other weather options  like forecast.io,OpenWeather maps check out - https://home-assistant.io/components/#weather

#5 Monitoring you Pi CPU, disk usage etc

      this is setup as a sensor, and add the following platforms section under sensor section of configuration.yaml

 

#Pi system monitor
- platform: systemmonitor
  resources:
    - type: disk_use_percent
      arg: /home
    - type: memory_free
    - type: processor_use
- platform: cpuspeed
  name: CPU

     For more info check out - https://home-assistant.io/components/sensor.systemmonitor/

                                              https://home-assistant.io/components/sensor.cpuspeed/

#6 Monitoring your favorite twitch channel to check if it is streaming now!

      This again is setup as a sensor, which means you will have to add this to the sensor section of configuration.yaml , here is an example

  

- platform: twitch
  channels:
    - esl_csgo
    - gamingonlinux

         here I am monitoring two channels as a demo , the fist one, is the most active Counter-Strike: Global Offensive channel

        For more info check out https://home-assistant.io/components/sensor.twitch/

 

#7  Checking on you network speed

       Add the following bit to the sensor section , i my case I am interested in Download speed and pings, check out this link for more options - https://home-assistant.io/components/sensor.speedtest/

 

#Wifi speed tests using Speedtest.net
- platform: speedtest
  monitored_conditions:
    - ping
    - download

#8 Checking on the BitCoin exchange rate

      In my case I am checking the bitcoin exchange rate in Candian dollars CAD

- platform: bitcoin
  currency: CAD
  display_options:
    - exchangerate

 

 

#9 Setting up the Philips hue Lights

      To setup the Philips hue lights you will first have to get the IP address of the Hue bridge, to do this get on you phone , in the Hue app go to the network setting and make a note of ip address

image

   Add the following lines to the configuration.yaml file

#Philips Hue lights
light:
  platform: hue
  host: 192.168.0.31
  allow_unreachable: true

 

once you are done with this setup reboot your Pi and then when you  should see the  Configurator for  Hue bridge in the Home-Assistant dashboard

image

One you hit the configure button , you should see all the Hue device in you dashboard

 

#10  Setting up Bluetooth , to detect your Phone

      It is now  time to take advantage off the Bluetooth on the Pi 3, basically we are going to check if the phone is Bluetooth range of the Pi 3 and switch on the Hue lights in the Living room, this           mimics that you have reached home and the Lights come on automatically. Start off by installing

         sudo apt install bluetooth libbluetooth-dev

      And then add the following to the configuration.yaml file

device_tracker:
  platform: bluetooth_tracker

 

       once done reboot your pi , and also switch off and switch on the Bluetooth on you phone , to check if device is discovered and added to Home-Assistant check the file at

           cd ~/.homeassistant

        and open the file,and you should see an entry for your phone, as show in the screenshot below

          sudo nano  know_devices.yaml

image

    For more info check out - https://home-assistant.io/components/device_tracker.bluetooth_tracker/

 

Now to lets setup an automation rule in the configuration.yaml file to check if your phone is detected by the Pi 3's Bluetooth

automation:
  alias: CarmelitosIphone is Home
  trigger:
       platform: state
       entity_id: device_tracker.carmelito_andrades_iphone
       state: 'home'
  action:
    service: light.turn_on
    entity_id: light.officelampbulb

   to get the name of you device to add to the rule in the Developer tools of the Home-Assistant dash board , ie http://ipaddressofPi:8123/dev-state , as you see in the screen shot below the entity_id for my phone is "device_tracker.carmelito_andrades_iphone" and the state is "home"

image

Note: this is a very basic rule to get you started, you can modify this to add time check in the trigger section, to only switch on the lights if you get home at night between 7 PM to 11 PM..

  • Sign in to reply

Top Comments

  • DAB
    DAB over 9 years ago +1
    Very good post and demo. Nice clean system monitoring and control with user status and options. Great implementation. DAB
  • fvan
    fvan over 9 years ago +1
    Home Assistant seems to be a good alternative to OpenHAB, with support for many devices and protocols!
  • pettitda
    pettitda over 8 years ago in reply to soccernut43 +1
    The Hue bridge links between the lights which use Zigbee and your phone/pc/raspberry Pi which use WiFi. The Raspberry Pi doesn't have Zigbee built in so you'll need to have either the Hue bridge or a generic…
  • carmelito
    carmelito over 8 years ago in reply to pettitda

    soccernut43 , thanks for the comment, the Hue lights use zigbee per pettitda comment to communicate to the bridge. If you don't want to get the hue bridge, you can try out the Aeotec by Aeon Labs ZW090 Z Stick (https://www.amazon.com/Aeotec-Aeon-Labs-ZW090-Stick/dp/B00X0AWA6E/ref=sr_1_1?ie=UTF8&qid=1478408064&sr=8-1&keywords=Z-wa… ). I had though of using the USB stick, but I had the Hue lights setup which I had purchased about 6 months ago with the bridge.In addition the USB stick is about 40 to 50 dollars and so is the bridge,but the USB stick would be a good choice if you want to get the other Aeotec stuff like a switch/socket/other sensors ..

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • pettitda
    pettitda over 8 years ago in reply to soccernut43

    The Hue bridge links between the lights which use Zigbee and your phone/pc/raspberry Pi which use WiFi.  The Raspberry Pi doesn't have Zigbee built in so you'll need to have either the Hue bridge or a generic Zigbee radio and the time/resources to reverse engineer the interface. 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • volly
    volly over 8 years ago

    carmelito, I like it...Splendid!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • soccernut43
    soccernut43 over 8 years ago

    I noticed you "had to check the address of the Hue Bridge".  I was hoping the Raspberry Pi 3 would become the Hue Bridge without having to purchase another bridge.  Great tutorial.  Will use this when my Raspberry Pi arrives today.  I have two Hue bulbs in place.  Hoping to get them working without purchasing a Philips Hue Bridge. Thanks!! 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fvan
    fvan over 9 years ago

    Home Assistant seems to be a good alternative to OpenHAB, with support for many devices and protocols!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube