Transformation scale work but icon doesn't change

Why doesn’t change Icon of Grid_Power item ?


grid.scale

[..0.000]=0
]0.001..]=1

file.items

Number Grid_Power "Grid Power [SCALE(grid.scale): %s]"     <energygrid>   { channel="fronius:powerinverter:mybridge:myinverter:powerflowchannelpgrid" }

icons

icons_2020-04-1420-11-56

Regards.
Lorenzo

Dynamic icons are always selected based on actual Item state. Any transform you do for display is irrelevant.

ok understood, but how can i set an icon for negative value ?

You can’t. Dynamic numeric icons only support values 0 to 100 and the “everything else” default option.

Bit more detail

Potentially, you could copy your negative number to a positive “shadow” Item, and use sitemap visibility= feature to switch display lines between “real” and “shadow” Item - with a different set of icons - switching based on negative or positive value of “real” Item
https://www.openhab.org/docs/configuration/sitemaps.html#visibility

1 Like

It should be solved, tested only then case… tomorrow morning will confirm.

file.items

Number Grid_Power "Grid Power  [%.2f W]"     <energygrid>   { channel="fronius:powerinverter:mybridge:myinverter:powerflowchannelpgrid" }
Number Load_Power "Load Power [%.2f W]"                     { channel="fronius:powerinverter:mybridge:myinverter:powerflowchannelpload" }
Number Battery_Power "Battery Power [%.2f W]" <battery>     { channel="fronius:powerinverter:mybridge:myinverter:powerflowchannelpakku" }
Number Gpower_Out "Grid Power Out [%.2f W]"      <energygridout>   { channel="" }
Number Gpower_In  "Grid Power In  [%.2f W]"      <energygridin>    { channel="" }

file.rules

rule "Grid Power icon"
when 
    Item Grid_Power received update
then
    val strGP = Grid_Power.state as DecimalType
    val float gpFloat = strGP.floatValue
    //logInfo("grid power rules", "gpFloat : " + gpFloat + " W")
    if ( gpFloat > 0 ) {
        Gpower_Out.sendCommand(0)
        Gpower_In.sendCommand(Grid_Power.state)
    }
    else{
        Gpower_In.sendCommand(0)
        Gpower_Out.sendCommand(Grid_Power.state)
    }
end  

file.sitemaps

    Frame label="FTV" {
    	Text item=Day_Energy
    	Text item=AC_Powery
    	Text item=FAC icon="freq"
    	Text item=IAC icon="currentac"
    	Text item=IDC icon="currentdc"
    	Text item=UAC icon="voltac"
    	Text item=UDC icon="voltdc"
        //Text item=Grid_Power
    	Text item=Gpower_Out visibility=[Gpower_In==0]
        Text item=Gpower_In visibility=[Gpower_Out==0]
    	Text item=Load_Power
    	Text item=Battery_Power
    	Text item=Year_Energy
     	Text item=Total_Energy
    }

Where did you get that syntax from? To define an Item with no channel, just leave out the optional { } section.

Number Gpower_Out "Grid Power Out [%.2f W]" <energygridout>

I think in your rule, you’d want to get the absolute (“positive”) value of your number if it is negative?

Fortunately works as expected.

i tried as below, but sitemap was not rebuilt correctly.

Number Gpower_Out “Grid Power Out [%.2f W]” { }

Nope, i just wanted set different icons.

Many Thanks

Lorenzo

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