Add D0 USB Support for my Landis en Gyr ZME120Acd with optic

Post Reply
jossie67
Posts: 86
Joined: Wednesday 31 December 2014 13:47
Target OS: Raspberry Pi
Domoticz version:
Contact:

Add D0 USB Support for my Landis en Gyr ZME120Acd with optic

Post by jossie67 » Friday 06 February 2015 18:28

Hi,

I want to add support for a D0 USB Optical the Electric meter.
But I want to use the "S0 Meter USB" and the "P1 Smart Meter USB" as a sort of guide line.
I with files can I find the information for that?

Jos
Raspberry Pi (3x)
Master Domoticz installed on a Synology
RFXCOM RFXtrx433E USB
RFLink
USB Z-Wave Mini Adapter
Mi-light
QuinLED
Landis+Gyr ZME120ACd
Kamstrup_M401
USB-IR-Schreib-Lesekopf Alecto WS1700
Watermeter with TCRT5000
Kodi
DS18B20

geezerrr
Posts: 126
Joined: Tuesday 02 December 2014 23:16
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with o

Post by geezerrr » Thursday 12 February 2015 20:43

I'm interested as well!

jossie67
Posts: 86
Joined: Wednesday 31 December 2014 13:47
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with o

Post by jossie67 » Thursday 12 February 2015 23:18

I have created a python script, that is reading the power meter. And send the informatie to dummy meter with json.
The script isn't perfect yet, I'm testing it
Raspberry Pi (3x)
Master Domoticz installed on a Synology
RFXCOM RFXtrx433E USB
RFLink
USB Z-Wave Mini Adapter
Mi-light
QuinLED
Landis+Gyr ZME120ACd
Kamstrup_M401
USB-IR-Schreib-Lesekopf Alecto WS1700
Watermeter with TCRT5000
Kodi
DS18B20

geezerrr
Posts: 126
Joined: Tuesday 02 December 2014 23:16
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with o

Post by geezerrr » Friday 13 February 2015 11:28

That’s something I want to do as well. I found out that I have to send a command to my meter ( /?!) before its sending information back.
I wish I had more knowledge of scripting but unfortunately not.. (yet)

I’ve tested my optical probe (iec-62056-21) on a windows platform and it work as it suppose to.

Is it technically possible to send commands to my meter using a python script?
And do you want to share your script..? so can play around to get it working?

jossie67
Posts: 86
Joined: Wednesday 31 December 2014 13:47
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with o

Post by jossie67 » Friday 13 February 2015 11:46

Yes,
I send the information to Domoticz with
http://'+domoticzserver+'/json.htm?type=command&param=udevice&idx=86&svalue='+power_used_con_str+';'+power_used_num.


Here is my code.
I know the script can be much beter. And I have to learn a lot.
But that is just the fun of it

Code: Select all


#
# Landis & Gyr uitlezen
# Release 4.0/
# Author J. Jeurissen
# Orgineel van J. van der Linde
# Copyright (c) 2012/2013 J. Jeurissen & J. van der Linde
# Phyton 3
version = "v4.0 Landis & Gyr  ttyAMA0"
import sys
import serial
import datetime
import time
import csv
import locale
import os
import urllib
import urllib.request
import json
import base64

time.sleep(5)

#########################################
#Main program
#########################################

# Settings for the domoticz server
domoticzserver="192.168.10.33:8080"
domoticzusername = ""
domoticzpassword = ""

# Read previous value power_used_num
power_used_prev = open("/root/elec/value.txt").read()
#print (power_used_prev)
power_delivered_prev = open("/root/elec/sun.txt").read()


#Set initial COM port config
ser = serial.Serial()
ser.baudrate = 300
ser.bytesize=serial.SEVENBITS
ser.parity=serial.PARITY_EVEN
ser.stopbits=serial.STOPBITS_ONE
ser.xonxoff=0
ser.rtscts=0
ser.timeout=20
ser.port="/dev/ttyUSB0"

#Show startup arguments
port="/dev/ttyUSB0"  

#print ("Open COM port at initial baudrate")   
#Open COM port
ser.open()

print ("------------------")
 
#Initialize
#print ("Send initialize")
ir_command='/?!\x0D\x0A'
ser.write(ir_command.encode('utf-8'))
ser.flush()
#Wait for initialize confirmation
#/[XXX] [Z] MCC [CR] [LF]   /KAM0MCC[CR][LF]
# XXX is manufacturer string
ir_buffer = ''
while '/' not in ir_buffer:
    ir_buffer = str(ser.readline(), "utf-8")
    if '/?!\x0D\x0A' in ir_buffer:
        ir_buffer = str(ser.readline(), "utf-8")
