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 ?
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.
rule Scale
when
Item SolarIntensity changed
then
SolarIntensityScaled.sendCommand((SolarInt.state as Number) * 100)
logInfo("TEST", SolarIntensityScaled.state.toString)
end