home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.16k stars 29.83k forks source link

Add support for D0 protocol to EDL21 #94460

Open julred opened 1 year ago

julred commented 1 year ago

The problem

Dear all,

I installed EDL21 in order to visualize my smartmeter interface. My energymeter is from Logarex (see here the description: https://www.kommenergie.de/_Resources/Persistent/d/9/4/8/d9485ccfb652107fdab8a0f8b6bbe6fea8393547/Bedienungsanleitung%20Logarex%20Z%C3%A4hler.pdf )

I'm able to see all the values using CLI command cat /dev/ttyUSB1

edl21

I added also /dev/ttyUSB1 to the EDL21 configuation - but on the devices overview, I only got this message: 12-06-_2023_11-32-58

There are no logs available.

How can I receive all values inside Home Assistant (2023.6.1) - LXC Proxmox installation

What version of Home Assistant Core has the issue?

2023.6.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

EDL21

Link to integration documentation on our website

https://www.home-assistant.io/integrations/edl21

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

edl21 documentation edl21 source

Sogge88 commented 1 year ago

same issue here is there a solution?

image

image

StephanU commented 1 year ago

Could you activate the debug logging ("Debug Protokollierung einschalten") and send your log file?

Sogge88 commented 1 year ago

home-assistant_edl21_2023-06-13T05-19-08.967Z.log

i make a restart of HA and log this. Otherwise nothing was written in log.

julred commented 1 year ago

error_log.log

I just reviewed this file. Lot of messages from viessmann integration, but also some lines regarding handling with /dev/ttyUSB1

hawkeye79 commented 1 year ago

Hello, I have the same problem. No devices/entities are displayed or created.

Although, it worked once. 1 device and 3 entities were displayed. After a reboot of the Pi 3b+ the entities were gone again.

with chmod I see that the USB0 is read only. Is this a problem?

error_log_edit.txt

StephanU commented 1 year ago

@Sogge88 Do you also have a Logarex energymeter like @julred? In both your logs it looks like a connection to the usb port is established, but no messages are received at all. I'm afraid this is beyond my capabilities. Maybe @mtdcr can help? :)

mtdcr commented 1 year ago

Your devices speak D0 protocol, but the edl21 integration only supports the binary SML protocol at this time.

Someone would need to implement a parser and a configuration knob to select the protocol. D0 may require additional options like baud rate or whether to send an activation sequence or not. Since it's a text protocol (line-based), it may be even suitable for Python beginners looking for a challenge.

Sogge88 commented 1 year ago

Hi @StephanU Yes i have a Logarex: LK13BE803039

OK bur somehow the smartmeter send something because with stty -F /dev/ttyUSB0 9600 -parodd cs7 -cstopb parenb -ixoff -crtscts -hupcl -ixon -opost -onlcr -isig -icanon -iexten -echo -echoe -echoctl -echoke

And cat /dev/ttyUSB0. Data is read

Sogge88 commented 1 year ago

I found this in the description of the smartmeter Optische Kommunikation EN 62056-21, Push, 9600 Bd

https://www.sw-l.de/assets/files/downloads/logarex-lk11-lk13.pdf

hawkeye79 commented 1 year ago

Hi, my problem is solved. My sensor did not have to sit centrally on the electricity meter, but rather eccentrically. After I had that, the integration ran.

But I still have one question: Is it possible to change the sampling time?

Jay-0810 commented 1 year ago

Hello,

I have a similar problem ('No values available in EDL21 #94460', referring also to 'EDL21 seems to be running (debug shows data) but not creating sensors or entities #91494'), no devices/entities have been created.

Configuration:

Transceiver: USB IR Lesekopf EHZ Lese-Schreib-Kopf Volkszähler Hichi Smartmeter, /dev/ttyUSB0

Debug-log: no entries related to the problem (so far I can see).

The weird issue is, that it worked already for a while, but all entries disappeared after reboot....

I would be happy to contribute to root cause analysis, but since I am a newbee, I need some advice.

Thanks Jay

julred commented 1 year ago

Hi, my problem is solved. My sensor did not have to sit centrally on the electricity meter, but rather eccentrically. After I had that, the integration ran.

But I still have one question: Is it possible to change the sampling time?

Which kind of smartmeter are you using? Did you see serial outputs from your IR transmitter using e.g. cat /dev/ttyUSB0 ?

Your devices speak D0 protocol, but the edl21 integration only supports the binary SML protocol at this time.

Someone would need to implement a parser and a configuration knob to select the protocol. D0 may require additional options like baud rate or whether to send an activation sequence or not. Since it's a text protocol (line-based), it may be even suitable for Python beginners looking for a challenge.

Do you have any recommondations, how to start with this issue? Or an idea what needs to be extended in the existing parser?

Jay-0810 commented 1 year ago

Smartmeter: GH305 cat /dev/ttyUSB0 --> '@@@f' and so on...

As I wrote: The weird issue is, that it worked already for a while, but all entries disappeared after reboot....

Regards Jay

mtdcr commented 1 year ago

If this integration has ever worked for you before, you have a different issue than OP.

You're also observing a different problem if your meter does not output ASCII characters as shown in screenshots above.

hawkeye79 commented 1 year ago

@julred I have a Apator Lepus (SML protocol) and use the same setup how @Jay-0810 (USB IR Lesekopf EHZ Lese-Schreib-Kopf Volkszähler Hichi Smartmeter, /dev/ttyUSB0.) cat /dev/ttyUSB0 --> '@B' etc.

as I said, in my case, it was due to the positioning of the read head.

Jay-0810 commented 1 year ago

@hawkeye79 Thanks for pointing out. I saw the comment and changed the position several times; unfortunately without success. In meantime I tried another transceiver of same type, same issue: no sensors or entities have been created. I deleted integration, rebooted and created it again, no success...

mtdcr commented 1 year ago

Your devices speak D0 protocol, but the edl21 integration only supports the binary SML protocol at this time. Someone would need to implement a parser and a configuration knob to select the protocol. D0 may require additional options like baud rate or whether to send an activation sequence or not. Since it's a text protocol (line-based), it may be even suitable for Python beginners looking for a challenge.

Do you have any recommondations, how to start with this issue? Or an idea what needs to be extended in the existing parser?

Home Assistant prefers using asyncio over synchronous I/O, so for reading from a serial port you should use the serial_asyncio library. It it feels too complicated, maybe start with synchronous I/O (serial library) and move to serial_asyncio at a later point in time. You can use https://github.com/mtdcr/pysml/blob/master/sml/asyncio.py as an example. Try to run your code outside Home Assistant before trying to integrate it.

  1. Familiarize yourself with the protocol, for example by writing a script that parses a single hard-coded message.
  2. Read messages from the serial port line by line:
    • Ignore lines until you find a start of a frame ("/XYZ..." followed by an empty line)
    • Parse values contained in the frame into a structure, e.g. a dict compatible to what's called 'telegram' in edl21 with keys 'objName', 'value' and 'unit'
    • Put the stuctures into a list
    • Continue until end ("!") or until you find an unexpected line, indicating an error condition (another start, empty line or a line you can't parse)
  3. Find the electricity ID
  4. Create a structure for the message, e.g. a dict compatible to what's called 'message_body' in edl21 (store electricity ID in 'serverId', list from step 2 into 'valList')
  5. Implement a D0_Protocol class similar to SmlProtocol, implement an add_listener function, just without the unnecessary types argument).

In edl21/sensor.py, replace

self._proto = SmlProtocol(config[CONF_SERIAL_PORT]) self._proto.add_listener(self.event, ["SmlGetListResponse"])

with

self._proto = D0_Protocol(config[CONF_SERIAL_PORT]) self._proto.add_listener(self.event)

and remove assert isinstance(message_body, SmlGetListResponse) from event().

  1. Create a configuration option in edl21 to choose between the two protocols.

  2. Decide whether to publish the code in a library of its own or to include it in pysml.

I hope this helps to get you started.

StephanU commented 1 year ago

@julred Would you please change the title of this issue to e.g. "Add support for D0 protocol to EDL21"

Sogge88 commented 1 year ago

Hi is now someone doing this Integration of D0 Protokoll top edl21?

Jay-0810 commented 1 year ago

Hi, as mentioned, I'm a newbie. I'm not able to implement the proposed improvements, but I'd like to contribute by doing tests, for example....

Dvaina commented 1 year ago

Hi, got the same problem as OP. Would really appreciate if someone smarter then me would write that D0 Parser :)

