smeterd icon indicating copy to clipboard operation
smeterd copied to clipboard

Error with EHz-P: What does this mean? Any ideas?

Open apassler opened this issue 5 years ago • 7 comments

smeterd read-meter -vvv --serial-port /dev/ttyUSB0 --baudrate 9600 --serial-baudrate 9600 --serial-bytesize 8 --serial-parity N --serial-stopbits 1 [2020-01-04 11:27:59,029] DEBUG Open serial connect to /dev/ttyUSB0 with: parity=N, baudrate=9600, bytesize=8, xonxoff=False, timeout=10, stopbits=1.0 [2020-01-04 11:27:59,035] INFO New serial connection opened to /dev/ttyUSB0 [2020-01-04 11:27:59,037] INFO Start reading lines [2020-01-04 11:27:59,103] ERROR 'ascii' codec can't decode byte 0xb7 in position 1: ordinal not in range(128) [2020-01-04 11:27:59,104] ERROR Read a total of 0 lines [2020-01-04 11:27:59,105] INFO Closing connection to /dev/ttyUSB0. Traceback (most recent call last): File "/usr/local/bin/smeterd", line 9, in load_entry_point('smeterd==2.8.1', 'console_scripts', 'smeterd')() File "build/bdist.linux-armv7l/egg/smeterd/cli/init.py", line 22, in parse_and_run File "build/bdist.linux-armv7l/egg/smeterd/cli/read_meter.py", line 73, in run File "build/bdist.linux-armv7l/egg/smeterd/meter.py", line 79, in read_one_packet smeterd.meter.SmartMeterError: 'ascii' codec can't decode byte 0xb7 in position 1: ordinal not in range(128)

apassler avatar Jan 04 '20 10:01 apassler

Hi @apassler

Thanks for sharing your findings here. In order to better understand this issue and to add support for EHz-P to smeterd I need more information.

  1. Does it work with other libraries or scripts you found on the internet?

  2. Are you sure all the connection settings are correct for this model (documentation?)

nrocco avatar Jan 04 '20 18:01 nrocco

Thank you for your quick respond! I didn't realy expect this so quickly.

  1. I also tested vzlogger with no success.

  2. I read the documentation on https://www.emh-metering.de/produkte/smart-meter/ehz I also tested this script:

#!/usr/bin/python import sys import serial import time

port = serial.Serial( port='/dev/ttyUSB0', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS )

data = ''

start = '1b1b1b1b01010101' for i in range (0, 1000): char = port.read() data = data + char.encode('HEX') pos = data.find(start) if (pos <> -1): data = data[pos:len(data)]

file = open('sample01', 'w') file.write(data) file.close()

results in sample01:

sample01.txt

apassler avatar Jan 06 '20 19:01 apassler

Hi together,

I have the same issue.

smeterd read-meter -vvv --serial-port /dev/ttyUSB0 --baudrate 9600 --serial-baudrate 9600 --serial-bytesize 8 --serial-parity N --serial-stopbits 1 [2020-02-20 21:37:59,112] DEBUG Open serial connect to /dev/ttyUSB0 with: baudrate=9600, bytesize=8, parity=N, stopbits=1.0, xonxoff=False, timeout=10 [2020-02-20 21:37:59,118] INFO New serial connection opened to /dev/ttyUSB0 [2020-02-20 21:37:59,118] INFO Start reading lines [2020-02-20 21:37:59,161] ERROR 'ascii' codec can't decode byte 0xe1 in position 5: ordinal not in range(128) [2020-02-20 21:37:59,161] ERROR Read a total of 0 lines [2020-02-20 21:37:59,162] INFO Closing connection to /dev/ttyUSB0.

If I use the Emlog testing software I got a byte string and the information about the baudrate is 9600 8N1.

The datalogger runs in my home automation smartVISU under the following plugin.

[https://github.com/smarthomeNG/plugins/tree/master/smlx]

Maybe it helps for analysis.

Many thanks.

simikuen avatar Feb 20 '20 20:02 simikuen

I'm also seeing 'ascii' codec can't decode byte 0xc0 in position 0: ordinal not in range(128). From what I'm reading this may indicate the code is made for Python2 and has trouble running on python 3.

//Update: that's not it. I got it working. I was using a virtual serial port to test it. When I switched to an Arduino that emulates a P1 meter, it worked.

flatsiedatsie avatar Jul 22 '20 21:07 flatsiedatsie

@flatsiedatsie Do you mean that you got smeterd read-meter working?

nrocco avatar Jul 25 '20 19:07 nrocco

No, I mean I got it working in an addon for the Mozilla WebThings Gateway, which uses your python module.

flatsiedatsie avatar Jul 27 '20 14:07 flatsiedatsie

May I join the club here?

Bildschirmfoto 2022-02-23 um 17 33 13

under-score avatar Feb 23 '22 16:02 under-score