Keeping track of input slider direction for window opener

Hi, I am planning to use the slider component to move a 12v chain drive window opener to open a window to various stop points. This will be done by calculating the amount of time that the motor is allowed to stay on, with perhaps 4 pre-set positions starting at zero (window closed), then stops implemented at 25, 50, and 100% (fully open). It seems to me I will need to know what the previous setting was, in order to make it move in the correct direction. Is there a way to store the state of the slider? Once it has been moved to trigger an automation, I’m pretty sure I need to know which way it was moved.

Hi @logman, just an idea, don’t know if this works.
Maybe multiple automations with triggers from the slider:

from: 0
to: 25

from: 25
to: 50

from: 50
to: 25

Hello @VDRainer, thanks for that, I did not realize there was any syntax like that as the input_slider page does not seem to show it.

So the automation would look something like this?

input_slider:
  window_opener1:
    name: 'Window Opener1'
    icon: mdi:window-closed
    min: 0
    max: 100
    step: 25
    initial: 0

automation:

  - alias: 'Test Window Opener1'
    trigger:
      platform: state
      entity_id: input_slider. window_opener1
      state: 'on'
    action:
      service: mqtt.publish
      data_template:
        topic: "setWindow1"
        retain: true
          from: 0
          to: 25
            payload: '{{ states.input_slider.window_opener1.state | int }}'
            run_script.A
          from: 25
          to: 0
            payload: '{{ states.input_slider.window_opener1.state | int }}'
            run_script.B            

As i said, don`t know, give it a try.

Edit:
I mean:

automation:
  - alias: 'Test Window Opener1'
    trigger:
      platform: state
      entity_id: input_slider.window_opener1
      from: '0'
      to: '25'

Hello @VDRainer, it’s a no go, unfortunately, but I’m wondering if you have seen the ‘from’ and ‘to’ syntax used elsewhere? I can’t seem to find any reference …

Hi, I finally found the correct syntax, here’s the example:

'Volume has gone from {{ trigger.from_state.state }} to {{ trigger.to_state.state }} ’

I found it here:

I put a fully operational script in this entry for window blinds, which uses essentially the same script as window openers:

Thanks for the tip, it helped me to make all this work!

Cheers