Splitting multiple values in one device to multiple single devices
Posted: Thursday 12 March 2020 17:20
Hi All,
I'm trying to realize split values from a multiple value device buienradar script.
Let me state that i am in no way a programmer but i somewhat understand the logic behind programming.
And so i try to combine and rebuild existing scripts to realize my goal.
I have this lua script running which grabs only the currect temperature from the weather underground device and puts it in a virtual device. So i can use this value in blockly scripts.
This splitting of values is the goal im trying to accomplish but now for a different source, namely Buienradar.
I want the wind and windgust values in two different devices.
situation:
Source device states the following values: 228.0;SW;99;141;8.3;4.0
I want to grab the third and fourth value.
I've created the script below for the third value, but its not working as expected:
Please ignore all the uncommented rows
This script works partially because it returns two values namely: 0, 99 in the devices screen.
The weather tab shows an empty device.
What should i do to make this script work the way i want it to?
I'm trying to realize split values from a multiple value device buienradar script.
Let me state that i am in no way a programmer but i somewhat understand the logic behind programming.
And so i try to combine and rebuild existing scripts to realize my goal.
I have this lua script running which grabs only the currect temperature from the weather underground device and puts it in a virtual device. So i can use this value in blockly scripts.
This splitting of values is the goal im trying to accomplish but now for a different source, namely Buienradar.
I want the wind and windgust values in two different devices.
situation:
Source device states the following values: 228.0;SW;99;141;8.3;4.0
I want to grab the third and fourth value.
I've created the script below for the third value, but its not working as expected:
Please ignore all the uncommented rows
Code: Select all
--Script To Parse WeatherUnderground Multi-Value Sensor, Additionally using PWS: system from WU with a new output format
--This script assumes the output (which can be viewed in events show current state button) is like this 19.5;79;3;1019;3 (temp;humidity;null;pressure;null)
--more details at this wiki http://www.domoticz.com/wiki/Virtual_weather_devices
--
--The following need updated for your environment get the 'Idx' or 'Name' off the Device tab. By default only the Temp is 'uncommented or enabled' in this script.
local sensorwu = 'Buienradar - Wind' --name of the sensor that gets created when you add the WU device (and that contains multiple values like temperature, humidity, barometer etc)
local idxt = 79 --idx of the virtual temperature sensor you need to change this to your own Device IDx
--local idxh = 999 --idx of the virtual humidity sensor you need to change this to your own Device IDx
--local idxp = 999 --idx of the virtual pressure sensor you need to change this to your own Device IDx
commandArray = {}
if devicechanged[sensorwu] then
sWindrichtingNUM, sWindrichting, sWind, sWindhoos, sA = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
--sWindrichtingNUM = tonumber(sWindrichtingNUM)
--sWindrichting = tonumber(sWindrichting)
sWind = tonumber(sWind)
--sWindhoos = tonumber(sWindhoos)
--parseDebug = ('WU Script Parsed Temp=' .. sWindrichtingNUM .. ' Humidity=' .. sWindrichting .. ' Pressure=' .. sWindhoos)
--print(parseDebug)
commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. sWind}
--commandArray[2] = {['UpdateDevice'] = idxh .. '|' .. tostring(sWindrichting) .. '|' .. tostring(sWind)}
--commandArray[3] = {['UpdateDevice'] = idxp .. '|0|' .. tostring(sWindhoos) .. ';' .. tostring(sWeatherPressForcast)}
end
return commandArray
The weather tab shows an empty device.
What should i do to make this script work the way i want it to?