smeterd
smeterd copied to clipboard
Does smeterd support DSMR5?
I will soon get a new 3-phase meter supporting DSMR5.02. Is this version of the standard supported?
Hi! I was not aware of that version of the protocol while creating this package. So if it is supported it is mere coincidence.
I would like to consider adding support for it. Are you able to share some more information (documentation)?
Here's the full spec: https://www.netbeheernederland.nl/_upload/Files/Slimme_meter_15_a727fce1f1.pdf
Key differences are an electricity update frequency of 1s (was 10s) and a gas update frequency of 300s (was 1h). There may be other differences.
Hi @ot3,
I was curious is you already received your new 3-phase meter and managed to try out the current version of smeterd on it?
At first glance (based on the document you shared) I do not see any significant changes.
Hi nrocco, I have not yet received my new meter (may take a few more months due to shortages). Because there was no solution from your end, I decided to rewrite my p1.py program, using a different DSMR library. From the comments in my code:
# using dsmr_parser from Nigel Dokter @ https://github.com/ndokter/dsmr_parser
# replaces p1.py v0.99 based on smeterd from Nico Rocco
There is a significant change between DSMR2.2 and DSMR 5. Again from my code:
def build_p1_record(dsmr_version, datagram):
# use current time for electricity timestamp
dtE = int(time.time())
cT1 = float(unwrap(datagram[obis_references.ELECTRICITY_USED_TARIFF_1])) # cumulative electricity consumption counter #1 in kWh
cT2 = float(unwrap(datagram[obis_references.ELECTRICITY_USED_TARIFF_2])) # cumulative electricity consumption counter #2 in kWh
fT1 = float(unwrap(datagram[obis_references.ELECTRICITY_DELIVERED_TARIFF_1])) # cumulative electricity production counter #1 in kWh - feed-in
fT2 = float(unwrap(datagram[obis_references.ELECTRICITY_DELIVERED_TARIFF_2])) # cumulative electricity production counter #2 in kWh - feed-in
Pc = float(unwrap(datagram[obis_references.CURRENT_ELECTRICITY_USAGE])) # current power consumed in kW
Pf = float(unwrap(datagram[obis_references.CURRENT_ELECTRICITY_DELIVERY])) # current power produced in kW
Pc = int(Pc * 1000) # convert to W
Pf = int(Pf * 1000) # convert to W
if dsmr_version == 'V4' or dsmr_version == 'V5':
dtG, gas = unwrap_gas(dsmr_version, datagram[obis_references.HOURLY_GAS_METER_READING]) # gas meter timestamp & gas meter reading
elif dsmr_version == 'V2_2':
dtG, gas = unwrap_gas(dsmr_version, datagram[obis_references.GAS_METER_READING]) # gas meter timestamp & gas meter reading
p1_record = (dtE, cT1, cT2, fT1, fT2, Pc, Pf, gas, dtG)
logging.debug(p1_record)
return p1_record
Please note the IF ELIF statement where the DSMR version is checked. I did al my testing with hard coded sample datagrams for the 3 DSMR versions. I hope this helps.
Edited: See file added to last line in this post
First of all: thanks for the nice python module!
Below you find RAW logging of my DSMR5.02 meter (without a gas connection). logging_of_meter.log
I shared the logging for two reasons.
- I'm missing some information on the output of smeterd. E.g: 1-0:32.7.0(232.0V) etc. and 1-0:31.7.0(008A) etc.
- It's maybe handy to have this logging data for testing
My question, is this data not available for a reason? Perhaps it was not available on older versions of the DSMR protocol.
SHELL:~$ python -m smeterd read-meter -vvv --serial-port /dev/ttyUSB-P1 --serial-baudrate 115200
[2019-10-14 08:59:31,871] DEBUG Open serial connect to /dev/ttyUSB-P1 with: parity=E, baudrate=115200, bytesize=7, xonxoff=False, timeout=10, stopbits=1
[2019-10-14 08:59:31,887] INFO New serial connection opened to /dev/ttyUSB-P1
[2019-10-14 08:59:31,888] INFO Start reading lines
[2019-10-14 08:59:31,890] DEBUG >> 002)
[2019-10-14 08:59:31,892] DEBUG >> 1-0:1.7.0(00.000*kW)
[2019-10-14 08:59:31,893] DEBUG >> 1-0:2.7.0(02.166*kW)
[2019-10-14 08:59:31,894] DEBUG >> 0-0:96.7.21(00577)
[2019-10-14 08:59:31,895] DEBUG >> 0-0:96.7.9(00010)
[2019-10-14 08:59:31,902] DEBUG >> 1-0:99.97.0(3)(0-0:96.7.19)(180508115740S)(0000013974*s)(180403130035S)(0000001142*s)(180207091909W)(0002466530*s)
[2019-10-14 08:59:31,903] DEBUG >> 1-0:32.32.0(00005)
[2019-10-14 08:59:31,904] DEBUG >> 1-0:52.32.0(00004)
[2019-10-14 08:59:31,905] DEBUG >> 1-0:72.32.0(00004)
[2019-10-14 08:59:31,906] DEBUG >> 1-0:32.36.0(00000)
[2019-10-14 08:59:31,907] DEBUG >> 1-0:52.36.0(00000)
[2019-10-14 08:59:31,908] DEBUG >> 1-0:72.36.0(00000)
[2019-10-14 08:59:31,909] DEBUG >> 0-0:96.13.0()
[2019-10-14 08:59:31,910] DEBUG >> 1-0:32.7.0(238.0*V)
[2019-10-14 08:59:31,911] DEBUG >> 1-0:52.7.0(239.0*V)
[2019-10-14 08:59:31,918] DEBUG >> 1-0:72.7.0(239.0*V)
[2019-10-14 08:59:31,919] DEBUG >> 1-0:31.7.0(003*A)
[2019-10-14 08:59:31,920] DEBUG >> 1-0:51.7.0(002*A)
[2019-10-14 08:59:31,921] DEBUG >> 1-0:71.7.0(003*A)
[2019-10-14 08:59:31,922] DEBUG >> 1-0:21.7.0(00.000*kW)
[2019-10-14 08:59:31,923] DEBUG >> 1-0:41.7.0(00.000*kW)
[2019-10-14 08:59:31,939] DEBUG >> 1-0:61.7.0(00.000*kW)
[2019-10-14 08:59:31,940] DEBUG >> 1-0:22.7.0(00.743*kW)
[2019-10-14 08:59:31,941] DEBUG >> 1-0:42.7.0(00.562*kW)
[2019-10-14 08:59:31,942] DEBUG >> 1-0:62.7.0(00.860*kW)
[2019-10-14 08:59:31,943] DEBUG >> !FB7D
[2019-10-14 08:59:32,865] DEBUG >> /Ene5\T210-D ESMR5.0
[2019-10-14 08:59:32,865] DEBUG >>
[2019-10-14 08:59:32,866] DEBUG >> 1-3:0.2.8(50)
[2019-10-14 08:59:32,867] DEBUG >> 0-0:1.0.0(191014090301S)
[2019-10-14 08:59:32,869] DEBUG >> 0-0:96.1.1(4530303438303030303131393037363138)
[2019-10-14 08:59:32,876] DEBUG >> 1-0:1.8.1(005499.558*kWh)
[2019-10-14 08:59:32,877] DEBUG >> 1-0:1.8.2(003603.856*kWh)
[2019-10-14 08:59:32,878] DEBUG >> 1-0:2.8.1(003355.937*kWh)
[2019-10-14 08:59:32,879] DEBUG >> 1-0:2.8.2(008026.127*kWh)
[2019-10-14 08:59:32,880] DEBUG >> 0-0:96.14.0(0002)
[2019-10-14 08:59:32,891] DEBUG >> 1-0:1.7.0(00.000*kW)
[2019-10-14 08:59:32,892] DEBUG >> 1-0:2.7.0(02.164*kW)
[2019-10-14 08:59:32,893] DEBUG >> 0-0:96.7.21(00577)
[2019-10-14 08:59:32,894] DEBUG >> 0-0:96.7.9(00010)
[2019-10-14 08:59:32,899] DEBUG >> 1-0:99.97.0(3)(0-0:96.7.19)(180508115740S)(0000013974*s)(180403130035S)(0000001142*s)(180207091909W)(0002466530*s)
[2019-10-14 08:59:32,900] DEBUG >> 1-0:32.32.0(00005)
[2019-10-14 08:59:32,901] DEBUG >> 1-0:52.32.0(00004)
[2019-10-14 08:59:32,902] DEBUG >> 1-0:72.32.0(00004)
[2019-10-14 08:59:32,904] DEBUG >> 1-0:32.36.0(00000)
[2019-10-14 08:59:32,905] DEBUG >> 1-0:52.36.0(00000)
[2019-10-14 08:59:32,905] DEBUG >> 1-0:72.36.0(00000)
[2019-10-14 08:59:32,906] DEBUG >> 0-0:96.13.0()
[2019-10-14 08:59:32,909] DEBUG >> 1-0:32.7.0(238.0*V)
[2019-10-14 08:59:32,910] DEBUG >> 1-0:52.7.0(239.0*V)
[2019-10-14 08:59:32,911] DEBUG >> 1-0:72.7.0(239.0*V)
[2019-10-14 08:59:32,915] DEBUG >> 1-0:31.7.0(003*A)
[2019-10-14 08:59:32,915] DEBUG >> 1-0:51.7.0(002*A)
[2019-10-14 08:59:32,916] DEBUG >> 1-0:71.7.0(003*A)
[2019-10-14 08:59:32,920] DEBUG >> 1-0:21.7.0(00.000*kW)
[2019-10-14 08:59:32,921] DEBUG >> 1-0:41.7.0(00.000*kW)
[2019-10-14 08:59:32,923] DEBUG >> 1-0:61.7.0(00.000*kW)
[2019-10-14 08:59:32,936] DEBUG >> 1-0:22.7.0(00.745*kW)
[2019-10-14 08:59:32,937] DEBUG >> 1-0:42.7.0(00.560*kW)
[2019-10-14 08:59:32,939] DEBUG >> 1-0:62.7.0(00.858*kW)
[2019-10-14 08:59:32,939] DEBUG >> !6C88
[2019-10-14 08:59:32,939] INFO Done reading one packet (containing 35 lines)
[2019-10-14 08:59:32,940] DEBUG Total lines read from serial port: 61
[2019-10-14 08:59:32,940] DEBUG Constructing P1Packet from raw data
[2019-10-14 08:59:32,946] INFO Closing connection to `/dev/ttyUSB-P1`.
Time 2019-10-14 08:59:32.951129
Total electricity consumed (high, Wh) 3603856
Total electricity consumed (low, Wh) 5499558
Total gas consumed (m3) 0
Current electricity tariff 2
Gas measured at None
Added after original post:
/Ene5\T210-D ESMR5.0
1-3:0.2.8(50) **//Version information for P1 output**
0-0:1.0.0(191013204921S) **//Date-time stamp of the P1 message**
0-0:96.1.1(4530303438303030303131393037363138) keys['kwh']['eid'] = self.get(b'^0-0:96\.1\.1\(([^)]+)\)\r\n')
1-0:1.8.1(005491.102*kWh) keys['kwh']['low']['consumed'] = self.get_float(b'^1-0:1\.8\.1\(([0-9]+\.[0-9]+)\*kWh\)\r\n')
1-0:1.8.2(003602.765*kWh) keys['kwh']['high']['consumed'] = self.get_float(b'^1-0:1\.8\.2\(([0-9]+\.[0-9]+)\*kWh\)\r\n')
1-0:2.8.1(003355.937*kWh) keys['kwh']['low']['produced'] = self.get_float(b'^1-0:2\.8\.1\(([0-9]+\.[0-9]+)\*kWh\)\r\n')
1-0:2.8.2(008025.525*kWh) keys['kwh']['high']['produced'] = self.get_float(b'^1-0:2\.8\.2\(([0-9]+\.[0-9]+)\*kWh\)\r\n')
0-0:96.14.0(0001) keys['kwh']['tariff'] = self.get_int(b'^0-0:96\.14\.0\(([0-9]+)\)\r\n')
1-0:1.7.0(02.721*kW) keys['kwh']['current_consumed'] = self.get_float(b'^1-0:1\.7\.0\(([0-9]+\.[0-9]+)\*kW\)\r\n')
1-0:2.7.0(00.000*kW) keys['kwh']['current_produced'] = self.get_float(b'^1-0:2\.7\.0\(([0-9]+\.[0-9]+)\*kW\)\r\n')
0-0:96.7.21(00577) //Number of power failures in any phase
0-0:96.7.9(00010) //Number of long power failures in any phase
1-0:99.97.0(3)(0-0:96.7.19)(180508115740S)(0000013974*s)(180403130035S)(0000001) //Power Failure Event Log (long power failures)
1-0:32.32.0(00005) //Number of voltage sags in phase L1
1-0:52.32.0(00004) //Number of voltage sags in phase L2
1-0:72.32.0(00004) //Number of voltage sags in phase L2
1-0:32.36.0(00000) //Number of voltage swells in phase L1
1-0:52.36.0(00000) //Number of voltage swells in phase L2
1-0:72.36.0(00000) //Number of voltage swells in phase L3
0-0:96.13.0() //Text message max 1024 characters.
1-0:32.7.0(232.0*V) //Instantaneous voltage L1 in V resolution
1-0:52.7.0(235.0*V) //Instantaneous voltage L2 in V resolution
1-0:72.7.0(235.0*V) //Instantaneous voltage L3 in V resolution
1-0:31.7.0(008*A) //Instantaneous current L1 in A resolution
1-0:51.7.0(002*A) //Instantaneous current L2 in A resolution
1-0:71.7.0(001*A) //Instantaneous current L3 in A resolution
1-0:21.7.0(01.924*kW) //Instantaneous active power L1 (+P) in W resolution
1-0:41.7.0(00.552*kW) //Instantaneous active power L2 (+P) in W resolution
1-0:61.7.0(00.244*kW) //Instantaneous active power L3 (+P) in W resolution
1-0:22.7.0(00.000*kW) //Instantaneous active power L1 (-P) in W resolution
1-0:42.7.0(00.000*kW) //Instantaneous active power L2 (-P) in W resolution
1-0:62.7.0(00.000*kW) //Instantaneous active power L3 (-P) in W resolution
!61D7
/Ene5\T210-D ESMR5.0
keys['kwh']['switch'] = self.get_int(b'^0-0:96\.3\.10\((\d)\)\r\n') //Not part of spec for ESMR5.0
keys['kwh']['treshold'] = self.get_float(b'^0-0:17\.0\.0\(([0-9]{4}\.[0-9]{2})\*kW\)\r\n') //Not part of spec for ESMR5.0
keys['gas']['eid'] = self.get(b'^0-1:96\.1\.0\(([^)]+)\)\r\n') //Page 27 of spec
keys['gas']['device_type'] = self.get_int(b'^0-1:24\.1\.0\((\d)+\)\r\n') //Page 27 of spec
keys['gas']['total'] = self.get_float(b'^(?:0-1:24\.2\.1(?:\(\d+[SW]\))?)?\(([0-9]{5}\.[0-9]{3})(?:\*m3)?\)\r\n', 0) //Page 27 of spec
keys['gas']['valve'] = self.get_int(b'^0-1:24\.4\.0\((\d)\)\r\n') //Not part of spec for ESMR5.0
It would be great to get some instantaneous data.
@roykrikke thanks for sharing that data and sorry for the late reply. Not all meters currently supported expose this data.
I have added initial support for instantaneous data to the P1 packet class. See PR #27
If you use smeterd
as a python module you can now use this library to get that instantaneous data.
Great!
What do L1
, L2
, and L3
denote?
I`m on holidays, after next Monday I will have a look.
On 27 Jul 2020, 16:10, at 16:10, flatsiedatsie [email protected] wrote:
Great!
What do
L1
,L2
, andL3
denote?-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/nrocco/smeterd/issues/22#issuecomment-664419355
Hi,
Commonly those are AC phases. L1 is phase 1, and so forth.
Thanks. If a user wants to know the total current wattage that their home is consuming, does it make sense to add up those three values?
It's what I've currently implemented.
If you use smeterd as a python module you can now use this library to get that instantaneous data.
It doesn't seem to pick up the changes yet?
@nrocco great update. I restarted my the project. I was wondering if you can also make the update available through the pip installer. The current version is smeterd, version 2.9.0, would be great to have 2.9.1 available via pip.
@roykrikke I have uploaded the latest tag 2.9.1 to pypi, see https://pypi.org/project/smeterd/2.9.1/
Just to confirm, using v2.9.1 as Python module works fine for me on a DSMR 5.0.0 meter as long as you explicitly set the baudrate to 115200.
Ex:
meter = SmartMeter(port, baudrate=115200)
packet = meter.read_one_packet()
print(packet)
meter.disconnect()
In short - great work! Perhaps this issue can be closed @nrocco?
Thanks for testing and confirming @hanssens