Custom Component: Cover Time Based

I noticed that since updating my Sonoff RF Bridge to late 9.x tasomta firmware versions, my covers miss a lot more times the codes transmitted. This happens when multiple covers are opened at once or quickly one after another.

I tried by sending repeats etc. but I only found improvement if I took out the rfraw 0 from the payload, including the backlogs.

Instead, I only send a single rfraw 0 after I assume cover operations stopped (in my case 40 seconds is enough. I modified the scripts by employing a separate transmitter script which takes care of queuing the transmission of the codes and keeping an appropriate delay between them, and a small automation to check when was that send last time. Documentation updated at:

Hi there,

The Documentation describes the set_known_action as following: ā€œThis service mimics cover movement in Home Assistant without actually sending out commands to the cover.ā€

If i activate the set known action automation the cover movement over the external switches is mimiced correctly.
But if i try to use the UI-Slider of HA to set a desired position, the cover only opens or closes completely. Any Idea how i can fix that? Iā€™m almost 1 week investigating now :frowning: Without the set known action service everything works.

Here is what i see in the log file after setting the position from 47 to 57. The cover stops at 100.

2021-03-30 23:37:14 DEBUG (MainThread) [custom_components.cover_rf_time_based.cover] My Room Cover: async_set_cover_position: 57
2021-03-30 23:37:14 DEBUG (MainThread) [custom_components.cover_rf_time_based.cover] My Room Cover: set_position
2021-03-30 23:37:14 DEBUG (MainThread) [custom_components.cover_rf_time_based.cover] My Room Cover: set_position :: current_position: 47, new_position: 57
2021-03-30 23:37:14 DEBUG (MainThread) [custom_components.cover_rf_time_based.cover] My Room Cover: start_auto_updater
2021-03-30 23:37:14 DEBUG (MainThread) [custom_components.cover_rf_time_based.cover] My Room Cover: init _unsubscribe_auto_updater
2021-03-30 23:37:14 DEBUG (MainThread) [custom_components.cover_rf_time_based.cover] My Room Cover: set_position :: command open_cover
2021-03-30 23:37:14 DEBUG (MainThread) [custom_components.cover_rf_time_based.cover] My Room Cover: _async_handle_command :: UP
2021-03-30 23:37:14 DEBUG (MainThread) [custom_components.cover_rf_time_based.cover] My Room Cover: auto_updater_hook
2021-03-30 23:37:14 INFO (MainThread) [homeassistant.components.automation.cover_set_open_action_from_ha_2] Open Action Test Cover: Running automation actions
2021-03-30 23:37:14 INFO (MainThread) [homeassistant.components.automation.cover_set_open_action_from_ha_2] Open Action Test Cover: Executing step call service
2021-03-30 23:37:14 DEBUG (MainThread) [custom_components.cover_rf_time_based.cover] My Room Cover: start_auto_updater
...
2021-03-30 23:37:25 DEBUG (MainThread) [custom_components.cover_rf_time_based.cover] My Room Cover: auto_updater_hook :: position_reached
2021-03-30 23:37:25 DEBUG (MainThread) [custom_components.cover_rf_time_based.cover] My Room Cover: stop_auto_updater

In Case someone has the same issue:
I fixed it by defining an input_boolean which listens to the set_position event. If that occurs the set_known_actionā€™s are ignored.

#Toggles
- id: Test Toggle On
  alias: toggleautomation_on
  trigger:
  - platform: event
    event_type: call_service
    event_data:
      domain: cover
      service: set_cover_position
      service_data:
        entity_id: cover.my_room_cover
  action:
  - service: input_boolean.turn_on
    entity_id: input_boolean.testtoggle
- id: Test Toggle Off
  alias: toggleautomation_off
  trigger:
  - platform: state
    entity_id: switch.pause_8
    to: 'on'
  action:
  - service: homeassistant.turn_off
    entity_id: input_boolean.testtoggle
#Cover known action
- id: Cover stopped external
  alias: Stop Action Test Cover
  trigger:
  - platform: state
    entity_id: switch.pause_8
    to: 'on'
  action:
  - service: cover_rf_time_based.set_known_action
    data:
      entity_id: cover.my_room_cover
      action: stop
- id: Cover up
  alias: testup
  description: ''
  trigger:
  - platform: state
    entity_id: switch.up_8
    to: 'on'
  condition:
  - condition: state
    entity_id: input_boolean.testtoggle
    state: 'off'
  action:
  - service: cover_rf_time_based.set_known_action
    data:
      entity_id: cover.my_room_cover
      action: open
- id: Cover Down
  alias: testdown
  description: ''
  trigger:
  - platform: state
    entity_id: switch.down_8
    to: 'on'
  condition:
  - condition: state
    entity_id: input_boolean.testtoggle
    state: 'off'
  action:
  - service: cover_rf_time_based.set_known_action
    data:
      entity_id: cover.my_room_cover
      action: close

Thank you for this CC @robi

Would it be possible to call the open/close/stop scripts with arguments / variables ? It would be great because it will allow us to write only one script for all covers. When you have a lot of covers it is very tedious and adds a lot of noise in HA to add as many scripts as covers.

Problem is that various cover types need various parameter/argument numbers and types, itā€™s near impossible to make one universal function to fit everybodyā€™s needs.

This has been discussed many times, you have to do the hard work only once.
A little trickery with copy+paste and then replace can speed up the work in a text editor like Notepad++.

To eliminate noise, use split config and keep scripts in a separate file.

When using something like ā€œBroadlink RM4 Proā€ as a RF bridge - is it still possible to calculate the position when activating blinds/shutters etc. using the original RF remote control.

Or should I steer clear of using the RF remote as it would mess up the position ?
I guess it would be nice to have a setup where you are still able to control your blinds with the RF remote even with home assistant down.

Using the RF remote would make home assistant unaware of the user activating it unless the RF bridge is able to pick this up then relay this info as events which in turn are picked up by this custom control which would make it possible to calculate a position based on this.

Hi,

Iā€™m using a Broadlink RMPro to open and close my shutters.
Did you found a way to use the stop command and time based component?

I was doing this earlier today! Hereā€™s my config:

- platform: cover_rf_time_based
  devices:
      deck_bbq_cover_time_based:
        name: Deck BBQ Cover
        travelling_time_up: 14
        travelling_time_down: 14
        close_script_entity_id: script.deck_bbq_cover_down
        stop_script_entity_id: script.deck_bbq_cover_stop
        open_script_entity_id: script.deck_bbq_cover_up

Could you please tell me where you placed this script and the other files you used?
This topic itā€™s a bit confused (for me of course).

Iā€™ve split my configuration.yaml into smaller .yaml files, one for scripts one for covers etc. As such yours might be different than the below:

cover.yaml

- platform: cover_rf_time_based
  devices:
      office_cover_time_based:
        name: Office Cover
        travelling_time_up: 17
        travelling_time_down: 17
        close_script_entity_id: script.office_cover_down
        stop_script_entity_id: script.office_cover_stop
        open_script_entity_id: script.office_cover_up

scripts.yaml

office_cover_up:
  sequence:
    - service: remote.send_command
      data:
        entity_id: remote.office_broadlink
        device: office_cover
        command: open
office_cover_down:
  sequence:
    - service: remote.send_command
      data:
        entity_id: remote.office_broadlink
        device: office_cover
        command: close
office_cover_stop:
  sequence:
    - service: remote.send_command
      data:
        entity_id: remote.office_broadlink
        device: office_cover
        command: stop

Then in a hidden folder in your config folder called .storage you should have a file with a similar name to this. This file and the content are auto created by the broadlink integration when you use the learn service:

broadlink_remote_780f77634fbf_codes

{
    "version": 1,
    "key": "broadlink_remote_780f77634fbf_codes",
    "data": {
        "office_cover": {
            "close": "sgD4AZ4yDBgXDRcNFg0XDQwYCxkXDQwYFw0LGQsYDBgXDQwYFw4LGAwYDBgXDRcNCxkXDQsZFw0XDBcOCxgMGAwYCxgYDQsZDBkLGRYNDBgMGAsZFwABIZ0yDBgXDRcNFg0XDQwYDBgXDQwYFw0LGQsZCxgXDQwYFw0NGQsYDBgXDRcNCxkXDAwZFw0XDRcNCxgMGAwYCxkXDQwYCxkLGBcNDBgMGAwYFwABIZ0zDBgXDRcNFw0WDQwYDBgXDQwYFw0MGAwYCxkXDAwYFw4LGAwYDBgXDRcNCxkXDQsZFw0XDRcMDBgMGAwYCxkXDQsZCxgMGBcODBgMGAwYFwABJ50yCxkXDRcNFw0WDQwYCxkXDQwYFw0LGQsYDBgXDQwYFw0MGAwYCxoXDRcNCxgXDgsZFw0XDRYNDBgMGAwYCxkXDQsZCxkLGBcNDBgLGQsYFwABIp0yCxgXDxYNFw0XDQwYCxkXDQwYFw0MGAsZCxgXDQwYFw0MGAwYCxkXDRcNCxgXDQwYFw4XDBcNDBgLGQsZCxgXDQwYDBgMGBcNCxkLGQsaFwABIZ0yCxgYDRYNFw0XDQwYCxkXDQsZFw0LGQsYDBgXDQwYFw0MGAsZCxkXDRcMDBkXDQwZFw0XDBcNDBgMGAsZCxgXDgsYDBgMGBcNCxkLGQsYFwAF3A==",
            "open": [
                "sgD0Ap0yCxkXDRcNFw0WDQwZChkXDgsYFw0LGQsZCxkWDQwZFg4LGQsYDBgXDRcNCxkYDQsZFw0XDRcNCxkLGQsZCxgXDQwYDBgXDRcNCxkLGRYNFwABIp0yCxkXDBcOFg0XDQwZDBgXDQwYFw0MGAsZCxkWDgsYFw4LGQsZCxgXDRcNCxkXDQsZFw0XDRcNCxkLGAwYDBgXDQsZDBgXDRcNCxkLGRYNFwABI50yCxkXDRYOFg0XDQwYCxkXDQwYFw0LGQsZCxkWDgsYFw4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gXDRcNCxkXDQsZFw0XDRcNCxkLGQsYDBgXDgsYCxkXDRYOCxkLGRYNFwAF3AAAAAAAAAAAAAAAAA=="
            ],
            "stop": "sgD4AZ0xDBgXDRcNFw0XDQsZCxgYDQsZFw0LGAwYDBgYDQwYFw0MGAwYCxgYDBcOCxgXDQwYFw0XDRcNCxkLGQsZCxgXDgsYGAwMGBcNDBgXDQsYGAABIZ4yCxkXDRcMGAwXDQwYDBgXDQwYFw0MGAsZCxkXDAwYFw4LGAwYDBgXDRcNCxkXDAwZFw0XDRcMDBgMGAwYDBgXDQsaFw0LGBgNCxgXDQwYFwABIZ4xDBgXDRcNFw0XDQsZCxgYDQsZFw0LGAwYDBgXDQsZFw4LGQsZCxgXDRcNDBgXDQsZFw0XDRcNDBgLGAwYDBgXDQwYFw0MGBcNDBcYDQsYFwABKJ0yDBgXDRcNFw0XDQwYCxgXDgwYFwwMGAwYDBgXDQsZFw0MGAwYCxgYDBgMDBgXDQwYGAwXDRcNDBgMGAsYDBgXDQwYFw0MGBgNCxgYDAwYGAABIJ4yCxgXDRcNFw0XDQwYCxgYDQwYFw0LGQsYDBgXDQwYFw0MGAsZCxoXDRYNDBgXDQwYFw0XDRcNDBgLGQsYDBgYDAwYFw0MGBcNCxgYDAwYFwABIp0yCxgYDRcNFw0XDQwXDBgYDQwXGA0LGAwYDBgXDQwYFw0MGAsZCxgXDRgMDBgXDQwYFw0XDRcNDBgLGQsYDBgXDgsYFw0MGBcNDBgXDA0YFwAF3A=="
        }
    }
}

Hope it helps.

2 Likes

Thank you very much for your attention!! Iā€™m going to try it this weekend!
Just one more thingā€¦ What did you placed on your configuration.yaml?

The only relevant parts are:

cover: !include cover.yaml
script: !include scripts.yaml 

There is no need to split the confg and have the ā€˜coverā€™ code and ā€˜scriptā€™ code in other config files, itā€™s just the way I decided to do it.

2 Likes

Thank you very much!

Humā€¦ Iā€™m missing something here. It was refrered before but I have HACS installedā€¦
What addon shoul I install from HACS?

Platform error cover.cover_rf_time_based - Integration 'cover_rf_time_based' not found.

Iā€™m sorry about these dumb questions but Iā€™m new to HA. I came from Homebridgeā€¦ :slight_smile:

Someone? Please?

@rn1 when you go to HACS > Integrations do you have ā€™ Cover Time Based RF (trigger script)ā€™ listed? If not you need to first install it.

1 Like

I did search but I guess I donā€™t have that repository. I have HACS and a lot of addons but not the "Cover Time Based RFā€¦

Thank you for your help!!

Try this:

HACS > Integrations > Explore & Add Repositories (bottom right) and then search for: Cover Time Based Component

Iā€™m sure itā€™s available in the default HACS repository.

1 Like

I was missing that script. Thank you!!!

Do you think that is possible to integrate with this?
Shutter Card