After being massively screwed by our Flemish government (Fuck you, government!) it was time to take a closer look at our energy usage. This page describes how to monitor your usage in real time from the Fluvius smart meter using a raspberry pi. And yes, it also works if you have solar panels.
We decided to go for solar panels and a geothermal heat pump when we built our house. We were also given a smart meter, a few months before the government decided to fuck us by cancelling the system of the rollback counter which we were promised to have for nearly 15 more years.
My first idea was to simply email some screenshots to myself so I could reproduce it later if needed, but some people were interested in how I did it so I created this page as a how-to.
Initially I ran Domoticz only but I was not that impressed with its graphs so I decided to use Grafana for some graphporn.
Copy/pasted from the Domoticz wiki: Domoticz is a very light weight home automation system that lets you monitor and configure miscellaneous devices, including lights, switches, various sensors/meters like temperature, rainfall, wind, ultraviolet (UV) radiation, electricity usage/production, gas consumption, water consumption and many more. Notifications/alerts can be sent to any mobile device. Best of all, Domoticz is open source and completely free! You only need to invest in hardware.
Copy/pasted from the Grafana wiki: Grafana is a multi-platform open source analytics and interactive visualization web application. It provides charts, graphs, and alerts for the web when connected to supported data sources. Grafana Enterprise version with additional capabilities is also available. It is expandable through a plug-in system. End users can create complex monitoring dashboards using interactive query builders.
Start by installing any OS on your raspberry pi. If you are new to this I propose you stick to the Raspberry PI OS which can be found here.
Once installed it might be a good idea to update your OS first. Launch the following command: sudo apt update && sudo apt upgrade .
Install Domoticz by issuing this command: curl -L https://install.domoticz.com | bash .
Connect your P1-to-USB cable between your raspberry pi's USB port and the P1 port of your Fluvius smart meter.
Make sure your raspberry pi is connected to the network (wired or wireless).
This chapter describes the necessary steps to configure Domoticz to see your real time usage. On any other computer in your network point your browser of choice to https://CHANGE.TO.RASPBERRYPI.IPADDRESS:443.
Once logged in into Domoticz go to Setup --> Hardware. Enter the details as below:
Now in Domoticz go to Setup --> Devices. Your smart meter should now be listed. You can click on the green arrows on the right side if you want to see graphs related to this device. As we also have gas in our house for cooking (Lacanche <3) but not as our heating source, so I added both the Energy and Gas meters. You will notice the green arrows become blue once you clicked them.
If you go to Utility in your Domoticz menu you will now see the 2 graphs you enabled. If you click on the small stars they will be added to your main dashboard.
For a detailled graph, go to Utility, click on the Log-button of Power and prepare to be amazed :)
On a sunny day when your solar panels are working as it should you will see a negative usage of electricity. In the graph above you can see the "return" line is green. This is the injected generated (so not used) solar energy.
As I don't have a fixed IP I created an account on https://www.noip.com/. Their free plan is good enough but a signup is required. Create a new host, for example mydomoticz.hopto.org. Remember the username, password etc because you need it later.
Install the ddclient on your raspberry pi: sudo apt install ddclient .
Edit /etc/ddclient.conf and fill in the correct details:
protocol=dyndns2
use=web, if=eth0
server=dynupdate.no-ip.com
login=YOUR_USERNAME
password='YOUR_PASSWORD'
mydomoticz.hopto.org
It's important you set use=web so it uses your external IP, and not your internal IP address.
Now if you have a cool domain such www.elitedomain.org and you have access to its DNS settings, then create a CNAME myenergy.elitedomain.org which points to mydomoticz.hopto.org.
Forward port 443 your router and NAT it to the IP of your raspberry pi. This way you can access Domoticz from anywhere in the world at https://myenergy.elitedomain.org.
Install the Domoticz app on your smartphone and point it to https://myenergy.elitedomain.org or browse to that URL. It uses a self-signed SSL certificate so your browser will complain. Maybe I will update this later to LetsEncrypt.
Another way to protect your Domoticz environment now its accessible via the web is by creating a user and password. Go to Setup --> Settings and under "Website Protection" a username and password can be added. You will need to login again for this to work.
If you are like me and you think the graphs of Domoticz are quite ugly, I have some good news. Domoticz is capable of exporting its data to InfluxDB. This can can be added as a data source into Grafana to create the most beautiful dashboard you have ever seen. It also allows you to add custom graphs, for example the CPU load of your raspberry pi.
This chapter describes the necessary steps to output Domoticz readings into InfluxDB, which we will then add to Grafana as a data source.
Let's start by installing InfluxDB. Enter the following commands as root on your raspberry pi.
Import the key of the InfluxDB repo: wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -You have now succesfully installed InfluxDB on your raspberry pi. Let's continue with Grafana's installation.
This chapter describes how Grafana can be installed.
Install the following tools first: sudo apt-get install -y apt-transport-https && sudo apt-get install -y software-properties-common wgetAt this point both InfluxDB and Grafana are succesfully installed.
In Domoticz, go to Setup --> More Options --> Data push --> InfluxDB. Here you can find the different devices and configure your InfluxDB instance.
At the bottom, enter the details of your InfluxDB. The IP should be the internal IP of your raspberry pi. 'Localhost' will probably work too. 8086 is the default port. If you followed this tutorial you created a user called 'admin' with YOUR_PASSWORD as password. Enter those details too, click Enabled and click Save.
Now you need to add your devices to InfluxDB. Select the device and the value you want to send, and click Add. Make sure you select Link Active too each time! If you added them all it will look like this:
Surf to http://IP.OF.RASPBERRY.PI:3000/ . Login with admin/admin. The first time Grafana will ask you to change your Grafana password. Once in Grafana go to Configuration (the gear-icon) --> Data Sources.
Add InfluxDB as its source and fill in the details as shown in the screenshot. Again, use the 'admin' user with YOUR_PASSWORD you created earlier. Finally click on Save & Test.
Great! Grafana is now able to use InfluxDB as its source. It's time to create some graph.
Grafana allows you to create your own dashboard which consists of multiple graphs. Click on the Plus sign (+) and select Dashboard. Then click the Add new panel button.
You are now in the Edit Panel of your very first graph. It might look a bit overwhelming but it's actually pretty intuitive.
Say you want to create a graph that shows you how much energy you injected in the grid, then change the "select measurement" to "Delivery-current". Notice how the graph is shown immediately. It's also wise to add a normal titel for your graph. Click Apply in the upper right corner and your very first graph is now added!.
When you are finished creating all the graphs you want, save that dashboard by clicking the Save-icon on top.
And for those who are wondering, this is how my dashboard looks. Notice how we started using electricity of the grid again once our solar panels weren't delivering enough energy any more.
Nope.