NOTE: This app doesn’t get information out of the smartmeter , you have to use an device (a raspberry pi for example) that push data to the app.
Introduction
This app adds the P1 smartmeter into Homey and add an api to update the data. The repository https://github.com/koktaildotcom/com.p1.smartmeter-dsmr.reader reads the data from the p1 and push it to the com.p1.smartmeter api.
I use a ‘Raspberry Pi 1 Model B+’ with an p1 cable (there are types for different smartmeters) and a Mini Wireless USB WiFi Adapter (RP1 comes without wifi).
Because there are different smart meters and different versions of data they transmit there isn’t one implementation. I use a python script that i found online and push the data with a POST to the app.
Hi,
will try your app in a few days, next friday my meter will be replaced by a P1 smart meter.
I have built a small circuit to connect the smart-meter to an esp8266 device running tasmota with serial-bridge configured. My hope/goal is to use this setup to push the P1 serial messages via mqtt to Homey, or to my Domoticz server as an alternative.
Hi Koktail,
i’ve had a quick look at your app, but sadly I think this does not really fit with my setup
I have a simple esp8266 device running espeasy, which passes the full p1 telegram via ser2net, it does not parse the telegram or something similar. I was hoping for an app that would do the parsing on Homey, similar to what I currently use on HAssIO, or before on Domoticz, both running on raspberri pi.
Bummer, too bad that it does not meet your expectations. You can try to export the data from either hassio or domaticz (if they have the possibility to export data trough an REST api)
@Jeroen_Somhorst, sadly I’m currently on HassIO, Domoticz was not very stable (crashed every other day) so last weekend I switched to HassIO and I must say that it looks pretty nice compared to Domoticz (or even Homey…).
The setup with ESP8266 connected to the P1 meter however does need some modifications, the wifi on that module is not very stable so the connection is lost every now and then, and as a result the energy data has some gaps…
I will check if a beefier controller (e.g. another raspi) connected to the P1 meter would be better, I then could also use the setup with your app @Koktail, will update my results.
Small question is the Optional CRC check enabled default? or do I need to edit/run something to enable it. Looking at my output I get the feeling it’s not enabled.
I have scripting on my Raspberry that puts stuff in an RRD database, composes my usage graphs etc, but I would like to publish the information gathered to my Homey using the app there. Does somebody have a bash script or something ‘curly’ that does just the appropriate post to the Homey app from a local downloaded smarttelegram?
This 13590.7 KWh (which might be improved as kWh since a lowercase k is the correct abbreviation for kilo) is an addition of the “delivery” of tariff1 and tariff2, which puzzled me a bit at first. It’s the electricity used. Would it be an idea to put “ELECTRICITY USED” below it? And for the 4707.68 “ELECTRICITY DELIVERED” to keep it in style?
Another thing might be that my meter has no clue about gas usage. Would it be an idea to put those values as an option in a configuration field to either show or not show them?
Lot’s of questions, and I haven’t even thanked you for the work you put in. Let’s set that straight: thanks!
Not sure if this is the best place for it, but here’s the script that is feeding com.p1 from my previously (and seperately) created smarttelegram (click on the sign below for the script):
bash script used
#!/bin/bash
# This script is started via cron and sends smartmeter data to homey
# The P1.py daemon is updating the smart telegram in /tmp/smarttelegram.txt at appropriate intervals
#
# Check if smarttelegram > 0
if [ -s /tmp/smarttelegram.txt ]
then
# Get all the parameters needed
# 1-0:2.8.2 delivered_tariff2, strip all crap
tdelivered_tariff2=`/bin/grep "1-0:2.8.2" /tmp/smarttelegram.txt | /bin/sed "s/.*(//;s/\*.*//"`
delivered_tariff2=$(/usr/bin/awk "BEGIN {printf \"%.3f\",$tdelivered_tariff2}")
# 1-0:2.7.0 delivered_actual, strip all crap
tdelivered_actual=`/bin/grep "1-0:2.7.0" /tmp/smarttelegram.txt | /bin/sed "s/.*(//;s/\*.*//"`
delivered_actual=$(/usr/bin/awk "BEGIN {printf \"%.2f\",$tdelivered_actual}")
# 1-0:2.8.1 delivered_tariff1, strip all crap
tdelivered_tariff1=`/bin/grep "1-0:2.8.1" /tmp/smarttelegram.txt | /bin/sed "s/.*(//;s/\*.*//"`
delivered_tariff1=$(/usr/bin/awk "BEGIN {printf \"%.3f\",$tdelivered_tariff1}")
# 1-0:1.8.2 received_tariff2, strip all crap
treceived_tariff2=`/bin/grep "1-0:1.8.2" /tmp/smarttelegram.txt | /bin/sed "s/.*(//;s/\*.*//"`
received_tariff2=$(/usr/bin/awk "BEGIN {printf \"%.3f\",$treceived_tariff2}")
# 1-0:1.7.0 received_actual, strip all crap
treceived_actual=`/bin/grep "1-0:1.7.0" /tmp/smarttelegram.txt | /bin/sed "s/.*(//;s/\*.*//"`
received_actual=$(/usr/bin/awk "BEGIN {printf \"%.2f\",$treceived_actual}")
# 1-0:1.8.1 received_tariff2, strip all crap
treceived_tariff1=`/bin/grep "1-0:1.8.1" /tmp/smarttelegram.txt | /bin/sed "s/.*(//;s/\*.*//"`
received_tariff1=$(/usr/bin/awk "BEGIN {printf \"%.3f\",$treceived_tariff1}")
# Prepare the post data
generate_post_data()
{
cat <<EOF
{
"electricity": {
"delivered": {
"tariff2": {
"reading": $delivered_tariff2,
"unit": "kWh"
},
"actual": {
"reading": $delivered_actual,
"unit": "kW"
},
"tariff1": {
"reading": $delivered_tariff1,
"unit": "kWh"
}
},
"received": {
"tariff2": {
"reading": $received_tariff2,
"unit": "kWh"
},
"actual": {
"reading": $received_actual,
"unit": "kW"
},
"tariff1": {
"reading": $received_tariff1,
"unit": "kWh"
}
}
},
"gas": {
"reading": 0,
"unit": "m3"
}
}
EOF
}
# Send post_data with curl to homey
# a curl request with the above form and data in the proper format to
http://localip/api/app/com.p1/update
#
/usr/bin/curl -X POST -H "Content-Type: application/json" -d "$(generate_post_data)" http://192.168.1.123/api/app/com.p1/update
else
# No smarttelegram found. We have a problem. We might loop and try again, but for now: fail.
echo `/bin/date` homeyupdate failed, no smarttelegram found >> /tmp/power_insight_log.txt
fi
Basically Q&D (quick and decent enough): grep the values, awk them to their appropriate format, push them to com.p1 with a