Closed asprickmann closed 1 year ago
hey @asprickmann :wave:
This looks like a network config value does not have the right type :thinking: Could you double-check that the hostname is a string and the port is a number? Alternatively, if you provide the config file you're using here I could take a look too.
Many thanks for your fast reply. The logarex config file beginning looks like shown below. BTW: I had to remove the parity parameter in serial_port section as it ran into a parsing error.
[logging]
level = 10 # error level (see built-in python logging levels)
[mqtt]
enabled = true
configuration_topic_template = "homeassistant/sensor/{entity_id}/config"
state_topic_template = "homeassistant/sensor/{entity_id}/state"
....
[mqtt.broker]
hostname = "192.168.178.23"
port = 1883
[mqtt.device]
id = "power-meter-0"
name = "Power Meter 0"
manufacturer = "Logarex"
model = "Unknown Model"
[serial_port]
port_url = "/dev/ttyUSB1"
baud_rate = 9600
byte_size = 8
[obis]
[[obis.data_sets]]
id = [1, 0, 96, 1, 0, 255]
name = "Meter Id"
value_type = "string"
I can't see anything wrong with the file. Maybe I'm not converting the port correctly? I ran into type conversion problems with the port argument for the socket module functions before.
Since mqtt.broker.port
is the default port, could you try removing it from the file?
That was it! Many thanks. It is starting without errors if I delete the port in the config file or add quotation marks to the port value.
Unfortunately I do not get any values from the serial connection but assume it is an issue on my end. The debug log looks good, right?: DEBUG:asyncio:Using selector: EpollSelector DEBUG:py_power_meter_monitor.commands:Opened serial connection /dev/ttyUSB1 with 9600 baud. DEBUG:py_power_meter_monitor.workers:IEC 62056 state machine in state InitialState() DEBUG:py_power_meter_monitor.workers:IEC 62056 state machine evaluating effect SendMessageEffect(message=RequestMessage(timestamp=0, device_address='')) DEBUG:py_power_meter_monitor.workers:IEC 62056 state machine evaluating effect AwaitMessageEffect(message_type=<class 'py_power_meter_monitor.iec_62056_protocol.iec_62056_21_messages.IdentificationMessage'>) DEBUG:py_power_meter_monitor.iec_62056_protocol:Draining the read buffer up to b'/' DEBUG:py_power_meter_monitor.iec_62056_protocol:Gave up on draining the read buffer DEBUG:py_power_meter_monitor.iec_62056_protocol:Reading up to b'\r\n'
Glad you got one step farther :+1:
From the log it seems it's waiting in vain for a response from the power meter. Here are some potential problems that come to mind:
stty
and manually watch the byte-stream until I found settings using which it made sense. Thankfully the protocol is mostly ASCII, so one can tell valid from invalid messages by sight (using echo
, cat
and xxd
).Sorry that I can only offer speculations. Since these devices often only implement very specific parts of the IEC 62056-21 standard a lot of trial and error is involved. But I'd be happy to try to provide more input if you want to share your progress.
Many thanks for all your support. So great and highly appreciated! :-) I have the same issue, that I connected via IR before which out of a sudden stopped working. I also believe that the iR LED in the meter is broken. By lucky circumstances I had an electrician here to work on other stuff and saw that he opened up the meter. He was so nice, connecting a wire for me to the rs485 connection points.
In the documentation of the meter, I found this sequence, which shows an ACK50 before sending data. Do we need to send it and is this implemented?
/LOG5LK13BE803049
Great that you have a wired RS-485 connection :+1: much more reliable
You're making progress :tada: The IdentifiedState
log line indicates that you received a response to your initial sign-on, so no device address seems to be necessary. Now the state machine should send the ACK message (implemented in https://github.com/weltenwort/py-power-meter-monitor/blob/f1cfd37cd08e849fa43767ebb74d1174faf1df85/py_power_meter_monitor/iec_62056_protocol/mode_c_state_machine.py#L110-L115), to which the power meter should respond with the STX
frame containing all the OBIS data sets:
Can you show the full debug log?
One more thought: Maybe the device is too sensitive to timing. More specifically, maybe it's too slow to process our ACK
message. You could try adjusting the response_delay
setting in the [serial_port]
section. The default is 0.3
(seconds), which might be too fast. Try setting it to 0.5
or even higher. The spec allows up to 1.5
.
Thanks a lot again. It is working now and I already receive all the data in FHEM MQTT Server!!!
Now I just need to do two further steps:
If you already did something in that direction, it would be great if you could share some insights.
Many thanks again for all your help.
Am Do., 29. Dez. 2022 um 01:05 Uhr schrieb Felix Stürmer < @.***>:
One more thought: Maybe the device is too sensitive to timing. More specifically, maybe it's too slow to process our ACK message. You could try adjusting the response_delay setting in the [serial_port] section. The default is 0.3 (seconds), which might be too fast. Try setting it to 0.5 or even higher. The spec allows up to 1.5.
— Reply to this email directly, view it on GitHub https://github.com/weltenwort/py-power-meter-monitor/issues/211#issuecomment-1366990480, or unsubscribe https://github.com/notifications/unsubscribe-auth/A46WMTNADLO4T636GD62FZLWPTIWJANCNFSM6AAAAAATJ6HQCI . You are receiving this because you were mentioned.Message ID: @.***>
Glad to hear it! What was the solution?
The MQTT messages are designed to work with the Home Assistant MQTT Discovery such that the power meter shows up as a device with sensors for the various measurements. The device_class
es and state_class
es are chosen such that the sensors work with the Home Assistant long-term statistics and the built-in energy dashboard.
I don't have any experience with FHEM or Volkszähler, sorry. You can adjust the topics that the messages are sent to in the config. Each OBIS data set configured in the config file is turned into an entity named after the name
property of the data set. Each state topic contains the name of the entity. The messages sent to the state topics are just { 'timestamp': number, 'value': number | string }
pairs. Without more context knowledge I'm not sure if that is any use to you, though.
I increased the response_delay setting to 0.7. As you assumed, this was the issue. Meanwhile I was also able to read the values in FHEM and send them to Volkszaehler.
Many thanks again for your great help.
Am Do., 29. Dez. 2022 um 13:29 Uhr schrieb Felix Stürmer < @.***>:
Glad to hear it! What was the solution?
The MQTT messages are designed to work with the Home Assistant MQTT Discovery https://www.home-assistant.io/integrations/mqtt#mqtt-discovery such that the power meter shows up as a device with sensors for the various measurements. The device_classes and state_classes are chosen such that the sensors work with the Home Assistant long-term statistics and the built-in energy dashboard.
I don't have any experience with FHEM or Volkszähler, sorry. You can adjust the topics that the messages are sent to in the config. Each OBIS data set configured in the config file is turned into an entity named after the name property of the data set. Each state topic contains the name of the entity. The messages sent to the state topics are just { 'timestamp': number, 'value': number | string } pairs. Without more context knowledge I'm not sure if that is any use to you, though.
— Reply to this email directly, view it on GitHub https://github.com/weltenwort/py-power-meter-monitor/issues/211#issuecomment-1367286932, or unsubscribe https://github.com/notifications/unsubscribe-auth/A46WMTIAIY2MML3SORV33L3WPV74BANCNFSM6AAAAAATJ6HQCI . You are receiving this because you were mentioned.Message ID: @.***>
That's awesome, thanks for sharing.
Hi, I would love to use your code to read data from my logarex power meter but receive the following error. Can you help here?
Thanks in advance.
Andreas