Map cover control to a switch with two controls

Hi there

I’m trying to map my roller blinds control to use a two button switch. I know about @boelle s excellent blue print but it does not work exactly as I’d like.

The problem is that the cover service uses a three way approach

  • cover.close
  • cover.stop
  • cover.open

But a two button switch would (and the original ikea roller blind switch actually does) work as:

- Switch 1
  if (cover is not moving) 
    cover.close
  else 
    cover.stop

- switch 2
  if (cover is not moving)
    cover.open
  else
    cover.stop

So if I’m going to map this to two switches I also need to know the actual state of the cover. But I really don’t know how to get the actual state of the cover (state as in “is it moving or not”, not the current position state).

I guess it should be something like:

cover is moving = (0 < cover.state.current_position) 
                  and (cover.state.current_position < 100)
                  and (cover.state.current_position.1_second_ago != cover.state_current_position)

My problem here is: how do I get the covers position from x miliseconds ago? Or is there any other way to check if the cover is actually moving?

I’m sure somebody already solved this. But my google foo has failed me, and I’m a little lost here.

So any references on where to start would be very nice… (A reference to a blueprint would of course be the best) :smiley:

If anyone in the future have the same problem, I found a solution and created a blueprint for it.