Trying to make a simple change to a premade community DTH named SmartWeather Station Tile 2.0 (thank you @takissd). Whoever knows Groovy, please help. I am not a programmer and it is driving me batty trying to make this simple change.
To summarize, this DTH currently gives a very loose estimate of lux based on the weather conditions. Sunny = 10000 lux, cloudy = 1000 lux etc. I want to change it so that Lux populates instead as a function of Solar Radiation which is a defined Attribute in the data set.
Specifically I want the formula to be Lux = solarradiation / .015.
Currently Solar Radiation is defined in the following way within the DTH:
In the metadata section:
attribute âsolarradiationâ, âstringâ
I am trying to create a lux value in the following way:
def lux = (solarradiation)/0.015
I know the âdef lux =â part is right because when i put âdef lux =1â i get the value of 1 returned.
To read that value you need to use the following, but since itâs defined as a string and your using it as a number youâd probably need to append either toInteger() or .toDecimal() to it:
Edit: I copied âsolarradiationâ from your original post and it looks like it used slanted quotes so if you copied and pasted it back into your code that would explain the error you posted.
Hey @krlaframboise . Thanks again for getting back. I tried the above but it would then take my solarradiation value to zero in SmartThings. When you mentioned taking the string to an integer I Googled it and ended up trying a few lines of what you reccomended and what I saw online. Bottom line is the below works. I probably could have saved a step but not going to touch it anymore now that it finally works.
Thx again!
def SRInteger = device.currentValue(âsolarradiationâ) as int
def lux = SRInteger / 0.015