I am an absolute beginner as far as openHAB is concerned.
Since I have a Nas, the Docker installation offered itself. So far I have been able to build or solve quite a few things. The start was a bit difficult, but you always learn something new.
What I canât get right though, even after searching for a while, is my configuration for a slider.
I have connected a Tuya switch, and included it under Pages. The slider (configured as a dimmer) sets a countdown, which then turns off the light at 0. That works so far.
But the number on the right side of the slider bothers me. This is displayed in seconds (6h = 21600seconds). If I now manage to format the slider in hh:mm:ss, I have the problem that the time does not arrive on the MQTT broker. Nothing seems to be transmitted.
I have created a second item *_Timer and configured it with Date:Time so that the patterns for the formatting work.
I am facing a puzzle how to teach the slider a conversion that is done in hh:mm:ss and sends to MQTT the corresponding seconds. With Type Number or Number:Time it definitely doesnât work.
How did you do this? Through the state description Item metadata?
I recommend using a Number:Time Item instead of a Dimmer. Then you can use a state description pattern of %1$tH:%1$tM:%1$tS to format the seconds to hours, minutes, seconds (Number:Time supports the same formatting as DateTime). I think the slider will pick that up.
Youâll have to elaborate. Doesnât work how? Logs?
It should work for up to 31 days, right? At least for the formatting. As I understand it, it basically adds the seconds to epoch 0 so the formatting should work until you get to the equivalent of Feb 1, 1970.
Youâve got to hope the slider widget ignores it, maybe it does, and instead finds some sensible unit to use, maybe it does that too. The problem I foresee revolves around the Itemâs default unit, as defined by âpatternâ metadata. A datetime formatter isnât a sensible default unit, so what will it use instead? Could be seconds I suppose.
Thereâs more to âget away withâ when commands are involved, rather than just display.
Switch - 6 - Countdown
is configured with 21600 seconds (6h). This one converts the whole thing and counts.
Itemtype: Number:Time
Of course the following was also implemented here
Item Metadata: stateDescription
value: " "
config:
max: â21600â
min: "0
pattern: â%1$tH:%1$tM:%1$tSâ
step: â1â
MQTT gets the number under command and counts down in state
âź2
state = 20500
command = 21600
output shows seconds and no timeformat
Switch - 6 - Test
Everything identical to Switch - 6 - Countdown
Only one thoing is changed
Itemtype: Number:Time to Itemtype: DateTime
and there you see, that the format is correct. but⌠no function with the slider.
The logs seem to send date values and not the numbers
2022-11-29 17:45:04.324 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' received command 12857
2022-11-29 17:45:04.325 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TuyaMQTT_tuyaSwitch6countdown' predicted to become 12857
2022-11-29 17:45:04.328 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 11170 to 12857
2022-11-29 17:45:04.465 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T03:06:10.000+0000 to 1970-01-01T03:34:17.000+0000
2022-11-29 17:45:04.533 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' received command 14400
2022-11-29 17:45:04.535 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TuyaMQTT_tuyaSwitch6countdown' predicted to become 14400
2022-11-29 17:45:04.539 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 12857 to 14400
2022-11-29 17:45:04.679 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T03:34:17.000+0000 to 1970-01-01T04:00:00.000+0000
2022-11-29 17:45:07.738 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' received command 7200
2022-11-29 17:45:07.740 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TuyaMQTT_tuyaSwitch6countdown' predicted to become 7200
2022-11-29 17:45:07.744 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 14400 to 7200
2022-11-29 17:45:07.895 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T04:00:00.000+0000 to 1970-01-01T02:00:00.000+0000
2022-11-29 17:45:07.953 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' received command 4114
2022-11-29 17:45:07.955 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TuyaMQTT_tuyaSwitch6countdown' predicted to become 4114
2022-11-29 17:45:07.959 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 7200 to 4114
2022-11-29 17:45:08.116 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T02:00:00.000+0000 to 1970-01-01T01:08:34.000+0000
2022-11-29 17:45:09.722 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' received command 12343
2022-11-29 17:45:09.727 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TuyaMQTT_tuyaSwitch6countdown' predicted to become 12343
2022-11-29 17:45:09.738 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 4114 to 12343
2022-11-29 17:45:09.898 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T01:08:34.000+0000 to 1970-01-01T03:25:43.000+0000
2022-11-29 17:45:09.925 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' received command 19029
2022-11-29 17:45:09.927 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TuyaMQTT_tuyaSwitch6countdown' predicted to become 19029
2022-11-29 17:45:09.933 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 12343 to 19029
2022-11-29 17:45:10.078 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T03:25:43.000+0000 to 1970-01-01T05:17:09.000+0000
2022-11-29 17:45:10.132 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' received command 21600
2022-11-29 17:45:10.133 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TuyaMQTT_tuyaSwitch6countdown' predicted to become 21600
2022-11-29 17:45:10.137 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 19029 to 21600
2022-11-29 17:45:10.278 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T05:17:09.000+0000 to 1970-01-01T06:00:00.000+0000
2022-11-29 17:45:15.826 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T06:00:00.000+0000 to 1970-01-01T05:59:55.000+0000
2022-11-29 17:45:15.828 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 21600 to 21595
2022-11-29 17:45:20.825 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T05:59:55.000+0000 to 1970-01-01T05:59:50.000+0000
2022-11-29 17:45:20.828 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 21595 to 21590
2022-11-29 17:45:25.830 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T05:59:50.000+0000 to 1970-01-01T05:59:45.000+0000
2022-11-29 17:45:25.831 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 21590 to 21585
2022-11-29 17:45:30.826 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T05:59:45.000+0000 to 1970-01-01T05:59:40.000+0000
2022-11-29 17:45:30.826 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 21585 to 21580
MQTT can not work with changed from 1970-01-01T05:59:45.000+0000 to 1970-01-01T05:59:40.000+0000 that is clear
With the Itemtype countdown I somehow donât get along, what this can / should do at all
Based on the new changes recently merged it should use the default unit (there is a default now) which would be s. But I donât know for sure if the state description would interfere with that.
The date time formatter actually doesnât define a unit so my hope would be it doesnât see a unit and uses the default one.
Well, of course, because itâs a DateTime Item. Itâs not a number. Iâm a little surprised it sends anything at all.
Which Slider widget are you using here. oh-slider-card?
I think you can define a label property with a value along the lines of label: =items[NameOfItem].displayState and for the Number:Time example it will use the state description formatted state for the label instead of the state that it appears to be using here.
You might need to do this through the YAMl on the code tab though. Not all possible properties, particularly inherited properties, are shown in the UI form when configuring a widget.
If that means that you want a plain-number command to your openHAB Item for forwarding over MQTT, just do that.
Use a Number tpe Item, set up your slider with the limits that you want.
That leaves just the numeric display, which you can format using a little JS transformation, by specifying that in âpatternâ and having the widget use displayState.
fact is here: functional slider with seconds only sends the the command right.
changed Date from to Date
received command number (in seconds),
predicted to become number (in seconds)
2022-11-29 17:45:10.132 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' received command 21600
2022-11-29 17:45:10.133 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TuyaMQTT_tuyaSwitch6countdown' predicted to become 21600
2022-11-29 17:45:10.137 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown' changed from 19029 to 21600
the timer slider, in DateTime format have only
changed Datum from to Datum
changed from number (in seconds) to number
2022-11-29 17:45:30.826 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TuyaMQTT_tuyaSwitch6countdown_Time' changed from 1970-01-01T05:59:45.000+0000 to 1970-01-01T05:59:40.000+0000
A DateTime Item is never going to work as you want with the slider and the MQTT binding. So thereâs no point messing with that any further. A DateTime isnât a number and doesnât act like a number. Itâs only ever going to work how you want with a Number.
An infinity is contained in those three words. Silently fails? Shows and error? If so whatâs the error?
Itâs a part of oh-slider-item (which is an important distinction because there are differences between oh-slider, oh-slider-card and oh-slider-item. But Iâm not positive that label is the right property name.
And truth be told, it works as expected for me by default anyway.
value: oh-slider-item
config:
max: 21600
min: 0
title: Test using Number:Seconds
step: 1
subtitle: Subtitle
And the commands received by the Item when I use the slider:
2022-11-29 13:19:55.713 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TestNumber' received command 7242 â
2022-11-29 13:19:55.715 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TestNumber' changed from 6981 s to 7242 s
Note: the item widgets are not expected to appear alone on a Page. They are shown inside an oh-list-card widget. You donât show the fill config but perhaps if you are putting these on a page by themselves that could be a problem.
It also might be working differently for me because Iâm on the snapshots and there have been some changes made relevant to this which I might have and you might not have.
Youâll notice that the command is actually just a plain old number but when the change is processed, the default units are added automatically.
I took the hint and updated the system to 3.4.0.M5.
here one has, as far as the UX and content of the slider, made adjustments that now a) take over the patterns and b) I can also insert blank text there, which then overwrites everything. from therefore first good.
pity are but here 2 things.
the scale remains at seconds (here in the example the numerical value is seconds which would be 21600s at 6h). unfortunately you canât use the scale with that. who wants to convert
if I want to convert seconds into minutes (input in minutes or hours), then I convert the seconds over steps. (e.g. 1min corresponds then step:60). one sees, how the count-down counts down, but with 30sec. then stops, is finished, but no switching condition further carries out.
must look how I can look here the log accordingly me times.
You can add tick marks and adjust the slider steps. For example, you could set the step to 60, scaleSteps to 3600 and scaleSubSteps to 60 and the slider will advance based on minutes instead of seconds and the tick marks will help orient you.
Ultimately, this is why one rarely sees sliders being used in relation to time. Itâs just not a very good user experience. Thereâs always something.
I donât understand what you are explaining here.