Giter Site home page Giter Site logo

nagyrobi / home-assistant-custom-components-cover-rf-time-based Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davidramosweb/home-assistant-custom-components-cover-time-based

78.0 7.0 74.0 197 KB

Time-based cover with customizable scripts or entity to trigger opening, stopping and closing. Position is calculated based on the fraction of time spent by the cover traveling up or down. State can be updated with information based on external sensors.

Python 100.00%
home-assistant cover trigger rf 433 433mhz script service shutter roller-shutters

home-assistant-custom-components-cover-rf-time-based's Introduction

NOTE

Since I moved the time-based functionality to an ESPHome node, which works much better as it's being done in hardware, I'm archiving this repository and stop maintaining it.

Anyone feel free to fork it and continue development as needed.

Cover Time Based script/entity

Cover Time Based Component for your Home-Assistant based on davidramosweb's Cover Time Based Component, modified for native cover entities, covers triggered by RF commands, or any other unidirectional methods.

Note: Since ESPHome v1.15.0 (September 13, 2020) it is possible to implement a Time Based Cover entirely in the Sonoff RF Bridge hardware, which excludes the necessity of this component (at least of the RF part). Jump to the bottom of this readme for an example how to set it up.

With this component you can add a time-based cover. You either have to set triggering scripts to open, close and stop the cover or you can use an existing cover entity provided by another integration which does not have timing or status feedback. Position is calculated based on the fraction of time spent by the cover travelling up or down. You can set position from within Home Assistant using service calls. When you use this component, you can forget about the cover's original remote controllers or switches, because there's no feedback from the cover about its real state, state is assumed based on the last command sent from Home Assistant. There's also a custom service available where you can update the real state of the cover based on external sensors if you want to.

You can adapt it to your requirements, actually any cover system could be used which uses 3 triggers: up, stop, down. The idea is to embed your triggers into scripts which can be hooked into this component via config. For example, you can use RF-bridge or dual-gang switch running Tasmota or ESPHome firmware integrated like in the examples shown below.

When you use it to extend functionality of an existing cover implementation, this component will generate a new cover entity with these new features.

The component adds two services set_known_position and set_known_action which allow updating HA in response to external stimuli like sensors.

The entities generated by this component have assumed states, which are remembered between Home Assistant restarts.

Support forum

Installation

hacs_badge

  • Install using HACS, or manually: copy all files in custom_components/cover_rf_time_based to your /custom_components/cover_rf_time_based/ directory.
  • Restart Home-Assistant.
  • Create the required scripts in scripts.yaml.
  • Add the configuration to your configuration.yaml.
  • Restart Home-Assistant again.

Usage

To use this component in your installation, you have to either set RF-sending scripts to open, close and stop the cover (see below), or use an existing cover entity provided by another integration, which is missing the features provided here.

Example configuration.yaml entry

Add the following to your configuration.yaml file:

cover:
  - platform: cover_rf_time_based
    devices:
      my_room_cover_time_based:
        name: My Room Cover
        travelling_time_up: 36
        travelling_time_down: 34
        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
        always_confident: False #optional
        device_class: garage #optional
        availability_template: "{{ is_state('binary_sensor.rf_bridge_status', 'on') }}" #optional

OR:

cover:
  - platform: cover_rf_time_based
    devices:
      my_room_cover_time_based:
        name: My Room Cover
        travelling_time_up: 36
        travelling_time_down: 34
        cover_entity_id: cover.myroom
        send_stop_at_ends: True #optional
        always_confident: True #optional
        device_class: curtain #optional
        availability_template: "{{ not (is_state('cover.myroom', 'unavailable') or is_state('cover.myroom', 'unknown')) }}" #optional

All mandatory settings self-explanatory.

Optional settings:

  • send_stop_at_ends defaults to False. If set to True, the Stop script will be run after the cover reaches to 0 or 100 (closes or opens completely). This is for people who use interlocked relays in the scripts to drive the covers, which need to be released when the covers reach the end positions.
  • always_confident defaults to False. If set to True, the calculated state will always be assumed to be accurate. This mainly affects UI components - for example, if the cover is fully opened, the open button will be disabled. Make sure to set the current state after first setup and only use this entity to control the covers. Not recommended to be True for RF-based covers.
  • device_class defaults to shutter if not specified. See the docs for availale cover device classes.
  • availability_template if not specified will make the cover always available. You can use a template returning True or False in order to toggle availability of the cover based on other entities. Useful to link with the connection status of your RF Bridge or relays device.

Example scripts.yaml entry

RF covers

The following example assumes that you're using an RF bridge running Tasmota or ESPHome open source firmware to integrate your radio-controlled covers. The command scripts pass the rfraw_data parameter to a general transmitter script which takes care of queuing the transmission of the codes and keeping an appropriate delay between them:

'rf_transmitter':
  alias: 'RF Transmitter'
  mode: queued
  max: 30
  sequence:
    # With Tasmota
    - service: mqtt.publish
      data:
        topic: 'cmnd/rf-bridge-1/rfraw'
        payload: '{{ rfraw_data }}'
    # With ESPHome
    - service: esphome.sonoff_rf_bridge_send_rf_raw
      data:
        raw: '{{ rfraw_data }}'
    # add a little delay
    - delay: 00:00:01

'rf_myroom_cover_down':
  alias: 'RF send MyRoom Cover DOWN'
  mode: single
  max_exceeded: silent
  sequence:
    - service: script.turn_on
      target:
        entity_id: script.rf_transmitter
      data:
        variables:
          rfraw_data: 'AAB0XXXXX....XXXXXXXXXX'

'rf_myroom_cover_stop':
  alias: 'RF send MyRoom Cover STOP'
  mode: single
  max_exceeded: silent
  sequence:
    - service: script.turn_on
      target:
        entity_id: script.rf_transmitter
      data:
        variables:
          rfraw_data: 'AAB0XXXXX....XXXXXXXXXX'

 'rf_myroom_cover_up':
  alias: 'RF send MyRoom Cover UP'
  mode: single
  max_exceeded: silent
  sequence:
    - service: script.turn_on
      target:
        entity_id: script.rf_transmitter
      data:
        variables:
          rfraw_data: 'AAB0XXXXX....XXXXXXXXXX'

Note that for RAW data you also need the Portisch firmware to be flashed on the EFM8BB1 embedded RF-transmitter chip of the bridge unit.

For the scripts above with Tasmota you need a small automation in automations.yaml to set RfRaw back to 0 to avoid spamming your MQTT server with loads of sniffed raw RF data. This trigger is checked every minute only so set > 40 set in the value_template to be a bit bigger than your biggest travelling_time:

- id: rf_transmitter_tasmota_cancel_sniff
  alias: 'RF Transmitter Tasmota cancel sniffing'
  trigger:
    platform: template
    value_template: "{{ ( as_timestamp(now()) - as_timestamp(state_attr('script.rf_transmitter', 'last_triggered')) | int(0) ) > 40 }}"
  action:
    - service: mqtt.publish
      data:
        topic: 'cmnd/rf-bridge-1/rfraw'
        payload: '0'

Switched covers

The example below assumes you've set send_stop_at_ends: True in the cover config, and you're using any two-gang switch running Tasmota open source firmware to integrate your switch-controlled covers:

'rf_myroom_cover_down':
  alias: 'Switches send MyRoom Cover DOWN'
  mode: single
  max_exceeded: silent
  sequence:
    - service: mqtt.publish
      data:
        topic: 'cmnd/myroomcoverswitch/POWER1' # open/close
        payload: 'OFF'
    - service: mqtt.publish
      data:
        topic: 'cmnd/myroomcoverswitch/POWER2' # power
        payload: 'ON'

'rf_myroom_cover_stop':
  alias: 'Switches send MyRoom Cover STOP'
  mode: single
  max_exceeded: silent
  sequence:
    - service: mqtt.publish
      data:
        topic: 'cmnd/myroomcoverswitch/POWER2' # power
        payload: 'OFF'
    - service: mqtt.publish
      data:
        topic: 'cmnd/myroomcoverswitch/POWER1' # open/close
        payload: 'OFF'

'rf_myroom_cover_up':
  alias: 'Switches send MyRoom Cover UP'
  mode: single
  max_exceeded: silent
  sequence:
    - service: mqtt.publish
      data:
        topic: 'cmnd/myroomcoverswitch/POWER1' # open/close
        payload: 'ON'
    - service: mqtt.publish
      data:
        topic: 'cmnd/myroomcoverswitch/POWER2' # power
        payload: 'ON'

Note how you don't have to configure these as switches in Home Assistant at all, it's enough just to publish MQTT commands strainght from the script (credits to VDRainer for this example). Of course you can customize based on what ever other way to trigger these 3 type of movements. You could, for example, turn on and off warning lights along with the movement.

Services to set position or action without triggering cover movement

This component provides 2 services:

  1. cover_rf_time_based.set_known_position lets you specify the position of the cover if you have other sources of information, i.e. sensors. It's useful as the cover may have changed position outside of HA's knowledge, and also to allow a confirmed position to make the arrow buttons display more appropriately.
  2. cover_rf_time_based.set_known_action is for instances when an action is caught in the real world but not process in HA, .e.g. an RF bridge detects a stop action that we want to input into HA without calling the stop command.

cover_rf_time_based.set_known_position

In addition to entity_id and position takes 2 optional parameters:

  • confident that affects how the cover is presented in HA. Setting confident to true will mean that certain button operations aren't permitted.
  • position_type allows the setting of either the target or current posistion.

Following examples to help explain parameters and use cases:

  1. This example automation uses position_type: current and confident: true when a reed sensor has indicated a garage door is closed when contact is made:
- id: 'garage_closed'
  alias: 'Doors: garage set closed when contact'
  trigger:
  - entity_id: binary_sensor.door_garage_cover
    platform: state
    to: 'off'
  condition: []
  action:
  - data:
      confident: true
      entity_id: cover.garage_door
      position: 0
      position_type: current
    service: cover_rf_time_based.set_known_position

We have set confident to true as the sensor has confirmed a final position. The down arrow is now no longer available in default HA frontend when the cover is closed. position_type of current means the current position is moved immediately to 0 and stops there (provided cover is not moving, otherwise will contiune moving to original target).

  1. This example uses position_type: target (the default) and confident: false (also default) where an RF bridge has interecepted an RF command, so we know an external remote has triggered cover opening action:
- id: 'rf_cover_opening'
  alias: 'RF_Cover: set opening when rf received'
  trigger:
  - entity_id: sensor.rf_command
    platform: state
    to: 'open'
  condition: 
  - condition: state
    entity_id: cover.rf_cover
    state: closed
  action:
  - data:
      entity_id: cover.rf_cover
      position: 100
    service: cover_rf_time_based.set_known_position

confident is omitted so defaulted to false as we're not sure where the movement may end, so all arrows are available. position_type is omitted so defaulted to target, meaning cover will transition to position without triggering any start or stop actions.

cover_rf_time_based.set_known_action

This service mimics cover movement in Home Assistant without actually sending out commands to the cover. It can be used for example when external RF remote controllers act on the cover directly, but the signals can be captured with an RF brigde and Home Assistant can play the movement in parrallel with the real cover. In addtion to entity_id takes parameter action that should be one of open, close or stop.

Example:

- id: 'rf_cover_stop'
  alias: 'RF_Cover: set stop action from bridge trigger'
  trigger:
  - entity_id: sensor.rf_command
    platform: state
    to: 'stop'
  condition:[]
  action:
  - data:
      entity_id: cover.rf_cover
      action: stop
    service: cover_rf_time_based.set_known_action

In this instance we have caught a stop signal from the RF bridge and want to update HA cover without triggering another stop action.

Icon customization

For proper icon display (opened/moving/closed) customization can be added with option device_class set either in the cover's config, based of what type of covers you have.

Can also be done in configuration.yaml:

homeassistant:
  customize_domain: #for all covers 
     cover:
      device_class: curtain
  customize: #for each cover separately
    cover.my_room_cover_time_based:
      device_class: curtain

More details in Home Assistant device class docs.

Some tips

When using this component with Tasmota RF Bridge in automations

Since there's no feedback from the cover about its current state, state is assumed based on the last command sent, and position is calculated based on the fraction of time spent travelling up or down. You need to measure time by opening/closing the cover using the original remote controller, not through the commands sent from Home Assistant (as they may introduce some delay).

Tasmota RF bridge is able to send out the radio-frequency commands very quickly. If some of your covers 'miss' the commands occassionally (you can see that from the fact that the state shown in Home Assistant does not correspond to reality), it may be that those cover motors do not understand the codes when they are sent 'at once' from Home Assistant.

This can be handled in multiple ways:

  • try increasing your RF range. Make sure the wire antennas of the covers are not tied close to the power cables or to big metallic surfaces. For 433MHz, the antenna length should be around 17cm (this may include the part going inside the tube motor). Sonoff RF Bridge has two copper helical antennas near the PCB, you can unsolder them and simply solder in place two straight hard wires of 17.3cm, which can go out through some small holes on the sides of the unit. You need to solder only one end of each wire, to the points where the helical legs were shorter (points U7 and U8). This will increase the range substantially, to the cost of aesthetics.
  • avoid backlogs with rfraw AAB0XXXXX....XXXXXXXXXX; rfraw 0 if you need multiple covers opening and closing at once. Switching the sniff on and off quickly for every cover movement may cause issues. It's enough to send rfraw 0 only once with some delay after all procedures related to cover movements finished, the example scripts above take care of that.
  • if you are sending 0xB0 codes (decoded with BitBucketConverter.py) you can tweak those to be sent with repetitions (multiple times) by changing the repetition parameter (5th byte) of the code. For example 20 repetitions can be achieved by changing 5th byte from 04 to 14. Also BitBucketConverter can be run by specifiying the required repetitions at command line before decoding. Some covers might not like this, though.
  • alternatively, you can further reduce stress by making sure you don't use cover groups containing multiple covers provided by this integration, and also in automation don't include multipe covers separated by commas in one service call. You could create separate service calls for each cover, moreover, add more delay between them:
- alias: 'Covers down when getting dark'
  mode: single
  max_exceeded: silent
  trigger:
    - platform: numeric_state
      below: 400
      for: "00:05:00"
      entity_id: sensor.outside_light_sensor
  action:
    - service: cover.close_cover
      entity_id: cover.room_1
    - delay: '00:{{ (range(1,10)|random|int) }}:00'
    - service: cover.close_cover
      entity_id: cover.room_2
    - delay: '00:00:02'
    - service: cover.set_cover_position
      data:
        entity_id: cover.room_3
        position: 20
    - delay: '00:00:01'
    - service: cover.set_cover_position
      data:
        entity_id: cover.room_4
        position: 30

Implementation with ESPHome

Use the following configuration for ESPHome on Sonoff RF Bridge:

substitutions:
  device_name: sonoff-rf-bridge
  friendly_name: "RF Bridge"
  device_ip: 192.168.81.22

esphome:
  name: ${device_name}
  platform: ESP8266
  board: esp01_1m
  esp8266_restore_from_flash: true

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: ${device_ip}
    gateway: 192.168.81.254
    subnet: 255.255.255.0
  use_address: ${device_ip}

logger:
  baud_rate: 0
  level: INFO

uart:
  tx_pin: GPIO01
  rx_pin: GPIO03
  baud_rate: 19200

rf_bridge:

api:
  reboot_timeout: 15min
  password: !secret api_password
  encryption:
    key: !secret encryption_key
  services:
    - service: send_rf_raw
      variables:
        raw: string
      then:
        - rf_bridge.send_raw:
            raw: !lambda 'return raw;'

ota:
  password: !secret ota_password

web_server:
  version: 2
  local: true
  port: 80
  auth:
    username: !secret web_server_adminuser
    password: !secret web_server_password

sensor:
  - platform: wifi_signal
    name: ${friendly_name} WiFi signal
    update_interval: 60s
  - platform: uptime
    name: ${friendly_name} Uptime

status_led:
  pin:
    number: GPIO13
    inverted: true

binary_sensor:
- platform: status
  name: ${friendly_name} Status

button:
- platform: restart
  name: ${friendly_name} Restart
  
cover:
- platform: time_based
  name: 'My Room Cover'
  device_class: shutter
  assumed_state: true
  has_built_in_endstop: true

  close_action:
    - rf_bridge.send_raw:
        raw: 'AAB0XXXXX....XXXXXXXXXX'
  close_duration: 34

  stop_action:
    - rf_bridge.send_raw:
        raw: 'AAB0XXXXX....XXXXXXXXXX'

  open_action:
    - rf_bridge.send_raw:
        raw: 'AAB0XXXXX....XXXXXXXXXX'
  open_duration: 36s

For multiple covers to be operated simultaneously, a delay is needed between sending out the codes, this can also be done within ESPHome, see detailed configuration example.

home-assistant-custom-components-cover-rf-time-based's People

Contributors

alfiegerner avatar barmazu avatar nagyrobi avatar regevbr avatar vdrainer avatar wrt54g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

home-assistant-custom-components-cover-rf-time-based's Issues

xknx SessionAuthenticate Error Home Assistant 2022.8.1

I am getting the following error during HA startup. I'm using a raspberry pi 4 with Bullseye OS and HA in a docker environment. Until now I never had a problem with this component but suddenly this one popped up. I'm using a MQTT based cover.

