I’m tracking my household energy usage by collecting data from my energy provider, Octopus, and displaying the data in OpenHAB. The data are stored in OpenHAB’s database, InFluxDB. Both OH and Influx are running on a Raspberry Pi 4b.
I’m also capturing data from smart plugs and other smart appliances, which can post to MQ. To support this I’m running Mosquitto on the same Pi as OH.
Total Energy Usage data is being captured by two methods
- GeoHome API
This runs as a service on a server in AWS Cloud. IT connects to the Geohome API to collect meter reading which are posted directly to OpenHab items as shown below. The timestamps are necessary as the gas and electricity meter readings only update periodically (sometimes not for days).- Realtime electricity usage: HouseElectricityPower
- Realtime gas usage: HouseGasPower
- Timestamp for the above: HousePowerTimestamp
- Current electricity meter reading: HouseElectricityMeterReading
- Timestamp for that reading: HouseMeterTimestamp
- Current gas meter reading: HouseGasMeterReading
- Timestamp for that readong: GasMeterTimestamp
Source code: https://github.com/markmac99/geohome_integration
- Octopus API
This runs as a cron job on the openhab server and connects to the Octopus API to collect gas and electricity usage data. The data update every 30 minutes, with the last 30 minutes total usage in Wh or cubic meters as appropriate. The gas data are converted to Wh, and then the data are written to InfluxDB measurements “OctopusElect30m” and “OctopusGas30m”.
In addition, a second cron job runs at 5am every day and calculates a daily total for the previous day. These values are written to “DailyHouseEnergy” and “DailyHouseGas” in InfluxDB. The data are held till 5am because the gas data in particular often lags behind.
Source code: https://github.com/markmac99/octopus_integration