Question on widgets

hello,
@crnjan

this not works, when .displaystate is empty he dont usw the .state, he says “undefined”

text: =Math.round(items[props.duration].state / 60) + " Minuten " + " ᛫ " +items[props.rating].displayState || items[props.rating].state

@RGroll
have you perhaps a idea why he shows me the scrollbar on the right side of the widget?

Unbenannt

my code

component: f7-card
slots:
  default:
    - component: f7-block
      config:
        class:
          - no padding
          - no margin
      slots:
        default:
          - component: f7-col
            slots:
              default:
                - component: f7-block
                  config:
                    class:
                      - no-padding
                      - no-margin
                  slots:
                    default:
                      - component: oh-image
                        config:
                          item: =props.item
                          style:
                            width: 100%
                            height: auto
                      - component: oh-image
                        config:
                          visible: =items.myKodi_mediatype.state == "movie"
                          item: =props.thumb
                          style:
                            position: absolute
                            bottom: 16px
                            width: 16%
                            height: 40%
                            left: 16px
                      - component: oh-image
                        config:
                          visible: =items.myKodi_mediatype.state == "episode"
                          item: =props.thumb
                          style:
                            position: absolute
                            bottom: 16px
                            width: 40%
                            height: 40%
                            left: 16px
                - component: f7-row
                  slots:
                    default:
                      - component: Label
                        config:
                          visible: =items.myKodi_showtitle.state !== "UNDEF"
                          text: =items[props.tvshowtitle].state
                          style:
                            font-size: 35px
                - component: f7-row
                  slots:
                    default:
                      - component: Label
                        config:
                          text: =items[props.title].state
                          style:
                            font-size: 20px
                            width: 100%
                      
                - component: f7-col
                  slots:
                    default:
                      - component: Label
                        config:
                          text: =items[props.genre].state
                          style:
                            font-size: 16px
                      - component: Label
                        config:
                          text: =Math.round(items[props.duration].state / 60)  + " Minuten   " + " ᛫ " +items[props.rating].state || items[props.rating].displayState 
                          style:
                            font-size: 16px
          - component: f7-row
            config:
              class:
                - padding-top
                - padding-bottom
            slots:
              default:
                - component: f7-col
                  slots:
                    default:
                      - component: oh-slider
                        config:
                          item: =props.progress
          - component: f7-row
            config:
              class:
                - padding-top
                - padding-bottom
            slots:
              default:
                - component: f7-col
                  slots:
                    default:
                      - component: oh-player-controls
                        config:
                          item: =props.mediacontrol```
text: =Math.round(items[props.duration].state / 60) + " Minuten " + " ᛫ " + (items[props.rating].displayState || items[props.rating].state)
1 Like

okay i found the problem.

hello,

i only get the actually position of a movie or episode in secons, i try to format it in hr:mm (Hour:Minutes).

i try it with a rule, but that is to much because the progress changes every second. Perhaps someone has a idea?



rule "progress - neues Format"
when
    Item myKodi_currenttime changed

then
    val totalSecs = (myKodi_currenttime.state as Number).intValue
	val min = (totalSecs / 60) % 60
	val hrs = (totalSecs / (60*60)) % 24
	val txt = (myKodi_currenttime)
	myKodi_currenttime_formated.postUpdate(String::format("%02d:%02d",  hrs, min))
	logWarn("formatierter fortschritt", "" +myKodi_currenttime_formated.state)		
end

If that is too much then there is something wrong with your setup. It should be able to do that calculation in milliseconds, not a second or more. So the fact that it changes every second should not be a concern.

What type is myKodi_currenttime? If you can use Number:Time then all you need to use is %1$th:%1$tM:%1$ts and it will convert the seconds to HH:MM:SS for you I think (if it can be longer than 24 hours you’ll need to add %1$td. If it can be longer than 31 days you’ll need to use a transformation.

You could also use a JavaScript transformation, but if your rule can’t keep up, the transform won’t be able to keep up either.

Hello

Its a number item with the progress of a playing Media file, fit example a movie or Episode.

IT changes every second because its the progress time.

Its from the kodi binding. See here

Number:Time myKodi_currenttime      "Current Time [%d %unit%]"  { channel="kodi:kodi:myKodi:currenttime" }

So it is a Number:Time Item. So change the label to “Current Time [%1$th:%1$tM:%1$ts]” and it should convert it for you.

1 Like

Hi,

Yes, it works. i had a mistake in the item.

I’m trying to automate the widget.

is it not possible to use a prefix on a label?

                     - component: Label
                        config:
                          visible: =items.myKodi_showtitle.state !== "UNDEF"
                          text: =[props.prefix + '_showtitle']
                          style:
                            font-size: 35px

it seems like “props.prefix” only works for one item. if i put it in a label it doesn’t show me the value in the item.

then i get “[ “myKodi_showtitle” ]”

is there another possibility? the “oh-label-card” doesn’t format everything correctly and pacts a frame around the label.

EDIT
Had it

=items[props.prefix + ‘_showtitle’].state

I am trying to create a selection button with which I can, for example, select different predefined entries.
a dropdown list.

I read in the forum that should go with “oh-link”

- component: oh-link
                  config:
                    iconF7: speaker_slash_fill
                    iconSize: 25
                    text: test
                    action: options
                    actionItem: =[props.itemMode]

But what does the item have to look like so that I can select the options and then react to them using a rule.

i just want to have a selection of tv channels and then react to the selected channel via a rule.

I already have the rule, but I have problems with the item

You will want to add the State Description metadata to your item. On the item’s page in UI, click on add metadata and select State Description from the default options. In the options box on the page you can list as many value=label pairs as you need.


And these, in turn will show up as the options list when triggered in the UI
image

1 Like