Raspberry Pi as SMART HOME hub – Home Assistant, Node RED, Grafana, InfluxDB etc. Guide From Scratch

In this article/video I’ll show you how to create a Smart Home hub on a Raspberry Pi from scratch. I’m going to install Home Assistant (HASSIO), Node-RED, Mosquitto MQTT, Grafana, InfluxDb, Pi-Hole, Portainer, OpenHAB, Plex media server, Log2Ram & TasmoAdmin, but don’t worry it will be easier than you think and everything will be based on Docker containers.

After you complete this tutorial you will be able to connect almost every smart device that you have, in one place, and control it from there. Oh and there is even a menu. 

Requirements for making Raspberry Pi as SMART HOME hub

To complete this tutorial you will need:

If you don’t have Raspberry yet, you can buy one from the affiliate links below:

I’m using MacOS but you can follow the same steps with Linux terminal or any Windows SSH client.

To download the project type the following in a Terminal:

sudo apt-get install git -y
git clone https://github.com/SensorsIot/IOTstack.git ~/IOTstack

To start the Menu

cd ~/IOTstack && bash ./menu.sh

After you install Docker and you have chosen anything from the Menu – type:

docker-compose up -d

This will download the Docker images from Internet and will install them on your Raspberry Pi. Depending on how many containers you selected and your internet connection speed this can take a while.

Portainer

Portainer is a powerful, open-source management toolset that allows you to easily build, manage and maintain Docker environments.

  • URL: 
    • YOUR_RASPBERRY_IP:9000
  • Default Credentials:
    • You will be asked to choose a password

Node RED

Node RED is a visual programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.

  • URL: 
    • YOUR_RASPBERRY_IP:1880

To enter inside the Node RED container execute:

docker exec -it bordered /bin/bash

or

./services/nodered/terminal.sh 

To secure Node-RED you need a password hash. To get the hash run the command bellow and change the PASSWORD with your password to get the hash:

node -e "console.log(require('bcryptjs').hashSync(process.argv[1], 8));" PASSWORD

Copy the generated has and open the file 

./volumes/nodered/data/settings.js 

Then follow the writeup on https://nodered.org/docs/user-guide/runtime/securing-node-red for further instructions.

Grafana

Open-source platform for data visualization, monitoring and analysis. Grafana works great with InfluxDB for storing IoT devices metrics, and it also supports other data sources (Prometheus, MySQL, Postgres) 

  • URL: 
    •   YOUR_RASPBERRY_IP:3000
  • Default Credentials:
    •   username: admin
    •   password: admin
  • Then you have to change your password

Mosquitto

To enter inside the Mosquitto container execute:

docker exec -it mosquitto /bin/sh

or  

./services/mosquitto/terminal.sh 

Then run the following command replacing MYUSER with username of your choice:

mosquitto_passwd -c /mosquitto/config/pwfile MYUSER 

It will then ask you to type your password and confirm it. 

To exit the container’s shell type:  

exit

Edit the file below and remove the comment in front of password_file

services/mosquitto/mosquitto.conf 

Restart the container either from your local Portainer or with the command:

docker-compose restart mosquitto. 

Then you can use these credentials in Tasmota, Node-RED, Home Assistant etc.

Home Assistant (HASSIO)

Hass.io is an Open source home automation software that puts local control and privacy first. Home Assistant currently supports over 1,400 different integrations with more added with every release.

  • URL: 
    •   YOUR_RASPBERRY_IP:8123
  • Info
    • Hass.io now has a seperate installation in the menu.
    • You will be asked to select your device type during the installation.

InfluxDb

InfluxDB is an open-source time series database. It is written in Go language and it is optimized for fast, high-availability storage and retrieval of time series data in fields such as operations monitoring, application metrics, Internet of Things sensor data, and real-time analytics.

  • Default Credentials:
    •   username: nodered
    •   password: nodered

To enter inside the InfluxDB container execute:

 docker exec -it influxdb /bin/bash

or 

./services/influxdb/terminal.sh

Using the CLI inside container you can type the following

To create mydb Database:

CREATE DATABASE mydb

In order to show all available Databases, you can use:

SHOW DATABASES

To connect to mydb Database:

USE mydb

Insert statement to add a single time series data point into InfluxDB, enter: 

INSERT cpu,host=serverA,region=us_west value=0.64

Select statement To retrieve data from the database

SELECT "host", "region", "value" FROM "cpu"

Perform a GET request to retrieve data from HTTP:

