Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disconnected due to exception #2

Closed
Melantrix opened this issue Oct 20, 2020 · 9 comments
Closed

Disconnected due to exception #2

Melantrix opened this issue Oct 20, 2020 · 9 comments
Labels
question Further information is requested

Comments

@Melantrix
Copy link

Melantrix commented Oct 20, 2020

Disclaimer: i may have a setup that's not the intended setup, so this is mainly to confirm if this is supposed to work or not.

My current setup is a Home Assistant appliance running in a VM on a proxmox host. I have a p1 usb running from my DSMR to the proxmox host and the usb passed through to the VM.

I read the data in Home Assistant through the DSMR integration. I then found out about DSMR-Reader and have that setup in a docker on a different host. I then wanted the data from the USB in DSMR-Reader so i installed this add-on to send it to DSMR-Reader. However since that moment i have frequent disconnects from both the DSMR integration and the DSMR-Reader add-on. The add-on gives the log below when that happens.

I understand the problem: two different algorithms are trying to access the same device and that doesnt work nicely. However, I thought that this add-on is specifically made for this kind of setup -> the USB is in the HA host but you want the data in both HA and the DSMR reader. Is this premise correct? And if that is the case, what am i doing wrong? Do you maybe have an idea how to get this setup working?

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/serial/serialposix.py", line 500, in read
    raise SerialException(
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 "./dsmr_datalogger_api_client.py", line 179, in <module>
    main()
  File "./dsmr_datalogger_api_client.py", line 150, in main
    telegram = next(datasource)
  File "./dsmr_datalogger_api_client.py", line 49, in read_telegram
    incoming_bytes = serial_handle.read(MAX_BYTES_PER_READ)
  File "/usr/local/lib/python3.8/site-packages/serial/serialposix.py", line 509, 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?)
@sanderdw
Copy link
Owner

Hi Melantrix, if i understand you correctly, you have put your P1 USB cable in a machine that's running Proxmox? And there you have a fully Home Assistant OS running as a VM? So you can install add-ons etc?

Not sure if this works (i only test my addon with the official raspberry installation), but if you want this setup to work you cannot share the usb device with anything other than the Home Assistant OS.

An alternative would be just to run https://dsmr-reader.readthedocs.io/en/v4/installation.html as a VM where you mount this USB port in?

I believe Proxmox is not really capable of running Docker right? Because then these options are also great: https://dsmr-reader.readthedocs.io/en/v4/installation/docker.html

The intended setup for this addon is basically when you don't have a server right next to your smart meter. In that case it's really simple to use my addon in combination with a raspberry pi and the full Home Assistant OS setup which then forwards the data to a specified API (to a separate server running the full DSMR Reader either as a VM, Docker or native).

@sanderdw sanderdw added the question Further information is requested label Oct 20, 2020
@Melantrix
Copy link
Author

Hi Melantrix, if i understand you correctly, you have put your P1 USB cable in a machine that's running Proxmox? And there you have a fully Home Assistant OS running as a VM? So you can install add-ons etc?

That is correct.

Not sure if this works (i only test my addon with the official raspberry installation), but if you want this setup to work you cannot share the usb device with anything other than the Home Assistant OS.

An alternative would be just to run https://dsmr-reader.readthedocs.io/en/v4/installation.html as a VM where you mount this USB port in?

I believe Proxmox is not really capable of running Docker right? Because then these options are also great: https://dsmr-reader.readthedocs.io/en/v4/installation/docker.html

The usb device is only used in the ha vm but by one integration and your add-on within the same vm. So two programs on one pc wants to read the usb data.

The intended setup for this addon is basically when you don't have a server right next to your smart meter. In that case it's really simple to use my addon in combination with a raspberry pi and the full Home Assistant OS setup which then forwards the data to a specified API (to a separate server running the full DSMR Reader either as a VM, Docker or native).

The intended use is my situation. Maybe I need to ask the following question, how do I get the data visible within ha? Does your add on also provide sensors? (I'm not sure but I thought it didn't)

@Melantrix
Copy link
Author

Do you have any more information about this? Especially the last question on how to get the data in HA while using this plugin.

@sanderdw
Copy link
Owner

sanderdw commented Oct 26, 2020

Do you mean this integration: https://www.home-assistant.io/integrations/dsmr/ (which is completely different from https://dsmr-reader.readthedocs.io/en/v4/)?
You can't use/share the usb device with 2 programs. So you need to choose which solution you want to work and remove the other.

So basically you can choose between 2 HA solutions:

  1. DSMR Slimme Meter (https://www.home-assistant.io/integrations/dsmr/)
    Only the integration needed, nothing else but limited in functionality

or

  1. https://dsmr-reader.readthedocs.io/en/v4/
    Full blown separate application with data.

My addon is focussed on option 2. When you want to integrate the sensors back in to Home Assistant (So HA Addon -> DSMR Reader -> HA) you need to use this specific integration: https://www.home-assistant.io/integrations/dsmr_reader/

Maybe this makes it more clear?

@Melantrix
Copy link
Author

Melantrix commented Nov 5, 2020

Hi,

first, excuse me for the late response, had some other things to take care of.

Yes that's the integration i'm using. I understand what i have to do.

I think I just thought: why create such a 'loop' from DSMR (smart meter)-> HA (your addon) -> DMSR_Reader -> HA (dsmr_reader integration). That's kind of complex..

So maybe this thread can be changed in a feature request? I don't know if Add Ons can supply devices and/or entities, but maybe you could create that? That way it would be:

DSMR -> HA (your addon) -> DMSR_Reader
                   |-> basic info like  https://www.home-assistant.io/integrations/dsmr/ supplies. 

@sanderdw
Copy link
Owner

It seems complex but there is a reason to do it this way. DMSR Reader has a lot of nice logic build in, like getting hour, day and month totals, pricing logic etc. Therefore it's better to get the data 'back' from there instead of doing this logic 'yourself' and defeating the purpose of using https://dsmr-reader.readthedocs.io/en/v4/intro.html#features anyway.

It would be better to extend the functionality of https://www.home-assistant.io/integrations/dsmr_reader/ when there are additional requirements. Or you can also use https://www.home-assistant.io/integrations/sql/ to query the data dsmr-reader.readthedocs.io stores in the configured database.

@sanderdw sanderdw closed this as completed Jan 4, 2021
@sanderdw
Copy link
Owner

@Melantrix i released an alpha version of the full DSMR Reader addon: https://github.com/sanderdw/hassio-addons/tree/master/dsmr_reader

@Melantrix
Copy link
Author

That's awesome! i'll take a look if i can migrate to it!

I do understand correctly that it's DMSR Reader hosted within HA? so it's the usb -> dsmreader addon -> HA ?

@sanderdw
Copy link
Owner

Yes, correct. See step 11 in https://github.com/sanderdw/hassio-addons/blob/master/dsmr_reader/README.md for the last '-> HA' part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants