Velux Component for KLF 200 doesn't support the new API with Firmware 2.0.0.71


hass_io_kitchen_blinds
hass_io_kitchen_windowss

I just realized that the sliders for the non window specific velux devices within hass.io does not correspond with how it’s rendered in the official Velux touch remote.

Ive uploaded an example of my kitchen blinds/windows as seen from the velux remote control point of view as well as the corresponding view as seen in hass.io.

the current physical state of the window is : Fully closed (shut)
the current physical state of the blind is : Fully open, light is entering the room

Now my OCD is severely triggered.

Also regarding the arrow buttons for the covers on the hass.io UI:
Looking it at the velux remote control manual for the KLR100 model we have:

Arrow Key Up:
OPEN/UP

Arrow Key Down:
CLOSE/DOWN

The buttons seems to be correct for both windows and blinds

How it should work:

  1. The blinds (gardin køkken 1) should be position: 0 for the blinds fully open
  2. The blinds (gardin køkken 1) should be position: 100 for the blinds fully closed

the windows scenario seems to get it right, so no changes needed there.

also, shutters, awning blinds are also wrong.
so we just need a small fix to inverse the order of the position for these cover types.

Hmm, I dont see the KLF200 showing me anything relevant about the open / close state.
Even using just the KLF200 I open and close the blind on the skylight and it show the same thing either way (and I note this is a single blind not a group which could be more complicated).

Skylights are similar for me.

Earlier in this thread there is comment about being unable to restart HA with the new Velux code.
I am still using the custom component from gibman.
I had this again just now; only it not only failed to restart HA, it wouldnt start even after power cycling the Raspberry Pi. I never had that before. I’ve always been able to power cycle to get HA back up.
=> I had to power cycle the KLF200 to get it HA going again.

I can confirm @gibman custom component helps but does not solve completely the issue.

Here is another image of one blind being operated from open / 0 to half closed / 49.

You are right… the klf200 does not maintain the status of the bottom slider as well as the digit /49. As long as the blind is being operated the status and digit are shown. Once its in place its hidden.

But it does seem like from the point of view of the velux remote that 100 indicates a fully closed blind and 0 being open.

Its reversed on the cover component within hass.io.

I did a few changes locally in covers.py for the velux component and was able to reverse the slider making it corresponding with the velux remote. But sadly this reversed the buttoms also.
So the arrow down button would close the blind / blinds going down. And vice versa for the up button.

So an even worse situation now.

hi… same here…

Anyone with KLF200 connection problems upon rebooting hass.io could you please try this fix in:

remember this import in the top of the file:
from homeassistant.const import (CONF_HOST, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP)

replace the def init with:
`
def init(self, hass, config):
“”“Initialize for velux component.”""

async def on_hass_stop(event):
	"""Close connection when hass stops."""
	_LOGGER.info("velux interface terminated")
	await self.pyvlx.disconnect()                    

hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, on_hass_stop)
#from custom_components.pyvlx import PyVLX                
from pyvlx import PyVLX
host = config[DOMAIN].get(CONF_HOST)
password = config[DOMAIN].get(CONF_PASSWORD)
self.pyvlx = PyVLX(
	host=host,
	password=password)

`

I’ve done 8 consecutive reboots and no problems so far :slight_smile:
Latest file for reference is here:
https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/velux/init.py

I’ll create a branch a pull request for this if others are seeing good results :slight_smile:

edit: here’s a link for the lazy ones that contains all the code.
It contains the latest version of pyvlx and is currently running on hass.io 0.93.0
https://drive.google.com/file/d/15rEu_0wQOlpgQQ8YvpQPz2VEImP5EB2x/view?usp=sharing

The archive also contains a few other fixes that I’m running locally (described in the this thread).

just put it into the customs_components folder as described in this thread previously.

Hi guys,

I´m willing to buy a KLF 200 to control one window and two blinds but I’m currently confused. Is the KLF now working or not?

Thanks a lot,

Flo

mostly…it is but not very robust on reboots

Hmm…what do you mean with not very robust on reboots?

read above: it has been covered

there is a custom component which mitigates the issue

Just getting back to this thread and I have picked up velux_patch2. Thanks @gibman.

For your reference, when I ran the first patch I was running 0.88.1 on Hasbian (this install died with a flash card failure).

I had been running a clean 0.93.2 without too many reboot problems, but then I got one today and came back to this thread. I installed the updated patch and rebooted and I immediately got the failure below.

I don’t think its worth tracking down (for now at least). It cleared up after rebooting the KLF, so something in the original failure may have been the root cause.

BTW - What do you use to extract the rar? I’ve been using windows and some snarky extractor and moving the files over SAMBA. Is there a unix utility I can use on hassio to extract rar?

2019-06-16 14:42:54 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for velux which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-06-16 14:43:02 ERROR (MainThread) [homeassistant.components.device_tracker] Unable to load /config/known_devices.yaml: Config file not found: /config/known_devices.yaml
2019-06-16 14:44:01 ERROR (MainThread) [homeassistant.setup] Error during setup of component velux
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/setup.py”, line 153, in _async_setup_component
hass, processed_config)
File “/config/custom_components/velux/init.py”, line 35, in async_setup
await hass.data[DATA_VELUX].async_start()
File “/config/custom_components/velux/init.py”, line 70, in async_start
await self.pyvlx.load_scenes()
File “/usr/local/lib/python3.7/site-packages/pyvlx/pyvlx.py”, line 87, in load_scenes
await self.scenes.load()
File “/usr/local/lib/python3.7/site-packages/pyvlx/scenes.py”, line 51, in load
await get_scene_list.do_api_call()
File “/usr/local/lib/python3.7/site-packages/pyvlx/api_event.py”, line 22, in do_api_call
await self.send_frame()
File “/usr/local/lib/python3.7/site-packages/pyvlx/api_event.py”, line 34, in send_frame
await self.pyvlx.send_frame(self.request_frame())
File “/usr/local/lib/python3.7/site-packages/pyvlx/pyvlx.py”, line 70, in send_frame
await self.connect()
File “/usr/local/lib/python3.7/site-packages/pyvlx/pyvlx.py”, line 45, in connect
await self.connection.connect()
File “/usr/local/lib/python3.7/site-packages/pyvlx/connection.py”, line 89, in connect
ssl=self.create_ssl_context())
File “uvloop/loop.pyx”, line 1945, in create_connection
File “uvloop/loop.pyx”, line 1942, in uvloop.loop.Loop.create_connection
ConnectionAbortedError: SSL handshake is taking longer than 60.0 seconds: aborting the connection
2019-06-16 14:44:32 ERROR (MainThread) [frontend.js.latest.201905140] http://192.168.2.240:8123/frontend_latest/chunk.8abe6b9573af3d1ad82d.js:2875:1345 Uncaught TypeError: Cannot read property ‘isOff’ of undefined
2019-06-16 14:44:32 ERROR (MainThread) [frontend.js.latest.201905140] http://192.168.2.240:8123/frontend_latest/chunk.8abe6b9573af3d1ad82d.js:2875:1345 Uncaught TypeError: Cannot read property ‘isOff’ of undefined
2019-06-16 14:47:26 ERROR (MainThread) [homeassistant.components.hassio.handler] Timeout on /homeassistant/restart request

I’ve been rebooting a lot this evening and with patch 2 I have had no trouble with velux hanging.
I’ll continue to monitor

1 Like

I received this error trace on a reboot today, and I needed to restart the Velux hub.

2019-07-06 19:42:58 ERROR (MainThread) [homeassistant.setup] Error during setup of component velux
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/setup.py", line 153, in _async_setup_component
    hass, processed_config)
  File "/config/custom_components/velux/__init__.py", line 35, in async_setup
    await hass.data[DATA_VELUX].async_start()
  File "/config/custom_components/velux/__init__.py", line 70, in async_start
    await self.pyvlx.load_scenes()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/pyvlx.py", line 87, in load_scenes
    await self.scenes.load()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/scenes.py", line 51, in load
    await get_scene_list.do_api_call()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/api_event.py", line 22, in do_api_call
    await self.send_frame()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/api_event.py", line 34, in send_frame
    await self.pyvlx.send_frame(self.request_frame())
  File "/usr/local/lib/python3.7/site-packages/pyvlx/pyvlx.py", line 70, in send_frame
    await self.connect()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/pyvlx.py", line 45, in connect
    await self.connection.connect()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/connection.py", line 89, in connect
    ssl=self.create_ssl_context())
  File "uvloop/loop.pyx", line 1945, in create_connection
  File "uvloop/loop.pyx", line 1942, in uvloop.loop.Loop.create_connection
ConnectionAbortedError: SSL handshake is taking longer than 60.0 seconds: aborting the connection

anyway the latest patch definetly improves the behavior.

@gibman will this be implemented into the official component?

I hope so…
I just have to create a pull request then I guess it will be part of the official component.

I’ve done countless hass.io reboots since the last patch and I haven’t seen one single hickup :slight_smile:

1 Like

@gibman
Have you had a chance to look at my logs which failed?
Is there anything I can test at my end which might help?

@jasebob : yeah… They don’t really tell much, other than not being able to establish a connection within the allowed timeout period.

hass.io seems to dispose the old log file upon boot. It’s the “old” log file that is more interesting, as it says something about velux klf disconnect being called or not.

btw. if you hard reset your hass.io then I guess the problem could still occur.
This patch only works when hass.io is being soft booted.
But I guess you already know this :slight_smile:

regards
gibman

If by hard reset you mean pulling the power, and soft reset you mean clicking / calling restart server, then yes that’s understood. :slight_smile:
But we also want hard reset to work eventually, especially in case of power outage. Is there a possible race condition between the boot of the Velux hub and HA on the rasberry Pi. If the Velux is not ready will HA hang or fail and then be unable to access all of the Velux devices?

Anyone know you you can disable the rain sensors build into the Velux units?

Ideally I’d be able to send a command which force disabled them for a period using node-red but didn’t disable fully (or a node-red command can reinstate)

Use Case: Ability to force open for cooking to 30% open

If needed if someone knows how you can just disable them but just thinking if the velux component goes down at some point then not great if it rains.

Found this which might be helpful but not sure how do go about it after that - http://klf200.renejosefsen.dk/KLF200_API.pdf

Hi all,
After a fair bit of research, I finally bought and installed a Velux blind for my fixed skylight here in the U.S. along with a KLF200 and wanted to share for those looking to do the same. (Probably information overload for others)

Velux Components:

  • Solar Blinds for mounting to a Fixed Skylight (Model FS)
  • KLI 312 1-way remote-control keypad. Came with the blinds.
    Specifically: 3LI S12US
    Model: BG-RC012-01
    (Although similar to a KLI 100 is not a KLI 100)
  • KLF 200 (already loaded with version 0.2.0.0.71.0). Purchased separately.
    Specifically: 3LF S02 US
    Model-BE-RC010-01

Theses particular blinds are controlled by the io-homecontrol at 2.4GHz.
Specifically (looking through FCC docs), it uses the same radio channel(s) as Zigbee for channels 15, 20, and 25 (but no indication it runs Zigbee’s higher layer protocols). The power levels are around 10mW. Compared to WiFi of around 100mW, the io-home control power is quite a bit less, but then the bandwidths (around 250kbps) are much smaller and thus the higher power is not required.

KLF 200 comes with

  • Couple of Manuals “A”(Installation/Setup of Legacy) and “B” (WiFi setup). For the most part Manual A can be ignored as it is written mostly for Legacy systems prior to 0.2.0.0.0.
  • USB Power adapter and cables for powering the unit. Mine came with U.S. specific plug adapter.
  • Lots of I/O cables for legacy systems. These will not be needed here.
  • Ethernet LAN port. This is what HA uses to communicate with the KLF. Given possible distance limitations of the io-homecontrol, and the need for a physical LAN cable connection, one must consider an appropriate location for the KLF.
  • io-homecontrol at 2.4GHz. (this model does not support 868MHz).
  • WiFi AP and web server. The AP/Web server is used to setup the KLF-200 and for adding blinds with a mobile device (phone, tablet, i.e. a WiFi client). The AP password is written on the back of the unit, and is the one HA needs for logging into the KLF 200. The Webserver has a fixed http url klf200.velux and default password “velux123”. After bootup, the GUI is only available for 10 minutes.
    – Login to the Webserver,
    – Initially it asks if you want to configure the unit as a “Repeater” or as an “Interface”, but here it needs to be configured as an “Interface”.
    – Control a Device. KLF gives you a couple of options for how to connect to the blinds, one of which is to search based on KLI that is already used to control the blinds. As I already had a KLI, I picked the “310/311/312” from the GUI. Here it wants to communicate with the KLI (to copy over its key codes) and the GUI provides the instructions for how to do this (the manual is no good as its for use with KLI 100). With the KLI 312 sitting next to the KLF200 I let the KLF200 discover the KLI 312 and copy over the data. Once done, the KLF200 creates an entry in the GUI for the blind named “blind 0”. Change the name, otherwise I found out HA will name it “cover.unamed_device”. At this point you can hit the “Identify” button on the GUI for this blind and you should see that blind move which tells you the KLF200 can now control the blinds. The GUI itself does not provide any real controls for the blinds (no up button, no down button, etc.)
    – There are other configurable options for the KLF200, like static IP configuration, but make sure the LAN port is on always (which it is by default).

Home Assistant

  • Configure HA to run the velux component and use the password on the back of the KLF200.
  • My HA didn’t come up first time. The log shows " Connecting to KLF 200"…it never showed the “Connected to KLF 200” state. Apparently the velux component is not letting go of a thread and causes HA to sit there waiting forever (you won’t be able to get the HA GUI connected to HA). I rebooted both KLF200 and HA and the connection came up :smile:
    Oh and BTW, the LED on the KLF200 flashes white until this connection is made.
  • HA discovered the blind from KLF200 and created a cover with a position slider and up/down arrows. The position slider and up/down arrows are updated once the blind reaches the desired position. If the KLI 312 is used, the HA arrows and slider position are still updated but be patience, its not instant.
  • Connectivity: The KLF allows for two sockets at a time and times out if idle, but pyvlx appears to send a keep alive message to keep the connection up all the time. I have once run into an Errno 111 (connection refused), but not sure if it is related to the HA reboot bug reported in this thread (I haven’t yet installed the patch that tears down the connection on HA reboot). I’m currently still running 0.94.

Hope this is helpful to others.

2 Likes