curl -G 'http://YOUR_RASPBERRY_IP:8086/query?pretty=true' --data-urlencode "db=mydb" --data-urlencode "q=SELECT \"value\" FROM \"cpu_load_short\" WHERE \"region\"='us-west'"

Pi-Hole

  • URL: 
    •   YOUR_RASPBERRY_IP:8089/admin
  • Default Credentials:
    •   password: pihole

Then you can change the password by entering inside Pi-Hole docker container using the following:

docker exec -it pihole /bin/bash

and then by executing:

pihole -a -p

You have to type your new password twice to save it.

Raspberry Pi as SMART HOME hub -Successful password change of the Pi-Hole
Raspberry Pi as SMART HOME hub – Successful password change of the Pi-Hole

openHAB

open Home Automation Bus (openHAB) is an open source home automation software written in Java. It is deployed on premise and connects to devices and services from different vendors. 

  • URL: 
    •   YOUR_RASPBERRY_IP:8080
    •   YOUR_RASPBERRY_IP:8443 #for HTTPS.

Plex media server

PlexMediaServeris a free digital mediaserver which lets you access the media contents (audio, video, pictures) on one computer with any other computer or devices. 

  • URL: 
    •   YOUR_RASPBERRY_IP:32400/web 
  • Info:
    • Create a directory in you home directory called mnt with a subdirectory HDD.
    • Follow these instructions to mount your external drive to /home/pi/mnt/HDD in you fstab
    • edit your docker-compose.yml file and under plex section uncomment the volumes for tv series and movies (modify the path to point to your media locations).
    • Run docker-compose up -d to rebuild plex with the new volumes

Log2Ram 

Very usefull tool for RaspberryPi for not writing on the SD card all the time.

Activate it through the menu and execute the following commands to ensure that is working. They have to return some lines if everything is OK.

df -h | grep log2ram
mount | grep log2ram

TasmoAdmin

TasmoAdmin is an administrative Website for Devices flashed with Tasmota firmware.

  • URL: 
    •   YOUR_RASPBERRY_IP:8088

Question for You

My question for you guys is very simple. What kind of smart devices are you currently have – let me know in the comments bellow.

I’m using several Tasmotised Sonoffs and D1 minis with temperature and humidity sensors.

These IoT devices are connected to my Home Assistant and Node-Red and I control my house heating, some of my lights and my garage door. 

Support my work

Any sort of engagement on this channel does really help out a lot with the YouTube algorithm, so make sure you hit the subscribe, Like and Bell buttons If you enjoy this video.

Also feel free to add me on Twitter by search for KPeyanski. I post there pretty much daily. 

I’m also messing around with TikTok just for fun. If you are there come and say hi.

I hope that you find this tutorial useful and definitely stay tuned for the other tutorials that are coming up. 

Thank you for reading, stay safe and see you next time.


32 Comments

Vernon · 07/12/2019 at 3:48 pm

I every time spent my half an hour to read
this website’s articles or reviews daily along
with a mug of coffee.

    Kiril Peyanski · 08/12/2019 at 12:45 am

    Great to hear that. Keep on doing that, cause I’m preparing a lot more stuff.

Keenan · 07/12/2019 at 10:03 pm

First of all I want to say fantastic blog! I had a quick question which I’d like
too ask if you ddo nott mind. I was interested too find out how you center yourself and clear
your thoughts before writing. I have had difficulty clearing my mind
in getting my thoughts out. I do take pleasure
in writing but it juust seems like the first 10 to 15 minutes are usualoy wasted simply just trying to figure out
how to begin. Any recommendations or tips? Appreciate it!

    Kiril Peyanski · 08/12/2019 at 12:47 am

    Turn off all distractions around you (phone, tv, etc.) and set a reachable for you deadline. Good luck

mobile legend cheat · 26/12/2019 at 3:19 pm

I’m curious to find out what blog system you’re utilizing?
I’m having some minor security issues with my latest site and I’d like to find
something more safeguarded. Do you have any solutions?

unblocked · 12/01/2020 at 1:52 pm

What’s Going down i’m new to this, I stumbled upon this
I have found It absolutely useful and it has helped me out loads.

I’m hoping to contribute & aid different users like its aided
me. Good job.

Hosea · 15/02/2020 at 2:39 pm

Can you tell us more about this? I’d like to find
out some additional information.

    Kiril Peyanski · 16/02/2020 at 7:23 am

    What exactly do you want to know?

Kendrick · 17/02/2020 at 2:10 am

I do consider all the ideas you have presented for your post.
They are really convincing and will certainly work.
Nonetheless, the posts are too short for newbies.

May just you please prolong them a bit from subsequent time?
Thanks for the post.

    Kiril Peyanski · 17/02/2020 at 8:41 am

    Thanks for the comment. Can you please tell me what part exactly do you think should be prolonged?

Erlinda · 31/03/2020 at 3:40 am

This is the perfect webpage for anyone who really wants to understand this topic.
You know so much its almost tough to argue with you (not that I really will need to…HaHa).
You certainly put a fresh spin on a subject that’s been written about for many years.
Wonderful stuff, just great!

sehy and i know it lyrics and music youtube · 05/04/2020 at 1:18 am

Ahaa, its good discussion on the topic of this piece of writing here at this web site, I have read all that, so now me also commenting at this place.|

Kristofer · 10/04/2020 at 1:14 am

Hey! I just wanted to ask if you ever have any trouble with
hackers? My last blog (wordpress) was hacked and I ended up
losing many months of hard work due to no backup. Do you have any methods to stop hackers?

Freddy Berenson · 03/05/2020 at 11:50 pm

“Having read this I thought it was very enlightening. I appreciate you taking the time and effort to put this article together. I once again find myself personally spending way too much time both reading and commenting. But so what, it was still worth it!”

Vickie · 10/05/2020 at 4:32 am

Spot on with this write-up, I truly believe this web site needs much more attention.
I’ll probably be returning to read through more, thanks for the info!

Manuela · 11/05/2020 at 12:06 am

I know this web page provides quality depending articles
or reviews and additional material, is there any
other website which offers these stuff in quality?

Johnie · 17/05/2020 at 6:58 pm

I’ve been exploring for a little for any high-quality articles or blog posts in this sort of space .
Exploring in Yahoo I ultimately stumbled upon this website.
Studying this info So i am satisfied to exhibit that I have
a very excellent uncanny feeling I came upon exactly what I needed.
I most indisputably will make sure to don?t put out of your mind this web site and provides it a
look regularly.

Milo · 19/05/2020 at 5:14 am

Hello There. I discovered your blog the use of msn. That is a very smartly written article.
I will make sure to bookmark it and return to read more of your useful information.
Thanks for the post. I’ll certainly return.

ปั้มไลค์ · 21/05/2020 at 9:55 am

Like!! Thank you for publishing this awesome article.

MadelynRKlas · 30/05/2020 at 9:20 pm

You have to be a part of a contest for one of your greatest blogs on the net. I am going to recommend this site!

BillWZenon · 04/06/2020 at 6:20 am

Hi there! Quick question that’s totally off topic. Are you aware learning to make your website mobile friendly? My website looks weird when browsing from my iphone4. I’m looking for a theme or plugin that might be able to correct this issue. For those who have any suggestions, please share. Cheers!

SonaCPicot · 04/06/2020 at 3:31 pm

Hello everyone, it’s my first go to see at this web site, and article is truly fruitful in support of me, keep up posting these types of articles or reviews.

SoonVBirdine · 10/06/2020 at 2:20 pm

This is a topic that’s near to my heart… Cheers! Specifically where are your contact details though?

Martin · 30/10/2020 at 3:28 pm

Hi, Great job! I’v notice zigbee2mqtt install option and i was wondering do you have ane example of that, since i’m interesting of zigbee network?

    Kiril Peyanski · 30/10/2020 at 3:46 pm

    Hi there, you should have zigbee usb stick to use that. Do you have one?

      Martin · 30/10/2020 at 6:18 pm

      Yes

        Martin · 31/10/2020 at 4:24 pm

        Yes, i have, but still i need some example. Any idea?

          Kiril Peyanski · 06/11/2020 at 2:12 pm

          Hey Martin just check the Home Assistant documentation about zigbee or you can ask in the HA community

      Martin · 31/10/2020 at 4:21 pm

      Yes i have, but still i need some example. Any idea ?

    Martin · 31/10/2020 at 4:24 pm

    Yes, i have, but still i need some example. Any idea?

Martin · 31/10/2020 at 4:23 pm

Yes, i have, but still i need some example. Any idea?

Martin · 11/11/2020 at 4:29 pm

Hi, After i install Home Assistant i can’t load it from the browser.
Also i’ve got this type of error in the terminal: missing:: Network Manager

When i type: sudo apt-get update && sudo apt-get -y install network-manager My RPI shut down and now it can’t turn on at all. Any help, please ?

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *