preceding 0, in values devices
Posted: Monday 06 March 2017 21:32
I use the "buienradar-plugin" to retrieve values for windspeed etc.
I run a lua script set these values to some dummy devices (type wind)
After running the script the values are :
2017-03-06 20:59:46.933 LUA: Windmeter: Winddirection (in degrees) is: 30
2017-03-06 20:59:46.934 LUA: Windmeter: Winddirection is: NNE
2017-03-06 20:59:46.934 LUA: Windmeter: Windspeed is: 22
2017-03-06 20:59:46.934 LUA: Windmeter: Windgust is: 29
2017-03-06 20:59:46.934 LUA: Windmeter: Windtemperature is: 6.1
2017-03-06 20:59:46.934 LUA: Windmeter: Windfeel is: 4.5
In every weather device the value is preceeded by 0,
So Winddirection in degrees is 0,30
Winddirection is 0,NNE
and so on
How do I get rid of the 0,
This is my code :
I run a lua script set these values to some dummy devices (type wind)
After running the script the values are :
2017-03-06 20:59:46.933 LUA: Windmeter: Winddirection (in degrees) is: 30
2017-03-06 20:59:46.934 LUA: Windmeter: Winddirection is: NNE
2017-03-06 20:59:46.934 LUA: Windmeter: Windspeed is: 22
2017-03-06 20:59:46.934 LUA: Windmeter: Windgust is: 29
2017-03-06 20:59:46.934 LUA: Windmeter: Windtemperature is: 6.1
2017-03-06 20:59:46.934 LUA: Windmeter: Windfeel is: 4.5
In every weather device the value is preceeded by 0,
So Winddirection in degrees is 0,30
Winddirection is 0,NNE
and so on
How do I get rid of the 0,
This is my code :
Code: Select all
--Windmeter data:
local idxt = 365 --idx of the virtual temperature sensor you need to change this to your own Device IDx
local idxh = 366 --idx of the virtual humidity sensor you need to change this to your own Device IDx
local idxi = 367 --idx of the virtual pressure sensor you need to change this to your own Device IDx
local idxj = 368
local idxk = 369
local idxl = 370
sWindDirectionDegrees, sWindDirection, sWindSpeed, sWindGust, sWindTemperature, sWindFeel = otherdevices_svalues['Buienradar - Wind']:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
sWindDirectionDegrees = tonumber(sWindDirectionDegrees);
sWindDirection = (sWindDirection);
sWindSpeed = tonumber(sWindSpeed);
sWindGust = tonumber(sWindGust);
sWindTemperature = tonumber(sWindTemperature);
sWindFeel = tonumber(sWindFeel);
print("Windmeter: Winddirection (in degrees) is: " .. sWindDirectionDegrees .. " ");
print("Windmeter: Winddirection is: " .. sWindDirection .. " ");
print("Windmeter: Windspeed is: " .. sWindSpeed .. " ");
print("Windmeter: Windgust is: " .. sWindGust .. " ");
print("Windmeter: Windtemperature is: " .. sWindTemperature .. " ");
print("Windmeter: Windfeel is: " .. sWindFeel .. " ");
commandArray = {}
commandArray[1] = {['UpdateDevice'] = idxt .. '|' .. sWindDirectionDegrees}
commandArray[2] = {['UpdateDevice'] = idxh .. '|' .. sWindDirection}
commandArray[3] = {['UpdateDevice'] = idxi .. '|0|' .. sWindSpeed}
commandArray[4] = {['UpdateDevice'] = idxj .. '|0|' .. sWindGust}
commandArray[5] = {['UpdateDevice'] = idxk .. '|0|' .. sWindTemperature}
commandArray[6] = {['UpdateDevice'] = idxl .. '|0|' .. sWindFeel}
return commandArray