Controlling a Number:Time item with stepper component

Hi everyone,

I finally made the upgrade to openHab 3.4.2. and I’m facing a problem with some of my widgets here: after the upgrade the type of some items was changed to Number:Time. I knew about this change in general and it was easy enough to fix my rules that control these items (command is now ‘10 min‘ when it was just 10 before). However I also send commands to these items through Main UI widgets using a stepper component. Is it possible to make the stepper component also send a command in the form of ‘XX min‘ where XX stands for the user input via the stepper? Right now it only sends 10 which is not accepted as command. I haven’t checked the logs but the command is not sent to the device and the item is not changed. This makes sense since 10 is of course a very ambiguous value when speaking about time…
I know I could work around this by using a proxy item but I would prefer to control these items directly.

The Slider Widget definitely supports that through the “unit” property but setpoint does not appear to.

But I thought that changes were made in 3.4.2 where the default unit for the Item type would be added when sending a number without units. Can you show the error you see when you do that? Even then, that probably wouldn’t help because the default unit for time is seconds, not minutes.

Actually you are right as usual: I dont get an error but the stepper sets the value to ‘1 s’ instead of ‘1 min’.

However the device (I want to control a shutdown timer for a lightbulb via the miio binding) only seems to accept values from one minute and up. When I enter e.g. 10 s it resets itself to 0 immediately and just stays on, when I set it to 60 it switches itself off after a minute. What works is to increase the step size in the component to 60 with some side effects in the UI: The value shown in the stepper is shown in seconds when entered and then switches to minutes as the device reports back the shutdown time in minutes. So I guess I have to use a different component or introduce a new proxy item.

Edit: Just checked the slider documentation: If the text is right the unit is just shown in the ui when the slider is dragged. I don’t think it actually gets sent in the command.

Does this Item have a state description pattern? If not, if you set it to %d min (I’m guessing at the unit symbol for minutes) does that cause OH to interpret the value as minutes?

Note, it’s looking like we might have an overhaul in how units are managed in OH 4 where you’ll be able to set the default units per Item yourself. But that doesn’t help you in OH 3.

It had a state description pattern but a different one. I changed this and now it is working :+1:

Only downside is that I can no longer format the state the way I want it (at least on item level) but that is no big deal. Thanks for your help!