When I recently had to do some rewiring of my “official”, dumb electricity meter anyway, I had the opportunity and space to put in another, smart meter I bought myself directly next to it. My self-bought meter basically gives me the opportunity to get a live feed of my electricity use, split up by the 3 phases.
I’ll try to describe how I connected this to HA, because the techniques can be useful for many smart meters, not only self bought ones, but also ones supplied from the utility.
The meter I bought is an EasyMeter Q3D, because this can be fitted interchangeably with the old mechanical meters, and I had a free spot for one of those. At a cost of EUR 120 it was not that expensive either for a calibrated meter. It is readily available at Conrad
One core aspect in choosing this meter was support by vzlogger, a software component of the
volkszähler.org project. vzlogger/volkszaehler supports many electricity, gas and water meters. Unfortunately most of the website and documentation is in German. Meter types are focused on German/continental european types, but many of the standards of these things are international, so many more types should work.
To link my meter to vzlogger I needed an interface to link up my meter to a raspberry pi. Many meters have RS485 output, which is cheap and easy even on a raspberry pi, some have the very simple “S0” interface, which works too, and others have optical interfaces, like my Q3D: You need an optoelectrical reading head (basically half an optocoupler, the other one is in the meter) to get a signal to a serial line. One benefit is that thiis signal can be read out without touching any dangerous parts. I bought the Allnet ALL3688, but there are many other options, and circuit diagrams to wire up a phototransistor and a few censts wort of parts to do the same thing are floating around.
The Allnet ALL3688 works well, but it has one drawback, it needs a 12V supply. I hooked an old 8.2V phone charger: Close enough.There is a data sheet with a pinout: RJ-45 Pin1, 5 : GND, Pin 7,8 +12V, Pin3 : ser. RX. GND and Pin 3 is can be connected to a serial adapter, I have not checked the voltage, maybe even directyl to the internal Raspi serial port ttyAMA0.
To check the hardware setup I used picocom, 9600 baud, even parity, 7 data bits and got something like the following:
/ESY5Q3DA1004 V3.04
1-0:0.0.0*255(1ESY1160437500)
1-081.8.0*255(00000023,7246460*kWh)
1-0:21.7.0*255(000071.27*W)
1-0:41.7.0*255(000013.81*W)
1-0:61.7.0*255(000156.27*W)
1-0:1.7.0*255(000241.35*W)
1-0:96.5,5*255(80)
0-0:96.1.255*255(1ESY1160437500)
!
/ESY5Q3DA1004 V3.04
1-080.0.0*255(1ESY1160037500)
1-0:1.8.0*255(00000023.7247795*kWh)
1-0:21.7.0*255 000071.16*W)
1-0:01.7.0*255(000013.88*W)
1-0:61.7.0*255( 00155.09*W)
1-0:1.7.0*255(000240.13*W)
1-0:96.5.5*255(80!
0-0:96.1.255*255 1ESY1160437500)
!
one of these stanzas is sent every other second. This format could in principle parsed directly, but using vzlogger is so much nicer. vzlogger takes this format from the serial port, and makes JSON available to be chewed up by the home assistant Rest sensor. Added benefit: My meter can be read remotely over the (WiFi) network and not only over cumbersome serial cables. To do this, vzlogger needs a configuration file that describes the meter. For my Q3D this looks like:
// Meter configuration
"meters": [
{
"enabled": true, // disabled meters will be ignored (default)
"skip": false, // errors when opening meter may be ignored if enabled
"protocol": "d0", // meter protocol, see 'vzlogger -h' for full list
"device": "/dev/ttyUSB0", // meter device
"dump_file": "/var/log/d0.txt", // detailed log file for all received/transmitted data (optional)
"parity": "7E1", // Serial parity, 7E1 or 8N1
"baudrate": 9600, // Serial baud rate, typically 9600 or 300
"interval": 0, // Wartezeit in Sekunden bis neue Werte in die middleware übertragen werden
"channels": [{
"uuid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeee0",
"identifier": "1-0:1.8.0" // OBIS identifier
}, {
"uuid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeea",
"identifier": "1-0:1.7.0" // OBIS identifier
}, {
"uuid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeb",
"identifier": "1-0:21.7.0" // OBIS identifier
}, {
"uuid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeec",
"identifier": "1-0:41.7.0" // OBIS identifier
}, {
"uuid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeed",
"identifier": "1-0:61.7.0" // OBIS identifier
} ]
}
]
The uuids are choosen arbitrarily. This gives the following JSON output:
{ "version": "0.6.0", "generator": "vzlogger", "data": [ { "uuid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeee0", "last": 1469974831127, "interval": 0, "protocol": "d0", "tuples": [ [ 1469974831127, 42.678551 ] ] }, { "uuid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeea", "last": 1469974831247, "interval": 0, "protocol": "d0", "tuples": [ [ 1469974831247, 533.130000 ] ] }, { "uuid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeb", "last": 1469974831157, "interval": 0, "protocol": "d0", "tuples": [ [ 1469974831157, 342.950000 ] ] }, { "uuid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeec", "last": 1469974831188, "interval": 0, "protocol": "d0", "tuples": [ [ 1469974831188, 52.140000 ] ] }, { "uuid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeed", "last": 1469974831218, "interval": 0, "protocol": "d0", "tuples": [ [ 1469974831218, 138.040000 ] ] } ] }
and to parse this a template can be used (only the first sensor shown):
- platform: rest
resource: http://meter.local:80
value_template: >
{% for i in value_json.data %}
{% if i.uuid == "aaaaaaaa-bbbb-cccc-dddd-eeeeeee0" %}
{{ i.tuples[0][1] }}
{% endif %}
{% endfor %}
method: GET
name: ges
unit_of:measurement: "kWh"
I don’t know if this can be solved better without the “for”, but this works for me.
meter.local is the hostname of the host vzlogger runs on (a raspberry pi next to the meter)
This setup gives me almost realitme display in Home Assistant (when I switch on my oven, the additional current shows up after about 10s on the HA web interface).
“ges” is total kWh, L1, L2, L3 is the power used on the 3 phases (in Watts), P is total power in Watts.
I’ll post a few photos of the hardware in the next days.