[SOLVED] Howto scale an item for display on Chart

Hi All,

I have a Number form a solar sensor that I would like to scale by 100 before displaying it on a chart.
I presume I can use a Rule to do this, but I am having trouble with the syntax …

my first attemp is:

rule Scale
when
Item SolarIntensity changed
then
var int SolarInt = (SolarIntensity * 100).intValue
SolarIntensityScaled.sendCommand(SolarInt.toString)
end

ITem involved is:

Number SolarIntensity “Solar Intensity [%s W/m2]” (Sensors) {mqtt="<[mosquitto:/Garden/Aeroponics/SolarIntensity:state:default]"}

Where SolarIntensity is a “Number” Item above with the raw value, I want the result to be in SolarIntensityScaled and for that to be used in the chart.

Do I have to define SolarIntensityScaled as an Item as well ?

Any help appreciated

Yes, use an Item for your SolarIntensityScaled. You can persist this item for display on a chart.
I suggest to use a number type and also suggest to postupdate a number not a string.

Yes

Number SolarIntensityScaled

rule:

rule Scale
when
    Item SolarIntensity changed
then
    SolarIntensityScaled.sendCommand((SolarInt.state as Number) * 100)
end

@vzorglub

Do you mean:

SolarIntensityScaled.sendCommand((SolarIntensity.state as Number) * 100)

i.e without the extra variable I showed?

Cheers

Yes

Many thanks … :grinning:

@vzorglub

Hmm, doesn’t seem to work, in my Sitemap I have:

Text item=SolarIntensityScaled label=“Solar Intensity” icon=“solarplant”

and all I get is blank on thescreen where the number should be …

rule Scale
when
    Item SolarIntensity changed
then
    SolarIntensityScaled.sendCommand((SolarInt.state as Number) * 100)
    logInfo("TEST", SolarIntensityScaled.state.toString)
end

What do the log openhab.log show?

All good … it works, just had not referenced the correct name …

Many thanks :slight_smile:

Coolio, please mark the thread as solved
hc_292

Done …