YET another time controlled cover (RFLink)

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
3 Likes

Hi Javiclle,

I have been using your implementation of the extended RFLinkCover component for my normal covers controlled by the RFLink. This worked perfect until the 0.81 release the other day.

I see that you have updated your extended RFLinkCover component to work with 0.81, I have copied the new script onto my HA machine, but now none of the covers show the status of the covers. (hope i have the term “Status” correct)

Before the upgrade, if my covers were open the up arrow was grayed out, now if the covers are open the up arrow is clickable or vice versa if they are closed the down arrow is clickable. all three buttons are clickable all the time “open/ stop / close” doesn’t matter the status of the covers.

Keep up the good work on the extended RFLinkCover functionality.

Hi dd77,
I’m glad to hear that my implementation is useful to someone. :ok_hand:

The previous behavior was a side effect of a misinterpretation (from me) of the method assumed_state(self) implementation and use.
According to the official documentation, Cover behavior for the assumed_state it’s the one you are seeing in the new code.
If you preferred the previous behavior, I’m not sure if you can modify it at customize section (I have not checked it) but you always can change the assumed_state(self) function at your rts_rflink.py file.

In my case, I prefer the new behavior because, after HA restarts and some anomalous cases, one of the buttons remain disabled and I could not operate correctly my cover.

PS: v0.81.2 will fix a detected bug and probably I will update some modifications to my code

I was able to update my customize.yaml file with “assumed_state: false” for each of the covers. This gave me the functionally of your previous implementation. So no need to modify your script.

Would you know how to save the state of covers so when HA restarts they all return to the state before the restart. On a restart all my covers state change to closed even if they were open before the restart.

Thanks again for your help, keep up the good work…

Sorry for the delayed answer.

I’m glad to hear that you can get the functionality that you wanted.

I’m in the same boat. Now I’m fighting with some issues from the latest refactor, but this is one of the improvements to achieve.

I can’t give you an ETC, but I have it in my roadmap.

Thanks to you for your feedback.

I just push some changes to implement this functionality.
Although it relies on the recorder component, it should work simply by replacing the rts_rflink.py file in the '\custom_components\cover' folder. In my case, it has worked for me as is.

I’m still testing it, but I think it should be fully functional.

Hi Javiclle,

I’ve upgraded my Home Assistant machine to 0.86.3 and your extended RFLinkCover component no longer works, ive had to configure the standard RFLink covers component for now. Really missing your extended implementation of the rflink covers.

After the upgrade i’m getting -platform not found: cover.rts_rflink.

Are you able to assist?

Hi Divyesh,
sorry for the delay.

After the RestoreEntity refactor, the rts_rflink component broke and I had to modify it.
As I started to try some improvements, I did not upload changes in my repo, and it became unusable.

Now I just uploaded some changes to the repository, but you should keep in mind that they are not tested. If it gives you a problem, I can try to solve it.
You should also be aware that the state’s restoration in the reboots is not working as expected. It’s something I have yet to review, but I can not guarantee that it will be soon.

Hi,
I integrated your rts_rflink.py file in the custom_components \ cover directory.
I configured my configuration.yaml file with the lines :

rflink:
  port: /dev/serial/by-id/usb-Arduino__www.arduino.cc__xxxx_xxxxxxxxxxxxxxxxxxxx-xxxx
  wait_for_ack: false

- platform: rts_rflink
  automatic_add: false
  devices:
    rts_xxxxxx_xx:
      name: Volet Salon
      rts_my_position: 10
      traveling_time_down: 23
      traveling_time_up: 24
      aliases:
       - rts_xxxxxx_xx
       - rts_xxxxxx_xx
    rts_xxxxxx_xx:
      name: Volet Chambre 1
      rts_my_position: 10
      traveling_time_down: 23
      traveling_time_up: 24
      aliases:
       - rts_xxxxxx_xx
       - rts_xxxxxx_xx

It doesn’t work, when I restart HASS I get the error:
Platform error cover.rts_rflink - Integration ‘rts_rflink’ not found
Home Assistant version 0.105.4

I have not maintained / updated the existing version in Github for a long time.
Let me review it and answer you.

I just uploaded the updated version.
The folder structure changed a long time ago and was not updated.
You must create the folder config\custom_components\rts_rflink and put inside all the files from:

You should have the following files:

  • cover.py
  • manifest.json
  • services.yaml

The configuration stays the same:

rflink:
  port: /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
  wait_for_ack: false
cover:
  - platform: rts_rflink
    devices:
      RTS_308742_0:
        name: comedor
        rts_my_position: 35
        travelling_time_down: 23
        travelling_time_up: 25
        aliases:
          - rts_33e53f_01
          - rts_fa872e_01
      RTS_0A8721_0:
        name: ...

If you have any problems, I will try to help you

HI,
Thank you very much, I will give it a try. The HASS RTS Somfy rflink is unfortunately very insufficient.
The big lack and not taking into account a STOP value which is annoying for automations. In addition, when we activate the stop button it causes an On.

Hi,
After a test, always the same error :
Platform error cover.rts_rflink - Integration ‘rts_rflink’ not found

Can you try to change this sentence:

from custom_components.rflink import (
    CONF_ALIASES,
    ...
    RflinkCommand,
)

with this one (just the from part):

from homeassistant.components.rflink import (
    CONF_ALIASES,
    ...
    RflinkCommand,
)

I have some local implementations in the rflink module that I was testing. It should work with that change.

Hi, always the same error.

Have you deleted the cover folder from custom_components?

The only difference that remains is that I have the rflink module inside the custom_components folder.
Try downloading rflink module content (https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/rflink) within the custom_components folder (/custom_components/rflink) and undoing the previous change.

I will see if I can replicate your problem in my installation.

The cover folder is deleted in custom_components \

And do you have all 3 files inside the rflink folder?

I just deleted my rflink folder from the custom_components and made the same change that I propossed and I get this trace from log:

2020-02-17 21:01:32 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for rts_rflink 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.

Do you have any other error traces during startup?

2020-02-17 21:15:56 ERROR (MainThread) [homeassistant.components.hassio] Platform error cover.rts_rflink - Integration 'rts_rflink' not found.

the 3 files are in the rts_rflink directory.
No other error traces during startup.