#print ("Initialize complete.")
ir_lines = ir_buffer.strip().split('\r\n')
#print (ir_lines[0])
ir_speed = ir_buffer[4:5]
if ir_speed == '0': ir_baud = "300"
else: ir_baud  = "unknown"

#print ("Manufacturer FLAG ID: %s" % ir_buffer[1:4])
ir_speed = '0'
ir_baud = "300"
#Acknowledge to 300baud
#[ACK]0[Z][Y] [CR] [LF]
# Z is the baudrate, take the same value as B in the previous answer
# Y can be 0 or 1. Value 0 sets the actual meterreading mode, Value 1 sets the programming mode
#

ir_command='\x060'+ir_speed+'0\x0D\x0A'
ser.write(ir_command.encode('utf-8'))
ser.flush()

#Wait for data
ir_buffer = ''
ir_lines_index = 0
ETX = False
#print(ir_lines[ir_lines_index]) 
while not ETX:
    ir_buffer = str(ser.readline(), "utf-8")
    if '\x060' in ir_buffer:
        ir_buffer = str(ser.readline(), "utf-8")
    if '!' in ir_buffer:
        ETX = True
    ir_lines.extend(ir_buffer.strip().split('\r\n'))
    ir_lines_index = ir_lines_index + 1
    #print(ir_lines[ir_lines_index])
#print ("Datatransfer complete.")
#print ("Number of received elements: %d" % len(ir_lines))
#print ("Array of received elements: %s" % ir_lines)
    
#Close port and show status
ser.close()



#################################################################
# Process data Only need Array 5 and 6                          #
#################################################################           
power_timestamp=datetime.datetime.strftime(datetime.datetime.today(), "%Y-%m-%d %H:%M:%S" )
power_data = ir_lines
power_used = power_data[5]
power_delivered = power_data[6]


#################################################################
# Remove 1.8.2 /2.8.2 . *kWh)                                                 #
#################################################################           
power_used_num = power_used
power_used_num = power_used_num.replace('*kWh','0')
power_used_num = power_used_num.replace('1.8.2','')
power_used_num = power_used_num.replace('(','')
power_used_num = power_used_num.replace(')','')
power_used_num = power_used_num.replace('.','')
print (power_used_num)

power_delivered_num = power_delivered
power_delivered_num = power_delivered_num.replace('*kWh','0')
power_delivered_num = power_delivered_num.replace('2.8.2','')
power_delivered_num = power_delivered_num.replace('(','')
power_delivered_num = power_delivered_num.replace(')','')
power_delivered_num = power_delivered_num.replace('.','')
print (power_delivered_num)

print ("Telegram ontvangen op: %s" % power_timestamp)

#################################################################
# calculate power consumption 60/5 = 12
################################################################# 
power_used_con = (int(power_used_num))-(int(power_used_prev))
power_used_con_str = str (power_used_con*12)
print (power_used_con_str)

power_delivered_con = (int(power_delivered_num))-(int(power_delivered_prev))
power_delivered_con_str = str (power_delivered_con*12)
print (power_delivered_con_str)


#################################################################
# Store value power_used_num and power_delivered_num
# in to file
#################################################################   

with open("/root/elec/value.txt", "w") as fh:
    fh.write(power_used_num)

with open("/root/elec/sun.txt", "w") as fh:
    fh.write(power_delivered_num)

#################################################################
# Send to Domoticz
#################################################################   
domoticzurl1 = 'http://'+domoticzserver+'/json.htm?type=command&param=udevice&idx=86&svalue='+power_used_con_str+';'+power_used_num
domoticzurl2 = 'http://'+domoticzserver+'/json.htm?type=command&param=udevice&idx=87&svalue='+power_delivered_con_str+';'+power_delivered_num
domoticzurl3 = 'http://192.168.10.30/json.htm?type=command&param=udevice&idx=6&svalue='+power_used_num
domoticzurl4 = 'http://192.168.10.30/json.htm?type=command&param=udevice&idx=87&svalue='+power_delivered_num

# Domoticz prod 
req = urllib.request.urlopen(domoticzurl1)
html1 = req.read()
print (html1)
req = urllib.request.urlopen(domoticzurl2)
html2 = req.read()
print (html2)

