Ikea blinds, input_number and an issue with delay

Hey,

I got the new IKEA blinds and sucessfully paired them with deconz. I’ve set up a template sensor that shows the current state of openess of the blind (0-100%) called sensor.rollo_schlafzimmer_open_percent.
I have also set up an input_number (slider) that can be used to control the blinds called input_number.rollo_schlafzimmer.

Now I want to make this slider bidirectional e.g. when I use the blinds remote and put the blind into a new state the slider should adapt this value. The blinds take roughly 17 seconds to completly open or close. My plan is to monitor the value of my template sensor and when the value has not changed for 20 seconds the slider should be updated with the last value of the template sensor. Here is what I got so far. I have placed the delay as first action but for some reason it is ignored by the automation causing trouble with the automation to set the blind when the slider is updated:

- alias: Rollo Schlafzimmer Set Slider
  initial_state: True
  trigger:
    - platform: state
      entity_id: sensor.rollo_schlafzimmer_open_percent
  action:
    - delay: '00:20:00' #WHY IS THIS DELAY IGNORED?
    - service: input_number.set_value
      data_template:
        entity_id: input_number.rollo_schlafzimmer
        value: "{{ states('sensor.rollo_schlafzimmer_open_percent') | int }}"

Anyone has a solution?

Delays and wait states are cancelled when the automation re-triggers.

1 Like

Well, that explains a lot. What would be the correct way to watch the template sensor not having changed for 20 seconds? A template trigger? :thinking:

Maybe you could try (I haven’t tried, so not sure if it will work)

- alias: Rollo Schlafzimmer Set Slider
  initial_state: True
  trigger:
    - platform: state
      entity_id: sensor.rollo_schlafzimmer_open_percent
      for: "00:00:20"
  action:
    - service: input_number.set_value
      data_template:
        entity_id: input_number.rollo_schlafzimmer
        value: "{{ states('sensor.rollo_schlafzimmer_open_percent') | int }}"
1 Like

As far as I know you need a defined state like on or off if you want to use for as trigger or condition. I’ill give it a try.

No, I believe Coninoxx is correct. (Unfortunately he wasn’t, see below) :sob:
It changes, so it starts, (at whatever value) it waits for 20 seconds, if it changes again the wait is cancelled and the new state value fires it again, wait 20 seconds…

It deviously complies with what I know of the rules,
Me Likey :heart_eyes:

As I expected. Only a given state can be observed when using for:

Invalid config for [automation]: dependency violation - key "for" requires key "to" to exist @ data['trigger'][0]. Got None.

Okay, well that would have been the nice and quick way of doing it :grimacing:

What you’ll have to do is create a binary sensor that returns true when now() - .last_changed (of your other sensor) is greater than 20 secs
Not at my workstation at the mo so you’ll have to do some research :roll_eyes:

That would be a nice way of solving the problem. Great idea.

Try : -

{{ (as_timestamp(now()) - as_timestamp(states.sensor.rollo_schlafzimmer_open_percent.last_changed)) > 20 }}

Again, I’m still on my phone … so …

Edit: Microsoft decided to upgrade my laptop this morning, this is after my main workstation had a motherboard failure 2 days before. Once it’s back up I’m really going to concentrate on an Ubuntu workstation.
As a result I have had a couple of edits of the above and I’m still unable to test it.

Edit2: tested it, it works ! :man_superhero:

What am I doin wrong? It is always showing an off state.

- platform: template
  sensors:
    rollo_stopped:
      friendly_name: "Rollo Stilstand"
      value_template: '{{ (as_timestamp(now()) - as_timestamp(states.sensor.rollo_schlafzimmer_open_percent.last_changed)) > 20 }}'

What section are you putting this.?
It needs to go under binary_sensor:
If you put the template I gave you into the template editor … Wait no !
Put this in instead : -

'{{ (as_timestamp(now()) - as_timestamp(states.sensor.rollo_schlafzimmer_open_percent.last_changed)) }}' 

This will give you the number of seconds since the last change.
So get a value, move the blind (or change it to another entity if that’s easier) and then update the editor (add a space then backspace over it) you should see the number change.
Then add the > 20 back in and it will go from false to true 20 secs after the change.

You then trigger your automation on the state change of this binary sensor going to true.

Edit: can anyone else test just to see if I’ve missed a bracket or something ?

jones, I use packages but your definition of a binary sensor should look something like this : -

binary_sensor:
  - platform: template
    sensors:
      bs_occupied_mutt:
        entity_id: device_tracker.life360_muttley, input_boolean.ib_occupied_mutt_away
        value_template: "{{ is_state('device_tracker.life360_muttley', 'home') and is_state('input_boolean.ib_occupied_mutt_away', 'off') }}"
        friendly_name: Mutt At Home

I picked one that was a single line template (needs quotes) rather than a multiline template (that doesn’t)

I then picked two entities that exist on my system that I could easily change, I’ll leave alone and the other I’ll change, image, wait and image again. I’ll set the offset to 2 mins as I have to take screen images and save them. Note how the result flips around on the 120 second period.

and the changed : -