Run automation when value IS NOT actively changing (current_cover_position)

So all, I’ve run into something interesting.

I have Ikea smart blinds, and a Zooz ZEN32 scene controller.

I am simply trying to achieve this: Pressing button 2 toggles my shades up and down (that is working)
What I want next is to get the LED on button 2 to change color ONLY WHILE the shades are moving.

So if I press the button and my shades are up, they will go down, light changes to blue while shades are in motion, and THEN changes back to white once motion stops.

Unfortunately it seems that the Ikea blinds don’t report is_opening or is_closing, which would be the obvious way to do this.

So the question is this, using the platform property current_cover_position, is there a way to write an expression or something that essentially will let me change the LED color back to white only when “current_cover_position” is not actively changing? If that number is actively changing, then that means the LED should be blue, if it’s not actively changing, it should be white.

Thanks for any help!

You might use the last_updated info of the blind?
Something like

  - condition: template
    value_template: >-
      {{ ( now()|as_timestamp() - states['sensor.someblind'].last_updated | default(0,true) | as_timestamp() | default(0,true)) > 5 }}

That will be true if it is more than 5 seconds that the blind state did not change.

EDIT: The template is evaluated only once per minute. I guess it is ok if your light is on for the remaining of the minute, right?

Thanks for the advice, to answer your question, it doesn’t really matter at all, I just thought this would be a cool thing to have the light indicate current movement, but I would rather not have it where the light just stays on for the remainder of the minute, if that was the case I could just put a 15-20s delay on the action that makes it blue to put it back to white.

It’s possible this might not be do-able, or that the solution would be very creative to have it work how I want, which to clarify is:

Button White - Blinds whatever position they’re in
Press button once - Blinds toggle, button blue while moving
button white once movement stops.

Basically, your blind is moving by itself as soon as you press the button right?
It will then stop at the maximum (or minimum) position, right x2?
Then, can’t you use the value of the current_cover_position as trigger?

  - platform: template
    value_template: >-
        (state_attr('sensor.someblind','current_cover_position') | default(0) = minvalue) or
        (state_attr('sensor.someblind','current_cover_position') | default(0) = maxvalue)

EDIT: Or, by any chance, any other attribute like ‘moving’, ‘running’, ‘stopped’ ?

I think that “is_closing” and “is_opening” are supposed to be what is built in to the blinds to report that they are moving, but it appears the ikea blinds just report open, closed, and their position as a numerical value, no other attributes.

Also, it will not necessarily stop at a max or min value, for example, say it’s 70% open and I close it to 40% open with my phone. The LED should be white to start, and then blue while moving from 70 to 40, and then back to white to indicate movement is complete.

I am just not sure if there is a way to define the position such that it is not something specific, but if it is changing at all, then I want something to happen, and then when it is done changing, something else happens.

My apologies if I’m being repetitive. I appreciate the help and realize without the blinds reporting the fact that they’re moving that this might not be possible.

Never giving up :slight_smile:
I’m thinking of something else.

  1. Create an input_number and an input_boolean
  2. Create an automation triggered by current_cover_position changing, only actions are update the input_number with the current value of the current_cover_position and set input_boolean to true (representing the blind moving)
  3. Create another automation, running on time_pattern second /1 (every second) and conditionned by the input_boolean = true which will compare the input_number with the current attribute current_cover_position.
    → different, do nothing, still moving
    → the same, it has stopped, set input_boolean to false, blind is not moving anymore (turn light to white)

To fine tune, maybe 1 second is not enough to detect the movement

Amazing! I must admit I don’t have experience with this kind of programming, but I am going to see if i can figure it out, mainly the part about creating time_pattern, etc.

Alright, I’ve got the input_boolean working, but for the number, I can’t figure out how to set it.

This isn’t working:

service: input_number.set_value
  entity_id: input_number.scottshade
  value: "{{ states('cover.bed_blinds.current_position') }}"

I’ve tried

value: "{{ states('cover.bed_blinds')}}"

In the template editor in dev tools. That works and returns “open”

When I do value: “{{ states(‘cover.bed_blinds.current_position’)}}” or current_cover_position, the value just returns as unknown, so I’m kind of stuck. Is it not a state?

Ok, got that, it’s "{{ state_attr('cover.bed_blinds', 'current_position')}}"

Now my issue is the next part where you do the time_pattern automation.

  1. I can’t seem to condition the trigger based on input _boolean being yes or no, so it just runs every second.

  2. I don’t know how to make it compare the numbers.

  1. Yes, it will start every second, but you’ll put a condition based on the boolean
  - condition: state
    entity_id: input_boolean.blindmoving
    state: true
  enabled: true
  1. With a template condition, like this:
- if:
  - condition: template
    value_template: "{{ state_attr('cover.bed_blinds', 'current_position') != states('input_number.blindposition') }}"
  - ...
  - ...

EDIT: if you are concerned with performances, increase the /1 to /2 or more

Did you achieve your objective?

Not yet, I don’t want to have an automation that just runs every second of every minute of every day lol.

It will not run, it will check every second (you can change to 2, 3 or 5) if the boolean is false and then stop.
This should not alter performances. At least you can test.
You can also add another automation that disable that automation based on criteria like night time, sun elevation, home presence, stuffs like that.
If the sun is lower than blabla, it is highly probable that you’ll not change the blind position. Or if nobody is home, or between midnight and 5 o’clock. You get the idea.