Controllerx: [FEATURE REQUEST] Fire action after a custom delay

Created on 16 Mar 2020  路  11Comments  路  Source: xaviml/controllerx

Feature Request

Is your feature request related to a problem?

When I go to bed, I'd like to have a light on for 5 mins. So I'd like to have an option in controllerx to fire the action only after a period of time has expired after the event occurred.

Describe the solution / feature you'd like

Maybe an activate_after option with its value in seconds.

Describe alternatives you've considered

An alternative could be a timer configured in HA but I somehow would prefer to configure it in one place.

Additional context

Add any other context or screenshots about the feature request here.

enhancement

Most helpful comment

It would make sense, but if you use CustomLightController that looks like:

example_app:
  module: controllerx
  class: CustomLightController
  controller: sensor.livingroom_controller_action
  integration: z2m
  light: light.livingroom
  mapping:
    toggle: toggle
    brightness_up_click: on_full_brightness
    brightness_down_click: on_min_brightness
    brightness_up_hold: on_full_brightness
    brightness_down_hold: on_min_brightness
    arrow_right_click: on_full_color_temp
    arrow_left_click: on_min_color_temp
    arrow_right_hold: on_full_color_temp
    arrow_left_hold: on_min_color_temp

Then you would need to add the delay together with the action string. Furthermore, if using the regular device controller like E1810Controller, then, there would be no way to insert the action delay since it does not have mapping:

livingroom_controller:
  module: controllerx
  class: E1810Controller
  controller: sensor.livingroom_controller_action
  integration: z2m
  light: light.bedroom

So I decided to separate actions to delays, on one side you define the actions (mapping) and in the other one the delays (action_delays).

I hope this makes sense of why I took this decision.

All 11 comments

Hi @chbndrhnns

This would be a nice feature to have! I have thought about this before and this functionality might go under custom controllers. However, I have to think how to do it. Thank you for the request! :)

Nice to hear that! It might be difficult to decide what to do if during a running timer, other events occur that are connected, like changing the hue or another on event.

Could be a nice feature 馃憤

Perhaps a visual indication that timer event has been activated should be implemented.
light flash: short call or something similar ?

Ciao !

Hi guys, I just released the latest beta v2.4.4b1 that includes this issue. I added a new attribute to the main controller called action_delay which is a dictionary where the key is the action and the value is the delay in seconds.

This is an example with the regular E1743 controller for a light, but delaying the off action for 10 seconds. The use case could be for when we have a switch at the beginning of the corridor and we do not want the light to turn off until a certain period of time.

corridor_controller:
  module: controllerx
  class: E1743Controller
  controller: sensor.corridor_controller_action
  integration: z2m
  light: light.corridor
  action_delay:
    "off": 10

If the timer is running and the action is called again, then the timer is cancelled and a new one is created. So in this example, if after 8 seconds you press the off button then it will cancelled the timer and turn off the light in 10 seconds from there. For simplicity, the timer is not cancelled when a third party change the state of the light.

Furthermore, to answer @htvekov, there is no feedback (apart from logging) that the timer is activated, if you want a flash when the timer is activated, you can add another app instance. So the first one will activate the timer and the second one will flash the light.

I invite to test it and let me know if it works well in your side as well. I will be closing this issue once it is released.

Hi' Xavi.

I'll test this new action_delay feature, when the brightness/transition debugging and testing is done.

Swithcing back/forth between 2 versions plus patches of ControllerX AND Zigbee edge/stable will probably just f#ck up a test session at some point 馃槈

Ciao !

Perfect! Thanks, @htvekov. I will not release anything until that issue is solved, so no worries.

I am mostly using the CallServiceController. What would be correct way to delay the action for event 1001, for example?

kitchen_controller:
  module: controllerx
  class: CallServiceController
  controller: switch_kitchen
  integration: deconz
  mapping: 
    1001:
      service: light.toggle
      data:
        entity_id: light.kitchen_2

Hi @chbndrhnns,

If you have the latest beta version installed, then you configuration would be like the following:

kitchen_controller:
  module: controllerx
  class: CallServiceController
  controller: switch_kitchen
  integration: deconz
  action_delay:
    1001: 10
  mapping: 
    1001:
      service: light.toggle
      data:
        entity_id: light.kitchen_2

The only thing I did was to add the action_delay attribute and marking that 1001 should have a delay of 10 seconds.

I understand. Wouldn't it make sense to have the action_delay key on the mapping level like this, as well? It seems a little less verbose to me.

kitchen_controller:
...
  mapping: 
    1001:
      service: light.toggle
      action_delay: 10
      data:
        entity_id: light.kitchen_2

It would make sense, but if you use CustomLightController that looks like:

example_app:
  module: controllerx
  class: CustomLightController
  controller: sensor.livingroom_controller_action
  integration: z2m
  light: light.livingroom
  mapping:
    toggle: toggle
    brightness_up_click: on_full_brightness
    brightness_down_click: on_min_brightness
    brightness_up_hold: on_full_brightness
    brightness_down_hold: on_min_brightness
    arrow_right_click: on_full_color_temp
    arrow_left_click: on_min_color_temp
    arrow_right_hold: on_full_color_temp
    arrow_left_hold: on_min_color_temp

Then you would need to add the delay together with the action string. Furthermore, if using the regular device controller like E1810Controller, then, there would be no way to insert the action delay since it does not have mapping:

livingroom_controller:
  module: controllerx
  class: E1810Controller
  controller: sensor.livingroom_controller_action
  integration: z2m
  light: light.bedroom

So I decided to separate actions to delays, on one side you define the actions (mapping) and in the other one the delays (action_delays).

I hope this makes sense of why I took this decision.

This will be deployed in the next stable release.

Was this page helpful?
0 / 5 - 0 ratings