In the meantime someone shown a workaround in this thread from 2 years ago, might be worth a look. https://community.home-assistant.io/t/reading-data-from-a-smart-meter-speaking-d0/304258

Megachip commented 1 year ago

https://community.home-assistant.io/t/edl21-adding-support-for-logarex/343883

issue-triage-workflows[bot] commented 10 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

julred commented 10 months ago

Not cleared yet. Needs to be Open for further discussion

3dh-de commented 9 months ago

Would love to see the D0 integration, too. So please reopen this issue.

Any hints are greatly appreciated - IÄm not a Python expert, but would invest a few hours to integrate this...

Maschine20 commented 9 months ago

I need a D0 integration also. Using the Logarex counter and a Weidman IR Module availble on serial port (/dev/serial/by-id/usb-FTDI_FT230X_Basic_UART_DK0DW1X1-if00-port0).

issue-triage-workflows[bot] commented 6 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

mtdcr commented 6 months ago

Would love to see the D0 integration, too. So please reopen this issue.

Any hints are greatly appreciated - IÄm not a Python expert, but would invest a few hours to integrate this...

Does this information help? https://github.com/home-assistant/core/issues/94460#issuecomment-1599404122

issue-triage-workflows[bot] commented 3 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

julred commented 3 months ago

bumb - not fixed yet

issue-triage-workflows[bot] commented 3 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

mtdcr commented 3 weeks ago

.