Noob question about Rollershutter state / Percent with Sonoff / mqtt

Ok I’m sorry if the question is stupid but i admit to be a noob, and it’s been a long time since my exams in java.

I understand that Rollershutter uses PercentType , but how to determine it’s length?
I mean: until now i used a simple rule, a timer to fully open or close the shutters (they takes 25seconds), and i thought it could be useful to store their state during the movement and using that timer but i can’t figure out how.

I wanted to understand this concept to add the correct icon in sitemap showing if they are closed or open, to have the ability to open them X percent and to easily understand their position.

I use a 4channel Sonoff to move them (1 channel UP, 1 DOWN, and i have 2 shutters) with mqtt.

Many thanks in advance!
I feel a little sorry to ask for help for basic things but i did not find a solution in the community that fits my needs.
Again, thanks!

What sonoff code do you use?

The easiest way will be to get the sonoff to send the state to OH.
You can fire an MQTT message from the sonoff every % or 2% according to a timer in the code. and don’t forget to reset the state in the sonoff to 0 or 100 when fully up or down or the state will drift over time

many thanks for the reply @vzorglub.
I’m using Tasmota, i like it more than espeasy.

Sorry for another noob question but i can’t read mqtt state in openhab Rules, because Tasmota outputs
{“POWER”:“ON”} , {“POWER”:“OFF”} , ecc, and till now i still haven’t figured out how to manage those { to be read or converted to string, i always have syntax errors.
Couldn’t even map them (i tried {“POWER”:“ON”} = POWERON and many other combinations with brackets but nothing worked).

Btw, These days i’ll work on the solution you suggested, thanks!

You need to use the JSONPATH transform i your inbound mqtt binding
JSONPATH($.POWER) in your case

Yes @vzorglub! thanks to your help i easily manged to read mqtt state (i read the docs and saw how many things i missed, lack of basis!)
Now i’m working on the first problem, but i just wanted to thank you.
I’ll post the progress / result