home-assistant | 2022-08-06 11:56:09.193 ERROR (MainThread) [homeassistant.components.cover] Error while setting up cover_rf_time_based platform for cover home-assistant | Traceback (most recent call last): home-assistant | File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform home-assistant | await asyncio.shield(task) home-assistant | File "/config/custom_components/cover_rf_time_based/cover.py", line 150, in async_setup_platform home-assistant | async_add_entities(devices_from_config(config)) home-assistant | File "/config/custom_components/cover_rf_time_based/cover.py", line 132, in devices_from_config home-assistant | device = CoverTimeBased(device_id, home-assistant | File "/config/custom_components/cover_rf_time_based/cover.py", line 178, in __init__ home-assistant | from xknx.devices import TravelCalculator home-assistant | File "/usr/local/lib/python3.10/site-packages/xknx/__init__.py", line 3, in <module> home-assistant | from .xknx import XKNX home-assistant | File "/usr/local/lib/python3.10/site-packages/xknx/xknx.py", line 9, in <module> home-assistant | from xknx.io import ConnectionConfig, KNXIPInterface home-assistant | File "/usr/local/lib/python3.10/site-packages/xknx/io/__init__.py", line 10, in <module> home-assistant | from .request_response import RequestResponse home-assistant | File "/usr/local/lib/python3.10/site-packages/xknx/io/request_response/__init__.py", line 6, in <module> home-assistant | from .authenticate import Authenticate home-assistant | File "/usr/local/lib/python3.10/site-packages/xknx/io/request_response/authenticate.py", line 6, in <module> home-assistant | from xknx.knxip import KNXIPFrame, SessionAuthenticate, SessionStatus home-assistant | ImportError: cannot import name 'SessionAuthenticate' from 'xknx.knxip' (/usr/local/lib/python3.10/site-packages/xknx/knxip/__init__.py)

Feature request

Hi Robi!

Congratulation about this great add-on.
May I suggest a feature?
I used this to control the shutters. But the shutters build up with slates.
There is a time when the lowest slate hits the ground, and there is an another time when all the slates closed.
It would be good if your solution can handle this functionality.

I mean when we set 50%, the shutter should cover the half of the window, when I set 100% the shutter lowest slate should reach the ground, and after it we should go forward, to completely close the shutter if we want.

So one timer for cover the whole window, and a 2nd timer after it to close the shutter.

I hope I was clear...

Thank you

László

Call stop script when cover is opened

In lovelace I click on up button and this integration call up script.
When cover is opened I would the integration call stop script
Is it possible?
Thanks

using cover_rf_time_based One device works prefectly other won't stop to set position

Hi, Im using the cover_rf_time_based to set my ZigBee shutters so I have position cover etc. One will work without faults open, close and set position, but the other will continue to run either to 0% or 100% and won't stop when set position. if i remove the cover and re add it for that one device will start working but then the issue swaps to the other.

Adding cover to configuration.yaml cause KNX stop working

Hi guys, I'm noticing some problem with this integration. I've installed it with HACS (version 1.0.8), and I'm using HASSIO on raspberry 3 (core version 2021.5.1, supervisor 2021.04.3, OS 5.13).

I've installed the custom component, rebooted, added script and configuration, rebooted.

My config is:

cover:
- platform: cover_rf_time_based
  devices:
    veneziane_soggiorno_dx_knx:
      name: "Veneziane soggiorno dx knx"
      travelling_time_up: 43
      travelling_time_down: 43
      close_script_entity_id: script.veneziane_soggiorno_dx_discesa
      stop_script_entity_id: script.veneziane_soggiorno_dx_stop
      open_script_entity_id: script.veneziane_soggiorno_dx_salita
      send_stop_at_ends: False #optional
      aliases: #optional
        - veneziane_soggiorno_dx_knx

As I reboot, KNX is not working anymore. Different error is given, but seem to be kindly random.

The most common is:

Setup failed for knx: Unable to import component: No module named 'xknx.dpt'

Do you have some ideas where I can start from? Thank you.

Delay current_position

Hello and thanks for the script.
I have a problem using Alexa and this script. I constantly receive a message in error logs:

2022-07-21 23:00:31 ERROR (MainThread) [homeassistant.components.alexa.state_report] Error when sending ChangeReport for cover.rollo_wz_b to Alexa: THROTTLING_EXCEPTION: Request could not be processed due to throttling.

2022-07-21 23:00:31 ERROR (MainThread) [homeassistant.components.alexa.state_report] Error when sending ChangeReport for cover.rollo_wz_b to Alexa: THROTTLING_EXCEPTION: Request could not be processed due to throttling.

2022-07-21 23:00:31 ERROR (MainThread) [homeassistant.components.alexa.state_report] Error when sending ChangeReport for cover.rollo_wz_b to Alexa: THROTTLING_EXCEPTION: Request could not be processed due to throttling.

2022-07-21 23:00:32 ERROR (MainThread) [homeassistant.components.alexa.state_report] Error when sending ChangeReport for cover.rollo_wz_b to Alexa: THROTTLING_EXCEPTION: Request could not be processed due to throttling.

2022-07-21 23:00:32 ERROR (MainThread) [homeassistant.components.alexa.state_report] Error when sending ChangeReport for cover.rollo_wz_b to Alexa: THROTTLING_EXCEPTION: Request could not be processed due to throttling.

2022-07-21 23:00:32 ERROR (MainThread) [homeassistant.components.alexa.state_report] Error when sending ChangeReport for cover.rollo_wz_b to Alexa: THROTTLING_EXCEPTION: Request could not be processed due to throttling.

Possibly it is because of the “live state” information as it changes position.
Could a delay be added to “current_position”? Maybe 3 seconds or more.

mqtt:
  cover:
    -   name: "MQTT Rollo Balkon"
        object_id: mqtt_rollo_wz_b
        state_topic: "schellenberg/device/value/2298"
        command_topic: "schellenberg/device/value/update/2298"
        qos: 1
        retain: true
        payload_open:  "1"
        payload_close: "2"
        payload_stop:  "0"
        state_open: "1"
        state_closed: "2"
        state_stopped: "0"
        optimistic: false

cover:
  - platform: cover_rf_time_based
    devices:
      rollo_wz_b_based:
        name: rollo_wz_b
        travelling_time_up: 24
        travelling_time_down: 24
        cover_entity_id: cover.mqtt_rollo_wz_b
        send_stop_at_ends: False #optional
        always_confident: False #optional
        device_class: shutter #optional

alexa:
  smart_home:
    filter:
        include_entities:
        - cover.rollo_wz_b

Thank you

FR Allow templates for travelling_time_up/down

The last one today. 😄

Hope it's ok to request features in the issue tracker.

It would be nice to configure the travelling settings with an input_number or other templates.
For example:

travelling_time_up: "{{ states('input_number.cover_up') }}"
  • This would make adjusting the times easier without HA restart.
  • Some of my older covers need one or two seconds more if it's realy cold outside.

Please add support for TopDown - BottomUp shades

Could you please add support for TopDown - BottomUp shades. Now the top and bottom bar sometimes collide into each other. When that happens it stops/blocks and the cover-state is no longer correct. On top of that, to undo that you have to first send and inverted command (blocked going down -> send an up command and blocked going up -> send a down command) etc.

Warnings in HA 2021.12 beta

HA Startup log:

2021-12-08 08:46:28 WARNING (MainThread) [homeassistant.helpers.entity] Entity cover.og_bad (<class 'custom_components.cover_rf_time_based.cover.CoverTimeBased'>) implements device_state_attributes. Please report it to the custom component author.
2021-12-08 08:46:28 WARNING (MainThread) [homeassistant.helpers.entity] Entity cover.og_nico_dach (<class 'custom_components.cover_rf_time_based.cover.CoverTimeBased'>) implements device_state_attributes. Please report it to the custom component author.
2021-12-08 08:46:28 WARNING (MainThread) [homeassistant.helpers.entity] Entity cover.og_schlafzimmer (<class 'custom_components.cover_rf_time_based.cover.CoverTimeBased'>) implements device_state_attributes. Please report it to the custom component author.
2021-12-08 08:46:28 WARNING (MainThread) [homeassistant.helpers.entity] Entity cover.test_cc (<class 'custom_components.cover_rf_time_based.cover.CoverTimeBased'>) implements device_state_attributes. Please report it to the custom component author.

Can't reset inconsistent position

Cover state is assumed, so sometimes the Home Assistant cover status could be inconsistent with the real situation (for instance if someone used the old RF remote instead of using HA, or if the RF receiver fails before of bad quality signal).
I didn't found a way to "reset" the position to its actual value, i.e. overriding the cover position value in HA without sending any RF signal to the cover. Is there some special parameter or service to do that? Now I have to manually call my RF script to completely open the cover and then call the cover.open_cover service to align the HA position value to the actual position of the cover: it would be much more elegant to have some cover.reset_position to do the same

What to do in cases where a command is missed?

Hi I randomly have a situation where a command is missed by a cover (window blind), not really sure what to do in this case, should I alter the script to send multiple rfraw commands to try and compensate?

Config device key is ignored

The cover gets the entity_id from the friendly name, not from the devices key.

cover:
  - platform: cover_rf_time_based
    devices:
      my_test_cover_time_based: # this should be the entity_id
        name: Test CC # the name is used for the entity_id
        travelling_time_up: 26
        travelling_time_down: 24
        send_stop_at_ends: True
        close_script_entity_id: script.cover_test_cc_close
        stop_script_entity_id: script.cover_test_cc_stop
        open_script_entity_id: script.cover_test_cc_open

Auswahl_356

Closing and opening states

Hello,

Thank you for this integration!

I have an old shutter with a remote that only has the up/down buttons and when the shutter is moving a press on either one stops it.

This works fine, unless the shutter is not moving and I use the stop button in HASS.

So I'm trying to create a script to prevent the action if the shutter is not moving, I tried based on the state of the shutter opening/closing but it seems that these states are not managed. Do you confirm?

Any idea how to solve this case? Or a useful link?

Thanks in advance.

No cover.set_cover_position after Update to newest HassOS core-2021.3.1

After the Update to newest HassOS and Integration, the cover.set_cover_position won`t work anymore for me.
After Setting the Position manually to 50, nothing happens, but the Entity says Its Done. Im Using it with custom.entity.slider.row

Setting:

service: cover.set_cover_position
target:
entity_id: cover.kuche_rollo
data:
position: 50

resulting in:

current_position: 50
travelling_time_down: 17
travelling_time_up: 18
unconfirmed_state: 'True'
friendly_name: Küche Rollo
assumed_state: true
supported_features: 15

Nothing is happing in real. Only the Cover-Buttons "up" Down" "Stop" are working right now within the UI.
The Scripts for MQTT publish to Sonoff Tasmota-Bridge are tested and working fine. No Errors in Log.
I cant`t say if it is a Problem with HA or with rf-Integration. It seems that the postions are reversed
right now: "0" is opened and "100" is closed.

Configuration.yaml

  • platform: cover_rf_time_based
    devices:
    kueche_cover_time_based:
    name: Küche Rollo
    travelling_time_up: 18
    travelling_time_down: 17
    close_script_entity_id: script.rollo_kuche_down
    stop_script_entity_id: script.rollo_kuche_stop
    open_script_entity_id: script.rollo_kuche_up

Script:

service: mqtt.publish
data:
topic: cmnd/RFBridge_Tasmota/backlog
payload: >-
RfRaw
AAB035050812DE05F0017202D02BC0481XXXXXXXXXXXXA3B2A3A3A3B2A3B2A3A3B2A3B2A3A3B2B2B2A3A3A3B2A3A3A3A3B2B2B2B2A3A55

move delay option in position calculation

My roller shutter controller have two inputs that works in two modes:

  • full open/close - I have to turn on up/down relay for 0.1 sec and there is no way to stop it
  • move up/down - after 2.5 sec up/down relay, shutter start moving until relay is off

First option can be only used when full open or close is requested. Second gives me extra 2.5sec delay that break position calculation - for example 2 x 20% UP is not the same as 1 x 40% UP.

Please consider adding delay option that can be optionally excluded from position calculation.

Position value inconsistent with Home Assistant Template Cover convention

I think merging pull request #21 may have caused some unexpected behavior. The merge flipped the meaning of position 0 from closed to open and position 100 from open to closed. The problem is that Home Assistant uses the former convention, as seen in its Template Cover documentation. If you use a Cover Time Based Component within a Template Cover, things go awry unless you manually flip the positions back to the former convention.

Great component, and thanks for all your work!

Position slider invoking the wrong script

When using the position slider, it invokes the opposite script than it should.

cover:
  - platform: cover_rf_time_based
    devices:
      study_curtains:
        name: Study curtains
        travelling_time_up: 11
        travelling_time_down: 11
        open_script_entity_id: script.curtain_study_open
        stop_script_entity_id: script.curtain_study_stop
        close_script_entity_id: script.curtain_study_close
        device_class: curtain

Scenario:

  1. Use the cover card's Open button to fully open curtain
  • current_position: 0
  • position slider showing 0%
  • scripts called per logs: Open
  • actual state: curtain is fully opened
  1. Use the cover card's Close button to start closing curtain, then when it's approx 30% closed, hit the Stop button to stop it
  • current_position: 30
  • position slider showing 30%
  • scripts called per logs: Close, Stop
  • actual state: curtain is 30% closed
  1. Use the position slider to close curtain to about 60%
  • current_position: 60
  • position slider showing 60%
  • scripts called per logs: Open, Stop (I'd expect the Close script to be called)
  • actual state: curtain is now fully open (I'd expect the curtain to be 60% closed)

Is this a config mistake on my end or is the component really invoking the wrong script?

Interrupt previous send command (script) with new one.

Hi,

I'm not sure if this is possible at all or if it is a limitation of my RF device (Broadlink RM PRO+) but I'm wondering if there could be an option to interrupt the previous script call to start the next one.

Reason/Use case:
If my blinds are closed and I want to open then very slightly, around 1%-3% for example. I notice that my broadlink will send the open command and only once that is done (once broadlink LED goes off), will it send the stop command. The issue is the stop command should have been set earlier, given the time it takes for my blinds to open completely.

Cheers!

Integration breaks built-in KNX integration

Hello,

we recently had a bug report in HA core (home-assistant/core#76604) mentioning that a very old xknx version is used to run the KNX integration. After some analysis the issue creator found out that this custom integration is using xknx==0.9.4, which is from 3 years ago as a pinned dependency.

Can you please update to the latest version of xknx or even better - get rid of it altogether.

using cover object instead of scripts/switches

Hi,

I'm having RFXTRX for Somfy RTS shutter.
RFXTRX integration create cover objects.

In order to have this custom component to work, I need to create via script the cover command open, close and stop.
Would it be possible to support also cover objects ?
It looks a little bit weird to create manual command for an already existing cover to make it working.

Thanks,
Pierre

rfxtrx:
device: /dev/ttyUSB1
devices:
# cover.bureau
xxxxxxxxxxxxxxx:

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

//script file

'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

Version Update doesn't maintain current location

Had a lot of updates recently and each time, the position of the cover is not maintained.
Normally, the position is maintained between server restarts.
Anyway to maintain the position when doing all these updates?

[Feature Request] Sunshade/Marquis mode

Hi,
As a feature request it would be nice to add Sunshade/Marquis mode which would basically reverse the directions of operation. By intuition sunshade is closed when it is rolled up and it is open when it rolls down and creates shade. Of course one can swap the RF codes but the position slider will go the wrong way

Feature Request + Questions

I was struggling to find a way to make this work using counters, but found this awesome component. So firstly, THANKS!

I have a few things:

#Feature Request

  1. Is there a way to either pass data through in the script call OR can we just call the remote service? It would save having to write a script for EVERY cover (I have a lot). Example:
      close_script_entity_id: >
        service: remote.send_command
        data:
          entity_id: remote.rmpro_remote
          command: b64:sgD0AqIzDBk

#Questions
2. I have blinds where I can set them in privacy mode when they are at 50% position. I have a separate RF signal for this, but obviously this unique use case means I can just set them at 50% value manually. It just means that I won't have the "opening" or "closing" states that I would prefer.

  1. I also have grouped blinds with a separate RF command so I can control a whole room, but creating a separate entity means their individual positions won't update.

Fully aware that question 2 and 3 are very specific to my use case, just curious if you might have some knowledge you could drop on me.

Again, amazing work as always nagyrobi!

I might be better doing my own counter and automations to address my specific needs, I'm just stumped though.

Allow sensors for close position and config item for assumed state

Hi,

Thanks for this - I'd made the tweaks to call my custom scripts and not send stop commands and then found your code, D'oh!

I was wondering if you'd consider introducing the other tweaks I'd made (happy to make a pull request):

An optional configuration for a sensor that indicates if cover is closed.

  @property
    def is_closed(self):
        """Return if the cover is closed."""
        door_sensor = self.hass.states.get(self._closed_sensor)
        return door_sensor is None or door_sensor.state == self._closed_sensor_state

I'm using this with a garage door where people will be opening / closing outside of HA controls this would help stop getting cover out of sync.

My other current tweak is to set assumed_state to False - leaving it as True means both Up and Down arrows are available e.g. when closed, which screws up underlying actions required to operate door.

Having that as an optional item defaulting to True would help - out of interest are you seeing any UI oddness like arrows being available when they shouldn't be with that set to True?

Thanks!

Using cover_rf_time_based.set_known_position-servicewhile the curtain is moving the curtain fails to stop a the target location

I set the known_position to compensate for the delay (app 1-2 secs) in sending the commands. I use the following code in the script. However the stop_script_entity_id-script is never called after using the cover_rf_time_based.set_known_position-service

      - service: cover_rf_time_based.set_known_position
        data:
          confident: false
          entity_id: cover.office
          position: "{{ starting_position_calculated }}"
          position_type: current

feature request - delay start/stop (compute the percentages separately for 3 zones)

Hi,

Thank you for your work! Much appreciated.

I've set up my rollers and they're working great, thanks.
But I would like to have a small enhancement - to have the rollers show the open percentage synced with the percentage of the height of the window (ie if they show 75% they should be about 75% of the window height).

My rollers are spending quite a lot of time (about 5-6 seconds) to unroll and start lifting up, while getting to fully open takes about 24 seconds. This is translating to show 60% open when they are only 30-35% compared with the window height.

Maybe we can split the time traveling up/down into 3 parts and calculate the percentages for each of them, something like:

0 --- 3 ----------------- 97---100
| ----- | ------------------ | ----- |
t1 t2 t3

That would make the percentages more accurate, and we can allow for different timings on each different motor.

Do you think this can be easily achieved?
Thank you very much!
Florin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.