# Domoticz Dev
#req = urllib.request.urlopen(domoticzurl3)
#html1 = req.read()
#print (html3)
#req = urllib.request.urlopen(domoticzurl4)
#html2 = req.read()
#print (html4)




Raspberry Pi (3x)
Master Domoticz installed on a Synology
RFXCOM RFXtrx433E USB
RFLink
USB Z-Wave Mini Adapter
Mi-light
QuinLED
Landis+Gyr ZME120ACd
Kamstrup_M401
USB-IR-Schreib-Lesekopf Alecto WS1700
Watermeter with TCRT5000
Kodi
DS18B20

geezerrr
Posts: 126
Joined: Tuesday 02 December 2014 23:16
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with o

Post by geezerrr » Friday 13 February 2015 12:13

Thanks a lot!

I will spend some time to understand the python language.. and give it a try.
First I need to celebrate “Carnaval” if I start studying before, for sure everything I’ve learned will be gone because of all the beers… :lol:

RonDomo
Posts: 1
Joined: Tuesday 10 March 2015 11:57
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with o

Post by RonDomo » Tuesday 10 March 2015 12:02

Kun je met dit script ook de software van de meter wijzigen ?

geezerrr
Posts: 126
Joined: Tuesday 02 December 2014 23:16
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with o

Post by geezerrr » Tuesday 10 March 2015 16:27

I don't think you can change the software from the supplier.. But why you want to change it anyway?

geezerrr
Posts: 126
Joined: Tuesday 02 December 2014 23:16
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with optic

Post by geezerrr » Sunday 06 March 2016 22:28

jossie67 wrote:Yes,
I send the information to Domoticz with
http://'+domoticzserver+'/json.htm?type=command&param=udevice&idx=86&svalue='+power_used_con_str+';'+power_used_num.


Here is my code.
I know the script can be much beter. And I have to learn a lot.
But that is just the fun of it

Code: Select all


#
# Landis & Gyr uitlezen
# Release 4.0/
# Author J. Jeurissen
# Orgineel van J. van der Linde
# Copyright (c) 2012/2013 J. Jeurissen & J. van der Linde
# Phyton 3
version = "v4.0 Landis & Gyr  ttyAMA0"
import sys
import serial
import datetime
import time
import csv
import locale
import os
import urllib
import urllib.request
import json
import base64

time.sleep(5)

#########################################
#Main program
#########################################

# Settings for the domoticz server
domoticzserver="192.168.10.33:8080"
domoticzusername = ""
domoticzpassword = ""

# Read previous value power_used_num
power_used_prev = open("/root/elec/value.txt").read()
#print (power_used_prev)
power_delivered_prev = open("/root/elec/sun.txt").read()


#Set initial COM port config
ser = serial.Serial()
ser.baudrate = 300
ser.bytesize=serial.SEVENBITS
ser.parity=serial.PARITY_EVEN
ser.stopbits=serial.STOPBITS_ONE
ser.xonxoff=0
ser.rtscts=0
ser.timeout=20
ser.port="/dev/ttyUSB0"

#Show startup arguments
port="/dev/ttyUSB0"  

#print ("Open COM port at initial baudrate")   
#Open COM port
ser.open()

print ("------------------")
 
#Initialize
#print ("Send initialize")
ir_command='/?!\x0D\x0A'
ser.write(ir_command.encode('utf-8'))
ser.flush()
#Wait for initialize confirmation
#/[XXX] [Z] MCC [CR] [LF]   /KAM0MCC[CR][LF]
# XXX is manufacturer string
ir_buffer = ''
while '/' not in ir_buffer:
    ir_buffer = str(ser.readline(), "utf-8")
    if '/?!\x0D\x0A' in ir_buffer:
        ir_buffer = str(ser.readline(), "utf-8")
#print ("Initialize complete.")
ir_lines = ir_buffer.strip().split('\r\n')
#print (ir_lines[0])
ir_speed = ir_buffer[4:5]
if ir_speed == '0': ir_baud = "300"
else: ir_baud  = "unknown"

#print ("Manufacturer FLAG ID: %s" % ir_buffer[1:4])
ir_speed = '0'
ir_baud = "300"
#Acknowledge to 300baud
#[ACK]0[Z][Y] [CR] [LF]
# Z is the baudrate, take the same value as B in the previous answer
# Y can be 0 or 1. Value 0 sets the actual meterreading mode, Value 1 sets the programming mode
#

