Custom Component: Cover Time Based

Yes indeed, but in some cases (like in my case) the cover does not send back what it is doing (up/down/stop) when I use a real KNX switch in my house for exemple, so I need to listen to each group addresses that my cover is listening to, to reproduce the movement/stop in Home-Assistant, maybe it is not clear enough in my repo ?
Thanks for your questions !
Maybe I should rename it “Multi group adresses listener for KNX time based cover” ?

Cool.
Have you had a look at https://github.com/XKNX/xknx/pull/441 ? There is no device support yet (and no config options), but you could inject your additional GA-lists directly into the Covers RemoteValue classes (eg. cover.updown or cover.stop_).
I would be interested if it works the same as your implementation.

Thanks !
I think I can try what you want, but how am I supposed to do that ? Should I use xknx custom component in Home Assistant instead of the classic knx component to be able to use these RemoteValue in a Cover ?

Yes, custom component would be the way to test this. You’d need xknx 0.15.3 (or 0.15.2 but I’d skip that) instead of 0.15.0 (used currently in HA).

It could be hardcode-injected here: https://github.com/XKNX/xknx/blob/d75b65e7bf45529e45adffb508f7b1f8dad474ad/home-assistant-plugin/custom_components/xknx/cover.py#L38
like

device.updown.passive_group_addresses = device.updown.get_passive_group_addresses(["1/2/3", "4/5/6"])

which is a little bit rough but should work.

Edit: Or here https://github.com/XKNX/xknx/blob/d75b65e7bf45529e45adffb508f7b1f8dad474ad/home-assistant-plugin/custom_components/xknx/factory.py#L69 so you have the config already available.

Or you add an attribute (/multiple) to the Cover device and set up configuration for this… which we wanted to postpone until the upcoming new configuration schema is ready.

If you need any advice, feel free to join the xknx discord server. Link can be found on xknx.io

Thank you for your explanation. I am still stuck xD Got it fixed:

Here are my configs:
configruation.yaml

  - platform: cover_rf_time_based
    devices:
      my_room_cover_time_based:
        name: My Room Cover
        travelling_time_up: 20
        travelling_time_down: 20
        close_script_entity_id: script.rf_myroom_cover_down
        stop_script_entity_id: script.rf_myroom_cover_stop
        open_script_entity_id: script.rf_myroom_cover_up
        send_stop_at_ends: False #optional
        aliases:
          - my_room_cover_time_based

I did a Binary Sensor like this in configurations.yaml:

binary_sensor:
  - platform: mqtt
    name: Test_Sensor_Up
    state_topic: "stat/TestCov/POWER1"
    payload_on: "ON"
    payload_off: "OFF"
  - platform: mqtt
    name: Test_Sensor_Pause
    state_topic: "stat/TestCov/POWER2"
    payload_on: "ON"
    payload_off: "OFF"
  - platform: mqtt
    name: Test_Sensor_Down
    state_topic: "stat/TestCov/POWER3"
    payload_on: "ON"
    payload_off: "OFF"

and it is working. Turns on and off if i press the button on my cover outside of HA

I’m Stuck on the automations.yaml:

- id: "Cover starts opening external"
  alias: "Cover: set open action from HA"
  trigger:
    - platform: state
      entity_id: binary_sensor.test_sensor_up
      to: "on"
  condition: []
  action:
  - data:
      entity_id: cover.my_room_cover
      action: open
    service: cover_rf_time_based.set_known_action
- id: "Cover stops opening external"
  alias: "Cover: set open action from HA"
  trigger:
    - platform: state
      entity_id: binary_sensor.test_sensor_up
      to: "off"
  condition: []
  action:
  - data:
      entity_id: cover.my_room_cover
      action: stop
    service: cover_rf_time_based.set_known_action

- id: "Cover stopped external"
  alias: "Cover: set stop action from HA"
  trigger:
    - platform: state
      entity_id: binary_sensor.test_sensor_pause
      to: "on"
  condition: []
  action:
  - data:
      entity_id: cover.my_room_cover
      action: stop
    service: cover_rf_time_based.set_known_action

- id: "Cover starts closing external"
  alias: "Cover: set close action from HA"
  trigger:
    - platform: state
      entity_id: binary_sensor.test_sensor_down
      to: "on"
  condition: []
  action:
  - data:
      entity_id: cover.my_room_cover
      action: close
    service: cover_rf_time_based.set_known_action

