Automation that translates percentage into seconds (runtime) and remembers state

I have some awnings on my house, that I am controlling via a shelly 2pm, so one switch is extend, the other is retract.

Full extension or retraction takes 28 seconds, and I currently have automations that will extend half way (14s extend), or the whole way (28s extend), or retract (28s retract). I have these exposed to Alexa so that I can say “extend rear awning” etc.

I’d like I way for HASS to store a value for how many seconds it has currently extended/retracted, to know the position, which I think I can do with HACS extensions (storing a value in a variable), but ideally I’d like to (as I can with my lights) be able to say “set rear awning to 30%” and have it translate that to 28x0.3s runtime, assuming it’s currently fully retracted, or say, 28x0.1s runtime if it’s variable currently tells it that it’s at 20%.

Is this something that is possible?

If you converted your Shelly to ESPHome you could use this:

That’s perfect, thanks!!

Also, just found this

Having just spent the last 30 mins trying to figure out how to flash the shelly with ESPhome and finding very little on google, this might work better, thanks :slight_smile:

You either need to flash with direct wiring

or use this to get to tasmota and then to esphome