ir_command='\x060'+ir_speed+'0\x0D\x0A'
ser.write(ir_command.encode('utf-8'))
ser.flush()

#Wait for data
ir_buffer = ''
ir_lines_index = 0
ETX = False
#print(ir_lines[ir_lines_index]) 
while not ETX:
    ir_buffer = str(ser.readline(), "utf-8")
    if '\x060' in ir_buffer:
        ir_buffer = str(ser.readline(), "utf-8")
    if '!' in ir_buffer:
        ETX = True
    ir_lines.extend(ir_buffer.strip().split('\r\n'))
    ir_lines_index = ir_lines_index + 1
    #print(ir_lines[ir_lines_index])
#print ("Datatransfer complete.")
#print ("Number of received elements: %d" % len(ir_lines))
#print ("Array of received elements: %s" % ir_lines)
    
#Close port and show status
ser.close()



#################################################################
# Process data Only need Array 5 and 6                          #
#################################################################           
power_timestamp=datetime.datetime.strftime(datetime.datetime.today(), "%Y-%m-%d %H:%M:%S" )
power_data = ir_lines
power_used = power_data[5]
power_delivered = power_data[6]


#################################################################
# Remove 1.8.2 /2.8.2 . *kWh)                                                 #
#################################################################           
power_used_num = power_used
power_used_num = power_used_num.replace('*kWh','0')
power_used_num = power_used_num.replace('1.8.2','')
power_used_num = power_used_num.replace('(','')
power_used_num = power_used_num.replace(')','')
power_used_num = power_used_num.replace('.','')
print (power_used_num)

power_delivered_num = power_delivered
power_delivered_num = power_delivered_num.replace('*kWh','0')
power_delivered_num = power_delivered_num.replace('2.8.2','')
power_delivered_num = power_delivered_num.replace('(','')
power_delivered_num = power_delivered_num.replace(')','')
power_delivered_num = power_delivered_num.replace('.','')
print (power_delivered_num)

print ("Telegram ontvangen op: %s" % power_timestamp)

#################################################################
# calculate power consumption 60/5 = 12
################################################################# 
power_used_con = (int(power_used_num))-(int(power_used_prev))
power_used_con_str = str (power_used_con*12)
print (power_used_con_str)

power_delivered_con = (int(power_delivered_num))-(int(power_delivered_prev))
power_delivered_con_str = str (power_delivered_con*12)
print (power_delivered_con_str)


#################################################################
# Store value power_used_num and power_delivered_num
# in to file
#################################################################   

with open("/root/elec/value.txt", "w") as fh:
    fh.write(power_used_num)

with open("/root/elec/sun.txt", "w") as fh:
    fh.write(power_delivered_num)

#################################################################
# Send to Domoticz
#################################################################   
domoticzurl1 = 'http://'+domoticzserver+'/json.htm?type=command&param=udevice&idx=86&svalue='+power_used_con_str+';'+power_used_num
domoticzurl2 = 'http://'+domoticzserver+'/json.htm?type=command&param=udevice&idx=87&svalue='+power_delivered_con_str+';'+power_delivered_num
domoticzurl3 = 'http://192.168.10.30/json.htm?type=command&param=udevice&idx=6&svalue='+power_used_num
domoticzurl4 = 'http://192.168.10.30/json.htm?type=command&param=udevice&idx=87&svalue='+power_delivered_num

# Domoticz prod 
req = urllib.request.urlopen(domoticzurl1)
html1 = req.read()
print (html1)
req = urllib.request.urlopen(domoticzurl2)
html2 = req.read()
print (html2)

# Domoticz Dev
#req = urllib.request.urlopen(domoticzurl3)
#html1 = req.read()
#print (html3)
#req = urllib.request.urlopen(domoticzurl4)
#html2 = req.read()
#print (html4)




Hi Jossie67,

Have you ever finished the project above?
Still have an optical probe, and played around a little with your script but my programming skills are quite little.

By now the script sends some data to do Dominicz but it's not the same as the actual as on my meter.

jossie67
Posts: 86
Joined: Wednesday 31 December 2014 13:47
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with optic

Post by jossie67 » Tuesday 08 March 2016 14:43

geezerrr wrote:
Hi Jossie67,

Have you ever finished the project above?
Still have an optical probe, and played around a little with your script but my programming skills are quite little.

