Min/Max Lua script problem
Posted: May 23rd, 2023, 10:10 am
Hi - first post here :
I am trying to get the min and max values of a list contained in MeasureTempHistory as follows:
With the Lua script as per this https://docs.rainmeter.net/snippets/min-max-value/:
Now, I am not a programmer, probably not even a good hack anymore, but I can see that MeasureTempHistory does contain a list of numbers/text in the Skins log. Yet after trying unsuccessfully all day to get the min/max value functions to return anything other than the full list of values in MeasureTempHistory I have posted here for some insight as to what might be wrong with the code or what to do to get it to work.
Cheers
I am trying to get the min and max values of a list contained in MeasureTempHistory as follows:
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DesktopWorkAreaType=1
AlwaysOnTop=-2
[StyleLiteText]
AntiAlias=1
FontColor=100,255,100,255
FontFace=System
FontSize=16
[TodaysDate]
Measure=Time
Format=%F
[MeasureScript]
Measure=Script
ScriptFile=#@#MyScript.lua
Disabled=1
[MeasureEcowittHistory]
Measure=WebParser
URL=https://api.ecowitt.net/api/v3/device/history?application_key=xxxxxxxxxxxxxxxxxx&api_key=xxxxxxxxxxxxxxxxxxxxxxxe&mac=xxxxxxxxxxxxxxxxxxxx&start_date=[&TodaysDate]00:00:00&end_date=[&TodaysDate]23:59:59&cycle_type=auto&call_back=outdoor.temperature&temp_unitid=1
RegExp=(?siU)"list":{(.*)}}}}}.*
UpdateRate=60
[MeasureTempHistory]
Measure=WebParser
URL=[MeasureEcowittHistory]
StringIndex=1
RegExpSubstitute=1
Substitute="\d{10}":"",'":"':"",'"':""
[MeterMaxTemp]
Meter=String
MeterStyle=StyleLiteText
Text=MaxTemp = [&MeasureScript:MaxValue('[&MeasureTempHistory]')]
DynamicVariables=1
W=240
H=80
Code: Select all
function MinValue(...)
valueTable = {}
for i = 1, #arg do
table.insert(valueTable, arg[i])
end
table.sort(valueTable, function(a,b) return a<b end)
return valueTable[1]
end
function MaxValue(...)
valueTable = {}
for i = 1, #arg do
table.insert(valueTable, arg[i])
end
table.sort(valueTable, function(a,b) return a>b end)
return valueTable[1]
end
Cheers