Intro
I love gadgets. I started collecting quite a few smart / connected devices over the last years. These range from diverse lightning sources over weather, airquality, connected audio to smart plugs. All of these devices bring their own apps and are not necessary compatible with each other.
Therefore I wanted something which allows to control all devices while also allowing to build up workflows, log data and visualize graphs. After a fair amount of research and watchin youtube videos I decided to go for ioBroker.
iobroker
What you need
- Raspberry Pi
- Pi Accessoires
- Case
- Poweradaptor
- SSD (usb)
- Raspberry Pi Imager
- ioBroker
- InfluxDB
- Grafana
Preparing the Raspberry
Build up your Pi system. After installing all the hardware components its time to load your operating system on the ssd. I´m using the official Pi imaging tool .
Use the official tool to install a plain Raspberry PI Os directly to the SSD. Remember to enable ssh access and prepare your network config.
Booting from SSD
Since I´m going to use the Raspberry also as a logging device I was a little bit afraid of heavy writes to the SD card. Luckily you can upgrade you device to boot from SSD. Generally speaking a “normal” operation of the Pi runs well on a SD card but if you´re expecting a lot of writes you should be using a ssd.
It might be necessary to enable ssd boot first. If this is the case you have an old model and should just follow this guide .
Installing ioBroker
After your Pi is setup and you´re able to connect via ssh, it´s time to install ioBroker.
Steps
- SSH into you machine
ssh pi@localipadress
- Ensure your system is uptodate
sudo apt-get update && sudo apt-get upgrade
- Restart
sudo reboot
wait a few seconds until the pi reboots and ssh into again.
- Install
curl -sL https://iobroker.net/install.sh | bash -
this starts the whole installation process. It takes a few minutes but it should run smooth. At the end you´ll be shown an IP adress which you can use to login. Be aware, you need to do another reboot before.
Basic config ioBroker
After navigating to the given URL in your favourite browser ioBroker webinterface starts up and you´re prompted with some basic config.
Add a password, choose date, language, location, currency symbols etc. I´ve choosen to go for default expert mode as well.
After this ioBroker asks to perform a network scan. After this is finished it´ll list all devices it has found and suggests to install all matching adaptors. I´ve choosen to let it install all of them.
Installing and configuring first adapters
After the automatic installation I realised not all devices are there, so I searched for matching adaptors and installed them as well. For some of them (e.g.: netatmo) I needed to authenticate a special user on the webinterface. The process is pretty good in most cases. In some (e.g: Hue) the interface wasn´t optimized for darkmode and some settings were only visible in the light settings.
One special thing was the Philips air purifier. In the adaptor you need an IP to connect. Unfortunatelly the device itsself doesn´t show its IP in the APP (only a mac:adress). I needed this to figure out which device it is in the router since it doesn´t connect with a really speaking name. If you have a fritz.box you´ll need to add mac:adresses to the view.
If you use a terminal ensure you´re connected to the same wifi as the air purifier and run: If you use a terminal ensure you´re connected to the same wifi as the air purifier and run:
arp -a
there you´ll be able to get the matching IP for the mac:adress as well.
Logging and visualization
I´ve choosen ioBroker because it also offer capabilities to work as a centralized logging instance for all connected devices. For this we need a place to store the data (InfluxDB) and something which makes it easy to build up dashboards (grafana).
Installing InfluxDB
InfluxDB is a timeseries database. Normaly I would have gone for something boring (aka battleproven) like MySQL oder PostGres but in this case InfluxDB seemed like the more reasonable choice. This was due to the fact, that a lot of tutorials and ready-to-use adaptors are out there and I only want to show some timeseries data.
In order to install you need to first log into your pi and check if updates and upgrades are installed.
Install
- SSH into you machine
ssh pi@localipadress
- Ensure your system is uptodate
sudo apt-get update && sudo apt-get upgrade
- Restart
sudo reboot
wait a few seconds until the pi reboots and ssh into again.
- Add the repos to apt
First you need to add the gpg key:
curl https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /usr/share/keyrings/influxdb-archive-keyring.gpg >/dev/null
- Next add the repo:
echo "deb [signed-by=/usr/share/keyrings/influxdb-archive-keyring.gpg] https://repos.influxdata.com/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
- Update the sources:
sudo apt update
- Install
sudo apt install influxdb2
- Unmask
sudo systemctl unmask influxdb
- Add to autostart
sudo systemctl enable influxdb
- Start
sudo systemctl start influxdb
- Check if it´s running
influx version
If you see:
Influx CLI 2.6.1 (git: 61c5b4d) build_date: 2022-12-29T15:41:09Z
Yay :-D
Influxdb setup
This is pretty straight forward.
- Run
influx setup
- you are prompted to add your user, password, org (I´ve choosen my-org), a bucket name and a retention period.
> Welcome to InfluxDB 2.0!
? Please type your primary username admin
? Please type your password ************
? Please type your password again ************
? Please type your primary organization name my-org
? Please type your primary bucket name iobroker
? Please type your retention period in hours, or 0 for infinite 0
? Setup with these parameters?
Username: admin
Organization: my-org
Bucket: iobroker
Retention Period: infinite
(y/N)
confirm with yes and done.
Yes
User Organization Bucket
admin my-org iobroker
You are now also able to log into the gui. Use the IP Adress of your Raspbi with port 8086.
Connect iobroker with influx
-
Add a new adaptorinstance in iobroker. It´s called influxdb.
-
To configure your instance you need to add a token influxdb.
- Login into the influx gui
- Go to Load Data and API Tokens
- Add a new API Token and copy it (you´ll only see it once)
- Configure the instace
- Now you´re done. Choose values you want to log in you other instances. They´ll be written to your influx instance.
Now we have setup influx and logging. Next step is to add a visualization interface.
Installing Grafana
Grafana is an open source system which brings a shitload of connectors and visualizations It´s easy to setup and connect with InfluxDB. We use it at work so I know a little bit about building dashboards which also influenced my decission.
- Add the APT key used to authenticate packages:
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
- Add the Grafana repository:
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
- Install Grafana:
sudo apt-get update
sudo apt-get install -y grafana
Grafana is now installed.
- Enable the Grafana server:
sudo /bin/systemctl enable grafana-server
- Start the Grafana server:
sudo /bin/systemctl start grafana-server
Grafana is now running. Open a browser and go to IP-Adress:3000. You’re greeted with the Grafana login page.
Log in to Grafana with the default username admin, and the default password admin. Change the password for the admin user when asked.
Connect Grafana and Influx
Now it´s finally time to connect grafana with influx.
- Login to grafana
- Login to influx
Create another token (readonly is fine) - Login to grafana and add a new datasource
Summary
We now have our basic setup, a machine which runs ioBroker, InfluxDB and Grafana. The devices are connected and logging data. All in all setup took me around 4 hours and went relatively smooth.
Next steps are:
- Integrating more adaptors / devices
- Finetune Logging
- Build up some dashboards
- Setup logic on the ioBroker
Will add more blogposts in future and maybe find some usecases which might be helpful for others as well.