By now the script sends some data to do Dominicz but it's not the same as the actual as on my meter.
Yes, It working fine for me.
Do you have only a Landis en Gyr ZME120Acd? I have also a stadsverwarming with a Opti prob.

I will try to help you
Raspberry Pi (3x)
Master Domoticz installed on a Synology
RFXCOM RFXtrx433E USB
RFLink
USB Z-Wave Mini Adapter
Mi-light
QuinLED
Landis+Gyr ZME120ACd
Kamstrup_M401
USB-IR-Schreib-Lesekopf Alecto WS1700
Watermeter with TCRT5000
Kodi
DS18B20

geezerrr
Posts: 126
Joined: Tuesday 02 December 2014 23:16
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with optic

Post by geezerrr » Tuesday 08 March 2016 19:45

I've started this topic some time ago..

viewtopic.php?t=5293

But not much interest until now..
So it's a different meter but the "same" protocol I think.

gerb
Posts: 3
Joined: Friday 18 March 2016 23:48
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with optic

Post by gerb » Monday 21 March 2016 10:26

I used Jossie67's script to push data from my ISKRA ME162 "bruto productiemeter" (which is only measuring my solar output), read with an optical probe bought at http://www.smartmeterdashboard.nl/webshop , "IR Converter Cable", to my domoticz server running on my Pi. I did this:
  • Setup - hardware - create new "dummy" device
  • Setup - hardware: at the new dummy device: create virtual sensors: Type "Electric: instant + counter"
  • Setup - devices: check which Idx the new device has (for instance, 15)
I then adapted Jossie67's script with the following main differences:
  • use ttyUSB1
  • use my own temp dir
  • use output line 2.8.2 and don't add a zero
  • use only the power_delivered variables
  • use localhost:8080 as domoticz server
  • use idx 15 as my dummy "Electric (instant + counter)" device in the "Send to domoticz" URL
Also, I used a soft link from /home/pietje/bpmeter to /run/bpmeter to be nice to the SD card in the Pi. This because the /run dir is in ramdisk and therefore it doesn't wear out the SD card by constantly writing to the same file again and again.

This is the code I use:

Code: Select all

#
# Landis & Gyr uitlezen
# Release 4.0/
# Author J. Jeurissen
# Orgineel van J. van der Linde
# Copyright (c) 2012/2013 J. Jeurissen & J. van der Linde
# Phyton 3
version = "v4.1 Iskra ME 162  ttyUSB1"
import sys
import serial
import datetime
import time
import csv
import locale
import os
import urllib
import urllib.request
import json
import base64

time.sleep(5)

#########################################
#Main program
#########################################

# Settings for the domoticz server
domoticzserver="127.0.0.1:8080"
domoticzusername = ""
domoticzpassword = ""

power_delivered_prev = open("/home/pietje/bpmeter/sun.txt").read()

#Set initial COM port config
ser = serial.Serial()
ser.baudrate = 300
ser.bytesize=serial.SEVENBITS
ser.parity=serial.PARITY_EVEN
ser.stopbits=serial.STOPBITS_ONE
ser.xonxoff=0
ser.rtscts=0
ser.timeout=20
ser.port="/dev/ttyUSB1"

#Show startup arguments
port="/dev/ttyUSB1"

#print ("Open COM port at initial baudrate")
#Open COM port
ser.open()

#print ("------------------")

#Initialize
#print ("Send initialize")
ir_command='/?!\x0D\x0A'
ser.write(ir_command.encode('utf-8'))
ser.flush()
#Wait for initialize confirmation
#/[XXX] [Z] MCC [CR] [LF]   /KAM0MCC[CR][LF]
# XXX is manufacturer string
ir_buffer = ''
while '/' not in ir_buffer:
    ir_buffer = str(ser.readline(), "utf-8")
    if '/?!\x0D\x0A' in ir_buffer:
        ir_buffer = str(ser.readline(), "utf-8")
#print ("Initialize complete.")
ir_lines = ir_buffer.strip().split('\r\n')
#print (ir_lines[0])
ir_speed = ir_buffer[4:5]
if ir_speed == '0': ir_baud = "300"
else: ir_baud  = "unknown"

#print ("Manufacturer FLAG ID: %s" % ir_buffer[1:4])
ir_speed = '0'
ir_baud = "300"
#Acknowledge to 300baud
#[ACK]0[Z][Y] [CR] [LF]
# Z is the baudrate, take the same value as B in the previous answer
# Y can be 0 or 1. Value 0 sets the actual meterreading mode, Value 1 sets the programming mode
#