- id: "Cover stops closing external"
  alias: "Cover: set close action from HA"
  trigger:
    - platform: state
      entity_id: binary_sensor.test_sensor_down
      to: "off"
  condition: []
  action:
  - data:
      entity_id: cover.my_room_cover
      action: stop
    service: cover_rf_time_based.set_known_action

I think I’m doing something seriously wrong in the automation part :smiley:
Maybe it helps some newbies like me

1 Like

Thanks or all your tips !
I am trying to do what you want but I can’t get xknx custom component to work with cover :

Logger: homeassistant.setup
Source: custom_components/xknx/factory.py:69
First occurred: 12:43:29 AM (1 occurrences)
Last logged: 12:43:29 AM

Error during setup of component xknx
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
    result = await task
  File "/config/custom_components/xknx/__init__.py", line 164, in async_setup
    create_knx_device(platform, hass.data[DOMAIN].xknx, device_config)
  File "/config/custom_components/xknx/factory.py", line 43, in create_knx_device
    return _create_cover(knx_module, config)
  File "/config/custom_components/xknx/factory.py", line 69, in _create_cover
    return XknxCover(
TypeError: __init__() got an unexpected keyword argument 'device_class'

I printed xknx version in LOGS and it is 0.15.3 so I really don’t understand why it is not working.
It seems that XknxCover do not accept any ‘device_class’ argument, but I noticed it should be fixed by a recent commit.
Please help me, it is driving me crazy !

This commit came after 0.15.3 release. You’d need to run current master branch instead of 0.15.3 now.

Ok thks,
I was using current master, but now I use an older commit, and it is working well (I think #479 was the problem) !
What you are proposing is doing the same thing as my component, it is nice, I hope it will be soon available in knx in home assistant !
But one thing is that those types of cover need to Remember their state between Home Assistant reboots, and this is done by my component, but not by the knx one, I think there sould be a config option in knx entities to force Home Assistant to remember the state, is this planned ?

It is currently not planned.
Feel free to open an issue, or even better a PR at https://github.com/XKNX/xknx !
Can we know how long the reboot took? If HA was not available for some time, the cover could have moved and the restored state would be wrong. I think a nice alternative could be https://github.com/XKNX/xknx/issues/491#issuecomment-727146543

I suggest we continue the conversation on GitHub or the xknx discord (see xknx.io) since it is getting OT for this thread :wink:

Hi all, i have another problem.

  • Binary Sensors for external commands recognize changes and change the % opened on the bar
  • With activated binary sensors i can’t set the bar to a % value because the curtains don’t stop anymore, just the endpoint. So i can only open or close the curtains if i set a % value in the UI
  • Without the binary sensors everything works finde with the % in the lovelace UI and the curtains stops at the set %

Here my Binary Sensor Automations code:

- id: "Cover starts opening external"
  alias: "Cover: set open action from HA"
  trigger:
    - platform: state
      entity_id: binary_sensor.test_sensor_up
      to: "on"
  action:
  - data:
      entity_id: cover.my_room_cover
      action: open
    service: cover_rf_time_based.set_known_action
- id: "Cover stops opening external"
  alias: "Cover: set open action from HA"
  trigger:
    - platform: state
      entity_id: binary_sensor.test_sensor_up
      to: "off"
  action:
  - data:
      entity_id: cover.my_room_cover
      action: stop
    service: cover_rf_time_based.set_known_action
- id: "Cover stopped external"
  alias: "Cover: set stop action from HA"
  trigger:
    - platform: state
      entity_id: binary_sensor.test_sensor_pause
      to: "on"
  action:
  - data:
      entity_id: cover.my_room_cover
      action: stop
    service: cover_rf_time_based.set_known_action
- id: "Cover starts closing external"
  alias: "Cover: set close action from HA"
  trigger:
    - platform: state
      entity_id: binary_sensor.test_sensor_down
      to: "on"
  action:
  - data:
      entity_id: cover.my_room_cover
      action: close
    service: cover_rf_time_based.set_known_action
- id: "Cover stops closing external"
  alias: "Cover: set close action from HA"
  trigger:
    - platform: state
      entity_id: binary_sensor.test_sensor_down
      to: "off"
  action:
  - data:
      entity_id: cover.my_room_cover
      action: stop
    service: cover_rf_time_based.set_known_action

My Cover and Binary Sensors Entities:

cover:
  - platform: cover_rf_time_based
    devices:
      my_room_cover_time_based:
        name: My Room Cover
        travelling_time_up: 20
        travelling_time_down: 20
        close_script_entity_id: script.rf_myroom_cover_down
        stop_script_entity_id: script.rf_myroom_cover_stop
        open_script_entity_id: script.rf_myroom_cover_up
        send_stop_at_ends: False #optional
        aliases:
          - my_room_cover_time_based   
binary_sensor:
  - platform: mqtt
    name: Test_Sensor_Up
    state_topic: "stat/TestCov/POWER1"
    payload_on: "ON"
    payload_off: "OFF"
  - platform: mqtt
    name: Test_Sensor_Pause
    state_topic: "stat/TestCov/POWER2"
    payload_on: "ON"
    payload_off: "OFF"
  - platform: mqtt
    name: Test_Sensor_Down
    state_topic: "stat/TestCov/POWER3"
    payload_on: "ON"
    payload_off: "OFF"

My Scripts:

rf_myroom_cover_down:
    sequence:
      service: mqtt.publish
      data:
        topic: "cmnd/TestCov/POWER3"
        payload: "ON"
  rf_myroom_cover_stop:
    sequence:
      service: mqtt.publish
      data:
        topic: "cmnd/TestCov/POWER2"
        payload: "ON"
  rf_myroom_cover_up:
    sequence:
      service: mqtt.publish
      data:
        topic: "cmnd/TestCov/POWER1"
        payload: "ON"

And this is what i mean with the UI Bar:
Cover

which is from lovelace-vertical-slider-cover-card if someone is interested.

Hi all
I recently bought a curtain wall switch from Amazon (Maxcio RMT005) and I registered it with Tuya. It works well and I’m able to see it in HA as a curtain switch entity, but I don’t have a slider or anything that indicates the cover position (I assume the device doesn’t expose this information). I wanted to use this integration but I’m not sure what to put in the:

open_switch_entity_id:
close_switch_entity_id:

just because I don’t see these entities as the open and close functions are “embedded” in the device itself (not sure I explain this correctly), so I’m kind of stuck here… Either I don’t know what are the right entities to put there or if this integration is suitable for my case.
Thanks everyone !

Congratulations to @robi and @davidramosweb for this wonderful and powerful Custom Component !

My projet (I am very proud of the concept :smiley:) :

  • SOMFY RTS rolling shutters already integrated to Home Assistant with USB RFXTRX433E and the rfxtrx component : only open / close / stop actions with no status return
  • Implement rfxtrx actions in your scripts in order to use your Custom Component to get the possibility to get actions to open or close a chosen fraction of the shutter and get assumed position : please let me know whether this is a dead-end or not.
  • Get rid of the original SOMFY telecommands in order to avoid losing the good prediction of position in Home Assistant
  • Replace them by the rounded Xiaomi Aqara Switches that take long clicks and multi-clicks with automation written in Node-red : one click would mean manual move up to the end, 2 clicks would mean 1/2 move, 3 clicks would mean 1/3 move, and so on, long click would mean toggle move direction (initial move would be defined according to the initial upper or lower position)

I will share here my configuration and scripts if I get through… and my difficulties if not !

I am already back ! I got it through in the first try. Easy and great !

Here it is my configuration file, implementing the original rfxtrx cover device plus typical to the custom component instructions :

rfxtrx:
  device: /dev/ttyUSB1
  devices:
    # cover.bureau     
    071a00000A5D6D01: # Somfy = 071a0000------01
  # If a device ID consists of only numbers, please make sure to surround it with quotes. This is a known limitation in YAML, because the device ID will be interpreted as a number otherwise.

cover:
  - platform: cover_rf_time_based
    devices:
      shutter_bureau:
        name: Volet roulant du bureau
        travelling_time_up: 28
        travelling_time_down: 26
        close_script_entity_id: script.close_shutter_bureau
        stop_script_entity_id: script.stop_or_my_shutter_bureau
        open_script_entity_id: script.open_shutter_bureau
        send_stop_at_ends: False #optional
        aliases:
          - volet_roulant_du_bureau

Here is my scripts file to make it work with rfxtrx cover :

'open_shutter_bureau':
  alias: 'Ouvre le volet du bureau'
  sequence:
    - service: cover.open_cover
      data:
        entity_id: cover.bureau
        #option: open

'close_shutter_bureau':
  alias: 'Ferme le volet du bureau'
  sequence:
    - service: cover.close_cover
      data:
        entity_id: cover.bureau
        #option: closed

'stop_or_my_shutter_bureau':
  alias: 'Fixe le volet du bureau'
  sequence:
    - service: cover.stop_cover
      data:
        entity_id: cover.bureau
        #option: stop

Feel free to share this configuration with RFXTRX in the documentation… or may be too basic… nevertheless I am happy to succeeding in it.

I encountered one conflicting behavior and I found a workaround :

  • SOMFY RTS shutters on Telis radiocommands have a “My” button which is the same button as “Stop” button, that put the shutter in a predefined position when the button is pressed while the shutter is standstill.
  • Such feature leads to the Custom Component losing the shutter position prediction because when “My” action is triggered then CC sees it as just a “stop” and it doesn’t change and know the final position.
  • In the coding here below, someone implemented such a “My position” in its work : YET another time controlled cover (RFLink)
  • For Cover Timed Based to work properly, I simply suppressed the “My” action from the radiocommand by pressing the “My” button during 5 sec.

Finally, happy to see that this even works with Google Assistant : “open shutter at 50%”.

I am feeling grateful to @robi and @davidramosweb developing this piece of code.

Hi, I’m new in HA and the gituhub on the top of this page is what I search since 5 days.
But, I have a little problem, I can’t assign a new cover to a room.

I have tried to add entity_id, delete name and many other but I can’t figure to attribute a room.

Below my code

cover:
  - platform: cover_time_based
    devices:
      persienne_cuisine:
        name: Persienne Cuisine
        travelling_time_down: 23
        travelling_time_up: 25
        open_switch_entity_id: switch.wall_switch_right
        close_switch_entity_id: switch.wall_switch_left
        aliases:
        - persienne_cuisine

  - platform: cover_time_based
    devices:
      persienne_jardin:
        name: Persienne Jardin
        travelling_time_down: 23
        travelling_time_up: 25
        open_switch_entity_id: switch.wall_switch_right
        close_switch_entity_id: switch.wall_switch_left
        aliases:
        - persienne_jardin

  - platform: cover_time_based
    devices:
      persienne_sdb:
        name: Persienne Salle de Bain
        travelling_time_down: 23
        travelling_time_up: 25
        open_switch_entity_id: switch.wall_switch_right
        close_switch_entity_id: switch.wall_switch_left
        aliases:
        - persienne_sdb

homeassistant:
  customize_glob:
    "cover.*":
      optimistic: true
#      position_template: "50"
#      assumed_state: true

I got this and don’t know how to resolve. It’s the last thing to finish my HA configuration.

HA

Thanks for your help.

You should check the home-assistant.log file for any problems. Try removing the aliases part completely, it’s not used anyways.

Thanks for your quick return. But unfortunately that doesn’t change a thing.

I just see that the entity is in read only mode. I think it’s for that but can’t delete this read only mode

I do it by edit the lovelace UI, but If someone have an idea to do it in the configuration file I will try it, just for know.

Thanks

It’s an issue with HA, not the covers component.
Try this:

  • remove completely all your covers from the configuration file
  • restart HA
  • see if you still have the cover entities present as disabled/read-only etc., and try to delete them
  • restart HA again, see if they come back or not. The goal is to clear all covers from the system completely.
  • put them back in the config file (without alias)
  • restart HA, see what’s up.

This is a great custom component…too bad I discovered it after I built my own system of automations to run an automated furnace damper…but yours is better, so thank you and I’m glad I found it!

One thing I ran into is that timed stuff is never perfect - after multiple back and forth movements there is drift in actual versus measured position. I built a zeroing function that drives the damper all the way to one stop (the damper motor is OK with running against the stop for a period of time), and then moves it back to the position the system ‘thought’ it was in.

This would be easy enough to do using the existing component, but might be a useful thing to add as a function (I imagine I’m not the only one to experience this).

Anyway, thanks again!!

On another note, is there a way to set the value of “current_position” using a script, without causing the cover to physically move? Easier than running out the time needed to let the cover get itself there…