Improved Velux integration

I moved from Tahoma box to Velux KLF200 in order to get rid of somfy servers. I could transfer all my devices (9 shutters and 4 exterior venetian blinds) quickly and control them (open and close). The KLF200 provides a local API ant the API specification allows to control nearly everthing the io-homecontrol protocol supports. However the current implementation via pyvlx packages provides not all functions.
One lovely feature I’m missing is the control of the tilt of the blinds. So I would much appreciate if someone could support to modify the velux integration in that way that it would be able to control also functional parameters of io-homecontrol devices and not only the main parameter (which is the position in most devices). Also it would be great if the complete velux integration would be part of home-assistant and not just a bridge to pyvlx package.

That contradicts the design-principles of Home Assistant. The goal is to have device/vendor-specific code outside of Home Assistant. It’s not the job of Home Assistant to know how to control the device. The library has to implement this, and provide some sort of API which Home Assistant then uses to integrate the device.

OK, understand. I already managed to adjust pyvlx on a custom component and created a pull request for pyvlx library. After merging I can create a push request for Home Assistant integration.

1 Like

Hi,

If possible I would also have a wish:

I have 3 windows with 3 Shutter and 1 internal venetian blind.

I have troubles with 1 of the shutters. If I close it then every 9 of 10 tries it stops at possition 1 and not going to 0. So in Home Assistant it is shown as open instead closed.

Would it be possible to integrate a function so that position 1 is also showed as “closed”?

Br,
Johannes

Hi @pawlizio,

very excited to read about your contribution to pyvlx for controlling slat orientation via KLF200. Have these improvements already made it into the current HA 0.112.4 release (pyvlx 0.2.16)? If so how is it enabled, I currently only have up/down controls available in HA. Otherwise, is there a way to test it pre-release?

I have been happily using HA for a while now but the one major pain-point has always been tilt-support for my external Venetian blinds with Somfy J4 motors (or rather the lack thereof). I’ve been getting by with some Scripts/Automations but it’s not the ideal solution.

Best Regards!

Sorry for the late reply, didn’t recognize this post. Currently the tilt functionality is only enabled on my HACS custom component: https://github.com/pawlizio/my_velux

At least it works with my exterior Venetian blinds. However it may cause problems with tilt open close function. My blinds are open at 50% and close at either 0 or 100%

Ok great, thanks for the tip @pawlizio, that’s working for me now!

My blinds are the external kind (Raffstore/Shutters) which only tilt outward, where 0% is fully closed/vertical & 100% fully open/horizontal, so I ended up having to modify line 272 in opening_device.py to make it behave correctly:

orientation=Position(position_percent=50)
orientation=Position(position_percent=0)

I was a bit confused at first since the function names seem to work exactly reversed in my case,. i.e. close_orientation() runs when the service cover.open_cover_tilt is called. I also modified the device class to shutter in customize.yaml, maybe that accounts for the reversed logic.

That said I’m clueless when it comes to Python so I could just be interpreting things wrong, nonetheless it’s working better now than ever before, it even finally works with scenes! :partying_face:

Many thanks for the assistance and of course @Julius2342 for the Integration! :beers:

Would be also nice if we could have the ventilation position, when the room is only opened for ventilation

@pergola.fabio: Not sure what you mean, the opening position of a window? Isn’t this the standard position?

If not you can check whether this information is provided by any functional parameter which is maybe not implemented yet by activating the logger on your configuration.yaml:

logger:
  default: warning
  logs:
    pyvlx: debug

Within above API specification on chapter “14 Appendix 2: List of actuator types and their use of Main Parameter and Functional Parameters” you will find all supported io-homecontrol devices and their supported parameters. Please check if you can identify your requested information and then it’s just a question about implementation.

hey, i am not sure, as discussed on githib, i only have my velux for like a week
but you know i have a rain sensor, so when it raines, they are closing, but not 100% closed
its also in api, they go to a ventilation mode
maybe its like a current position : 10 , or something like that, i need to wait until it rains again :slight_smile:
now, 2 nights ago, they closed because of rain, but HA still reported them as “open”, while they were actually almost closed

will have a look next time, already got debug open, also for that rain sensor

I noticed that as well. It is because the reported position is not 0 or 100 but, depending on the case 1 or 99. So, 99 is closed for our eyes, but, for a computer 99 is not 100. So it is “open”.
I don’t know if and how can be fixed…
GV

isnt it reporting the integer value in the states? didnt notice yet, maybe its in debug

For exact position you can check the attributes of your cover for current_position value.

Home Assistant report them only close when they are fully closed at 0%. While Home Assistant declares 0% as fully closed, io-homecontrol uses 100% as fully closed, so you have to be careful.

Inside code of course its possible to adjust if you use a custom component simpy change within cover.py as follows:

    @property
    def is_closed(self):
        """Return if the cover is closed."""
        return self.current_cover_position < 10

While 10 is just an example of the position where you want to specify that the cover is closed. But be careful, this will affect all covers in your component.

ok, will have a look next time
and crap, it started raining, debug was off, so no debug on the rain sensor :frowning:
what i can do to make a rain sensor =
if it starts raining => current position will be some value, so i know it started raining => i can create an automation based on that position, si can open the sun covers too

i just dont know that it stopped raining :slight_smile:

Every time I restart my HA I have to unplug or restart my Velux KLF200. Anyone know a fix for this?

If you use my custom component just create an automation which call the reboot gateway service on Hass stop event:

- id: 'KLF_reboot'
  initial_state: 'on'
  alias: KLF reboot on hass stop event
  description: ''
  trigger:
  - event_data: {}
    event_type: homeassistant_stop
    platform: event
  condition: []
  action:
  - data: {}
    service: my_velux.reboot_gateway
  mode: single
1 Like

Works verry nice indeed :wink:

thanks, i implemented this and it works great!

Will this custom be merged in official HA ?

I’m waiting for a new release of pyvlx. Afterwards the official integration can be updated.

1 Like