ir_command='\x060'+ir_speed+'0\x0D\x0A'
ser.write(ir_command.encode('utf-8'))
ser.flush()

#Wait for data
ir_buffer = ''
ir_lines_index = 0
ETX = False
#print(ir_lines[ir_lines_index])
while not ETX:
    ir_buffer = str(ser.readline(), "utf-8")
    if '\x060' in ir_buffer:
        ir_buffer = str(ser.readline(), "utf-8")
    if '!' in ir_buffer:
        ETX = True
    ir_lines.extend(ir_buffer.strip().split('\r\n'))
    ir_lines_index = ir_lines_index + 1
    #print(ir_lines[ir_lines_index])
#print ("Datatransfer complete.")
#print ("Number of received elements: %d" % len(ir_lines))
#print ("Array of received elements: %s" % ir_lines)

#Close port and show status
ser.close()



#################################################################
# Process data Only need Array 5 and 6                          #
#################################################################
power_timestamp=datetime.datetime.strftime(datetime.datetime.today(), "%Y-%m-%d %H:%M:%S" )
power_data = ir_lines
#power_used = power_data[5]
power_delivered = power_data[8]


#################################################################
# Remove 1.8.2 /2.8.2 . *kWh)                                                 #
#################################################################
power_delivered_num = power_delivered
power_delivered_num = power_delivered_num.replace('*kWh','')
power_delivered_num = power_delivered_num.replace('2.8.2','')
power_delivered_num = power_delivered_num.replace('(','')
power_delivered_num = power_delivered_num.replace(')','')
power_delivered_num = power_delivered_num.replace('.','')
#print (power_delivered_num)

#print ("Telegram ontvangen op: %s" % power_timestamp)

#################################################################
# calculate power consumption 60/2 = 30 (elke twee minuten loggen)
#################################################################
power_delivered_con = (int(power_delivered_num))-(int(power_delivered_prev))
power_delivered_con_str = str (power_delivered_con*30)
#print (power_delivered_con_str)


#################################################################
# Store value power_used_num and power_delivered_num
# in to file
#################################################################

with open("/home/pietje/bpmeter/sun.txt", "w") as fh:
    fh.write(power_delivered_num)

#################################################################
# Send to Domoticz
#################################################################
domoticzurl2 = 'http://'+domoticzserver+'/json.htm?type=command&param=udevice&idx=15&svalue='+power_delivered_con_str+';'+power_delivered_num

# Domoticz prod
req = urllib.request.urlopen(domoticzurl2)
I used cron to run the script every other minute, from 5:00 am until 22:58 pm:

Code: Select all

*/2 5-22 * * *  /usr/bin/python3 /home/pietje/bin/bpmeter-to-domoticz.py
As a last thing I set to zero the lines with the very high values from the meter_calendar table from domoticz.db, (the values representing the current value), because otherwise these values would dwarf the next measured values and you won't see any detail about them. I stopped the domoticz server, used a sqlite editor to remove the values, saved the database and started domoticz again. Now my measurements start at 0, but I still have a value for the total. My measurements started last Friday night.
Capture.PNG
Capture.PNG (21.45 KiB) Viewed 2967 times
Graph:
http://imgur.com/cUTUapF

Dlanor
Posts: 103
Joined: Sunday 22 March 2015 17:18
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with optic

Post by Dlanor » Sunday 21 August 2016 12:25

Can any one share an example what will be stored in the text files like value.txt / sun.txt?
Domoticz | Dashticz V2 | Raspberry Pi | RFXCOM RFXtrx433E USB | RFlink 433Mhz | SONOFF

Dlanor
Posts: 103
Joined: Sunday 22 March 2015 17:18
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Add D0 USB Support for my Landis en Gyr ZME120Acd with optic

Post by Dlanor » Sunday 09 September 2018 10:44

I have used the script by Jossie67 and get the following error.

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 490, in read 'device reports readiness to read but returned no data '
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "smartmeter5.py", line 95, in <module>
    ir_buffer = str(ser.readline(), "utf-8")
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 497, in read raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
Any idea how to solve?
Domoticz | Dashticz V2 | Raspberry Pi | RFXCOM RFXtrx433E USB | RFlink 433Mhz | SONOFF

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest