Using oh-icon state

Hello,

is there a tutorial how to use the different states of the oh icons in a widget?

I understood that tI need to use this component

but how to use the state option correctly??

Example a poweroutlet:

component: oh-icon
            config:
              icon: poweroutlet
              width: 80px
              height: 80px

and how to show now the on or off state of this icon in a widget?

I tried this

- component: oh-icon
            config:
              icon: poweroutlet
              width: 80px
              height: 80px
              state: "=(items.Z_way_switch_WallPlug3.state === 'ON') ? True : False"
              style:
                opacity: 40%
                position: absolute
                right: 16px
                top: 120px

But this not show the correct behaviour… any help ? @rlkoshak

True and False are not not item states. You don’t need the whole ternary expression you just need to return the state of the item:

state: =items.Z_way_switch_WallPlug3.state

Image 1 show wallplug on (grren dot is there)

Image 2 show wallplug off (grren dot is also there)

here my code

- component: oh-icon
            config:
              height: 80px
              icon: poweroutlet
              state: =items.Z_way_switch_WallPlug3.state
              style:
                opacity: 40%
                position: absolute
                right: 16px
                top: 120px
              width: 80px

In that case you need to double check both the name of this item to make it is correctly spelled and capitalized and the actual type of the item to make sure that it is a Switch item sending the correct states. The configuration of the component and the syntax of the state expression are both correct. If you are not getting the correct behavior then your item is not returning the correct values.

Open the developer tools panel by pressing alt + shift + d, press the third icon in the button bar to go to the expression tester and paste your expression (=items.Z_way_switch_WallPlug3.state) there. If result doesn’t show ON or OFF then something is wrong with your item.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.