Update sensor interval on Cover Blind actions with Shelly 2.5

Hello community :slight_smile:

I just set up my shelly 2.5 following this guide: Current Based Cover — ESPHome

but would like to tweak a bit to be more efficient but no way how to do it.

By default, update interval for sensor ade7953 is set to 0.5seconds. This is almost constantly checking the current and would like to reduce it to 60 seconds or similar.
However, to optimally use the “open_moving_current_threshold” and “close_moving_current_threshold”, I need this value to be updated more frequently as it was set initially to 0.5seconds.

Is there any way to update the interval TEMPORARY once button is pressed that calls “cover.open: blind” / “cover.close: blind”?

I tried to do something like this but obviously it doesn’t work :frowning:

cover:
  - platform: current_based
    name: Blind
    id: blind

    open_sensor: open_current
    open_moving_current_threshold: 0.005
    open_duration: 26s
    open_action:
      - switch.turn_on: open_relay
      - sensor.platform.ade7953.update_interval: 0.5s
    close_sensor: close_current
    close_moving_current_threshold: 0.005
    close_duration: 25s
    close_action:
      - switch.turn_on: close_relay
      - sensor.platform.ade7953.update_interval: 0.5s
    stop_action:
      - switch.turn_off: close_relay
      - switch.turn_off: open_relay
      - sensor.platform.ade7953.update_interval: 60s

This is the value I want to set on every different open, close, stop action: “sensor.platform.ade7953.update_interval” but of course this way of writing it doesn’t work.

Do anyone knows how can I do something like this or if it is possible? using global variable maybe? How?

Thank you,

I finally found the way thanks to @0x3333 in Dynamically change update_interval - #10 by 0x3333

Just the code reference here:

sensor:
  - platform: bl0939
    update_interval: 30s
    id: power_sensor

cover:
  - platform: current_based
    name: Blind
    id: blind

    open_sensor: open_current
    open_moving_current_threshold: 0.005
    open_duration: 26s
    open_action:
      - switch.turn_on: open_relay
      - lambda: !lambda |-
          id(power_sensor).set_update_interval(500);
          id(power_sensor).call_setup();
    close_sensor: close_current
    close_moving_current_threshold: 0.005
    close_duration: 25s
    close_action:
      - switch.turn_on: close_relay
      - sensor.platform.ade7953.update_interval: 0.5s
      - lambda: !lambda |-
          id(power_sensor).set_update_interval(500);
          id(power_sensor).call_setup();
    stop_action:
      - switch.turn_off: close_relay
      - switch.turn_off: open_relay
      - lambda: !lambda |-
          id(power_sensor).set_update_interval(30000);
          id(power_sensor).call_setup();

lambda function did the trick :slight_smile:

Thank you,