astrandb / sentio

Custom component for Sentiotec sauna controller
4 stars 2 forks source link

Problem with HA 2023.12.3 #24

Open rematde opened 11 months ago

rematde commented 11 months ago

The problem

Error on initial configuration.

Version of Easee integration having the issue?

0.18

Version of Home Assistant Core having the issue?

2023.12.3

Anything in the logs that might be useful for us?

Logger: custom_components.sentio.config_flow
Source: custom_components/sentio/config_flow.py:77
Integration: Sentio sauna (documentation, issues)
First occurred: 14:32:02 (7 occurrences)
Last logged: 14:38:29

Unexpected exception
Traceback (most recent call last):
  File "/config/custom_components/sentio/config_flow.py", line 77, in async_step_user
    info = await validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sentio/config_flow.py", line 51, in validate_input
    if not await hub.connect(data[SERIAL_PORT]):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sentio/config_flow.py", line 38, in connect
    api.get_config()
  File "/usr/local/lib/python3.11/site-packages/pysentio/__init__.py", line 158, in get_config
    self._write_read('get config\n')
  File "/usr/local/lib/python3.11/site-packages/pysentio/__init__.py", line 180, in _write_read
    ret = self._serial.read_until(';\r\n'.encode('utf-8'), 400).decode("utf-8")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

Additional information

As I can't configure, I can't debug?!

astrandb commented 11 months ago

Has it worked before with the same hardware? My existing HA 2023.12.3 is working fine from distance, and I am not keen on making a reinstall since I am 380 km away from my Sentio sauna. It is probably something wrong with the setup of the serial port. It is almost impossible to debug without having access to identical hardware as yours. The code that fails is in the pysentio library. There is a short example of how to test and debug the library here: https://github.com/astrandb/pysentio

rematde commented 11 months ago

Thank you, Ake! Yes, it worked before. How do I test the library? Where to put the code?

astrandb commented 11 months ago

You need to test on the hardware that has the serial port. Are you comfortable with dev containers or creating python venv:s? If the answer is "yes" then go to the Linux prompt and do:

$ pip install pysentio 

Then create a file e.g. test.py with the content from pysentio page and run python3 test.py.

If the answer on the question above is "no", I see no other alternative than waiting until the holiday period when i can try to reproduce the problem in my house.

You could also enter following into your configuration.yam and restart HA. It might generate som useful logs even if the integration is not properly configured. You could also try to set default to debug but that can generate a lot of data.

logger:
  default: warning
  logs:
    custom_components.sentio: debug
    pysentio: debug
astrandb commented 11 months ago

I just played around a little. I am running my HA in HAOS in a virtual machine on a proxmox server. There I can "easily" test the library with the terminal prompt in the Studio Code Server add-on. And it works as expected.

➜  /config ls -alF /dev/serial/by-id
total 0
drwxr-xr-x 2 root root 100 Dec 16 11:58 ./
drwxr-xr-x 4 root root  80 Dec 16 11:58 ../
lrwxrwxrwx 1 root root  13 Dec 16 11:58 usb-0658_0200-if00 -> ../../ttyACM0
lrwxrwxrwx 1 root root  13 Dec 16 11:58 usb-FTDI_FT232R_USB_UART_AH05KYDV-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root  13 Dec 16 11:58 usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0 -> ../../ttyUSB1
➜  /config ➜  /config pip install pysentio
Collecting pysentio
  Downloading pysentio-0.0.52-py3-none-any.whl (4.9 kB)
Requirement already satisfied: pyserial>=3.4 in /usr/local/lib/python3.11/dist-packages (from pysentio) (3.5)
Installing collected packages: pysentio
Successfully installed pysentio-0.0.52
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
➜  /config python3             
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysentio import SentioPro
>>> ss = SentioPro('/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0', 57600)
>>> ri = ss._write_read('get_info\n')
>>> print(ri)
INFO 
SW-Version 2.08.00
Type D2;

>>> 
rematde commented 11 months ago

Thank you so much for your support. The library test is working but I'm getting the same errors. I think I do have a connection problem or something else. Is there a possibillity to get the output of the controller somehow? Thanks alot!

astrandb commented 11 months ago

I did my initial tests with a laptop with a terminal program like putty and connected to the serial port. The Sentio interface is rather picky with delays between entered characters but you should be able to get readable error messages when hitting enter. Com port settings should be:

Baud rate: 57600
Data bits: 8
Stop bits: 1
Parity: No