After trying some of the time controlled covers based in automations (with poor results) I found the implementation for KNX cover:
This piece of code is the basis for my implementation. The merit and all my grats for the KNX developers/mainteners.
My implementation extends RFLinkCover and is very specific for RTS covers (a.k.a. Somfy covers). Still it’s a work in progress
It works better with
wait_for_ack: false
(disabled).# RFLink component rflink: port: /dev/serial/by-id/usb-1234_USB2.0-Serial-abcd-port0 wait_for_ack: false
If not setted, every command can take up to 4 seconds to execute and some commands can get lost, executed when cover is stoped or whatever.
You must configure the travel times (in seconds) and the MY position (0-100 where 0 is closed and 100 open). The MY position is used to calculate the cover position.
- platform: rts_rflink
devices:
RTS_0A8720_0:
name: enanos
rts_my_position: 10
travelling_time_down: 14
travelling_time_up: 15
aliases:
- rts_31e53f_01
- rts_32e53f_01
- RTS_32E542_0
You can test my implementation copying at config\custom_components\rts_rflink
all the files from the repo folder:
You must have at least 3 files:
cover.py
manifest.json
services.yaml
Some ‘improvements’ over oficial RFLink cover:
- cleaned some constants (now imported from RFLink component)
- time based control for
set_position()
- cover exposes
is_opening
&is_closing
states - aliases updates the cover state consistently (ex: when using control remote)
- cover entity exposes more attributes (my_position, traveltimes,…)
- cover supports
set_position
feature - cover exposes the (calculated)
current_cover_position
And some things to improve:
- not happy with the component name (
rts_rflink
) - not happy with
_require_stop_cover
flag. There has to be a better way to manage it. - a very (too much) optimistic implementation. Counters begins before execute commands, no error control, …
- actions in short period of time or over the edges (open/closed cover) may generate unexpected behaviors.
Disclaimer: this is my first contribution and my first coding with python.
Update:
I have added the type
attribute wich allow to define an inverted cover. It can be configured like:
- platform: rts_rflink
devices:
RTS_0A9620_0:
name: inverted_cover
type: inverted
rts_my_position: 10
travelling_time_down: 14
travelling_time_up: 15