Integer
(Mike P)
January 22, 2021, 2:54pm
1
I’m currently migrate to OH3. First of all, I’m really excited, it’s a huge step forward!
Now I have a question regarding the stepper-card.
I have a number item that stores the time in minutes when the irrigation should start.
In the sitemap it looks like this:
Setpoint item=WateringAutomatic_Start label="Start der Bewässerung [JS(numberToClock.js):%s]" icon="myclock" minValue=0 maxValue=1425 step=2
I’ve tried the same in OH3:
How can I show the transformed string inside the stepper?
State description looks like this:
numberToClock.js:
(function(i) {
var hours = Math.floor(i / 60);
var minutes = i % 60;
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
return hours + ":" + minutes + " Uhr";
})(input)
Javascript transformation is working, because when I use the label-card, it looks correct:
Thank you very much for your help!
1 Like
rlkoshak
(Rich Koshak)
January 22, 2021, 5:26pm
2
What’s the default standalone widget configuration?
Integer
(Mike P)
January 22, 2021, 5:48pm
3
Ah sorry, I forgot. It’s a simple stepper-card:
value: oh-stepper-card
config:
step: 15
min: 0
max: 1425
rlkoshak
(Rich Koshak)
January 22, 2021, 6:50pm
4
Is there any option in UI form to change the label or something like that? I’ve never used a stepper card but I would expect there to be an option to set how the middle number is displayed. In that field you’d want to enter something like =items.MyItemName.displayState
.
arjan-io
(Arjan)
September 16, 2021, 7:46am
5
@Integer Did you even succeed? I need kind of the same approach
arjan-io
(Arjan)
September 21, 2021, 7:12pm
6
Unfortunately, this does not seem to work. I tried changing it to a f7-stepper
and then I was able to modify values to displayState
(although I used the option-field in the meta state descriptor, same effect though). However, then my buttons didn’t work anymore…
andreapier
(Andrea Pierangeli)
February 8, 2022, 9:56am
7
It would be great if this was supported.
I have the exact same issue.
K4thv4d1
(K4thv4d1)
February 14, 2024, 1:41pm
8
Integer:
formed string insid
Hi, did you managed to solve this please ?
Integer
(Mike P)
February 14, 2024, 3:45pm
9
Yes, I made a new widget which looks like this:
Here is the widget code:
uid: Time_Stepper_Item
tags: []
props:
parameters:
- description: A text prop
label: Title
name: title
required: false
type: TEXT
- description: A text prop
label: Subtitle
name: subtitle
required: false
type: TEXT
- description: "only f7, without f7:"
label: icon
name: icon
required: false
type: TEXT
- description: MAX Value must be devidable by STEP value
label: STEP Value in minutes
name: steper
required: true
- context: item
description: An item to control
label: Item
name: item
required: false
type: TEXT
parameterGroups: []
timestamp: Aug 1, 2021, 9:44:58 PM
component: f7-list-item
config:
mediaItem: true
mediaList: true
f7-icon: =props.icon
slots:
inner:
- component: f7-block
config:
style:
flex-direction: row
display: flex
padding: 0px
margin: 0px
class:
- align-items-center
slots:
default:
- component: f7-icon
config:
f7: clock
size: 32px
- component: Label
config:
text: =props.title
style:
padding-left: 10px
- component: f7-block
config:
style:
flex-direction: row
display: flex
padding: 0px
margin: 0px
right: 0px
position: absolute
class:
- align-items-center
slots:
default:
- component: Label
config:
text: =items[props.item].displayState || items[props.item].state
style:
padding-right: 15px
color: gray
font-size: 13px
- component: oh-stepper
config:
min: 0
max: 1440
step: =Number(props.steper)
buttonsOnly: true
autorepeat: true
autorepeatDynamic: true
small: true
item: =props.item
K4thv4d1
(K4thv4d1)
February 15, 2024, 7:42am
10
Thank you although when I use it, it still shows number instead of time, but will try to figure it out.
many thanks !
Integer
(Mike P)
February 27, 2024, 9:09am
11
Have you also made the state description described in my first post? with the javascript transformation?
Integer:
State description looks like this:
numberToClock.js:
(function(i) {
var hours = Math.floor(i / 60);
var minutes = i % 60;
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
return hours + ":" + minutes + " Uhr";
})(input)
K4thv4d1
(K4thv4d1)
March 4, 2024, 3:00pm
12
That’s what I missed ! thanks very much