Julius2342 / pyvlx

PyVLX - controling VELUX windows with Python via KLF 200
GNU Lesser General Public License v3.0
76 stars 27 forks source link

Node Type 0x0401 not handled #409

Open raphaelzaugg opened 3 months ago

raphaelzaugg commented 3 months ago

I am using the KLF200 with several VELUX blinds and a Somfy motor. The Somfy motor is reported as a node with type 4 and subtype 1. But according to this enum (https://github.com/Julius2342/pyvlx/blob/master/pyvlx/const.py#L297) and also the KLF200 API documentation there is no subtype 1 for type 4. As a consequence the pyvlx module throws an exception when reading the nodes from the KLF200:

Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/sslproto.py", line 737, in _do_read
    self._do_read__copied()
  File "/usr/lib/python3.11/asyncio/sslproto.py", line 799, in _do_read__copied
    self._app_protocol.data_received(b''.join(data))
  File "/home/raphael/involi/velux/pyvlx/pyvlx/connection.py", line 62, in data_received
    frame = frame_from_raw(raw)
            ^^^^^^^^^^^^^^^^^^^
  File "/home/raphael/involi/velux/pyvlx/pyvlx/api/frame_creation.py", line 55, in frame_from_raw
    frame.from_payload(payload)
  File "/home/raphael/involi/velux/pyvlx/pyvlx/api/frames/frame_get_all_nodes_information.py", line 151, in from_payload
    self.node_type = NodeTypeWithSubtype(payload[69] * 256 + payload[70])
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 714, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 1137, in __new__
    raise ve_exc
ValueError: 1025 is not a valid NodeTypeWithSubtype

The KLF200 is running latest firmware 0.2.0.0.71.0

I don't understand if this is a new subtype that has been added recently but is not yet documented/handled or if the device is somehow reporting a wrong subtype. Any ideas?

Julius2342 commented 3 months ago

Do you know if somfy support is more responsive then Velux support? May you reach out to them?

raphaelzaugg commented 3 months ago

I have no experience with somfy or velux support but will give it a try. do you know if these IDs are directly coming from the somfy device or if its something velux internal?

empi89 commented 1 month ago

I had the same issue using latest homeassistant on HAOS with Markilux IO homecontrol and KLF200. Temporary fix for me was to change the line in const.py from 0x0400 to 0x0401.

For HAOS with safe mode off you can use this workaround. However, after Home Assistant update the fix is gone. After execution velux module needs a reload.

docker exec homeassistant sed -i 's/HORIZONTAL_AWNING = 0x0400/HORIZONTAL_AWNING = 0x0401/' /usr/local/lib/python3.12/site-packages/pyvlx/const.py
empi89 commented 7 hours ago

@Julius2342 does it make sense to introduce a new type (e.g. HORIZONTAL_AWNING_SUB) in const.py and add it to https://github.com/Julius2342/pyvlx/blob/0a3a234d96ac795cabfe9855d854015a17a7e066/pyvlx/node_helper.py#L98? could you suggest a fix so I can create a PR for this?