golles / ha-kamstrup_403

Custom component that integrates the Kamstrup 403 heating system into Home Assistant. This component does also support a few other heating systems
MIT License
71 stars 12 forks source link

Many I/O error messages #4

Closed Chrisiesmit93 closed 2 years ago

Chrisiesmit93 commented 2 years ago

Version of the custom_component

Version: 1.0.0

Configuration

I downloaded this integration through HACS and choose the following device: /dev/serial/by-id/usb-FTDI_FT230X_Basic_UART_D308BOXH-if00-port0

Describe the bug

I got a lot error massages (957 in ~24h) with the error: "Unexpected error fetching kamstrup_403 data: name 'serial' is not defined".

If I re-add the integration, it seems to work for some hours/days, but then I get above error messages again and no new updates from my Kamstrup 403.

Debug log

Logger: custom_components.kamstrup_403
Source: custom_components/kamstrup_403/__init__.py:84
Integration: Kamstrup 403 (documentation, issues)
First occurred: 14 oktober 2021 16:31:44 (953 occurrences)
Last logged: 08:23:44

Unexpected error fetching kamstrup_403 data: name 'serial' is not defined
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/serial/serialposix.py", line 621, in write
    n = os.write(self.fd, d)
OSError: [Errno 5] I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/kamstrup_403/__init__.py", line 82, in _async_update_data
    value, unit = self.kamstrup.readvar(SENSORS[key]["command"])
  File "/config/custom_components/kamstrup_403/kamstrup.py", line 194, in readvar
    self.send(0x80, (0x3F, 0x10, 0x01, nbr >> 8, nbr & 0xFF))
  File "/config/custom_components/kamstrup_403/kamstrup.py", line 164, in send
    self.wr(c)
  File "/config/custom_components/kamstrup_403/kamstrup.py", line 137, in wr
    self.ser.write(b)
  File "/usr/local/lib/python3.9/site-packages/serial/serialposix.py", line 655, in write
    raise SerialException('write failed: {}'.format(e))
serial.serialutil.SerialException: write failed: [Errno 5] I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/kamstrup_403/__init__.py", line 84, in _async_update_data
    except (serial.SerialException):
NameError: name 'serial' is not defined
golles commented 2 years ago

Strange that it seems to work fine at first and after a while, these exceptions occur.

My first guess is that the IR head is not positioned correctly, but I guess that nothing can accidentally move it.

I found this topic, can you have a read there and see if one of the suggestions helps you? It looks like a similar issue where the serial device seems to be gone after an event. https://discourse.tinyfpga.com/t/tinyprog-makes-serial-port-disappear-when-attempting-to-program-tinyfpga-bx-solved/1622

Chrisiesmit93 commented 2 years ago

For now it seems to work fine (but I also just rebooted HA, so maybe now it's working again...) But when the problem occurs again, I will try to move the optical head to see it that's the solution for me.

golles commented 2 years ago

If the head has a fixed position to the meter, I don't think that could cause the problem. For now, I don't have any idea why serial became unavailable while HA is running.

Would be interesting to test if you could read the meter out manually

Chrisiesmit93 commented 2 years ago

It seems like the problem is at my side, in HA logging I see USB reconnects on host level (also other USB devices, including the IR USB reader). You can close this issue ;)

golles commented 2 years ago

Ok, hope you manage to resolve your host device issues!