Supplies
- Raspberry Pi Zero W and power cable (+case)
- microUSB OTG kabel
- P1 to usb cable
- Micro SD card
hard and software (except Openhab ) is for the Dutch Smart power meters with a P1 port. The techniques described can of course be used for many more things
Software: P1Monitor (https://www.ztatz.nl/)
Install P1Monitor as described on the website
In P1Monitor go to settings (wrench icon) > API
There you will find various URLs to the data from P1Monitor.
Example URL: http://IP_ADRES/api/v1/smartmeter
If you open this URL you will see a lot of data (too much).
Add, the following to the end of the URL ?limit=1&json=object&round=on
then it becomes http://IP_ADRES/api/v1/smartmeter?limit=1&json=object&round=on
If you open this URL you get a short JSON string as result:
[{"CONSUMPTION_GAS_M3": 1246, "CONSUMPTION_KWH_HIGH": 3304, "CONSUMPTION_KWH_LOW": 3187, "CONSUMPTION_W": 371, "PRODUCTION_KWH_HIGH": 0, "PRODUCTION_KWH_LOW": 0, "PRODUCTION_W": 0, "RECORD_IS_PROCESSED": 0, "TARIFCODE": "P", "TIMESTAMP_UTC": 1630327113, "TIMESTAMP_lOCAL": "2021-08-30 14:38:33"}]
See the names like CONSUMPTION_GAS_M3 and PRODUCTION_KWH_LOW in the JSON string. This names we goanna use later.
Openhab (3.x)
Install http binding
Install JSONPath Transformation ( you can find under Settings > transformations )
Things
Make a new http thing (New HTTP URL Thing)
Give the thing a name and a label for example :
Unique ID: p1monitor
Label: P1Monitor
Enter this URL as Base URL in the HTTP thing you are creating.
like the example http://p1monitor/api/v1/smartmeter?limit=1&json=object&round=on
Don’t forget to Save the Thing.
Channels
within your newly created Thing go to channels and create a new channel
Channel Identifier: power_consumption_watt
Label: Power consumption in Watt
Channel type: String Channel
Leave “State Transformation” blank, we filter the correct value at item level
repeat this for all the value in the JSON string you want to use (So create a channel for each value)
for example CONSUMPTION_GAS_M3 or CONSUMPTION_KWH_LOW
Items
Go to the channel and create a new item by pressing on de link “Add Link to Item…”
Create a new item
Give it a name, label type, ect….
Under profile choose the option “JSONPATH”
“Profile Configuration” now appears as option on the bottom of the screen
JSONPath Expression: enter $[0]. plus the value you want to filter out of the string
in this example: $[0].CONSUMPTION_W
click Link button
Now you have created an item that you can display in your preferred UI