Some devices in Domoticz contains multiple values, separated by semicolon ';' :
- kWh meters contain both power and energy, for example "950;11658" where 950 is the power
- Temperature/Humidity sensors, for example "21.3;57" where temperature is 21.3°C and humidity 57%
- Wind sensor, for example "135;ESE;3;9;12.4;12.4" where 3=wind speed*10 and 9 is gust*10 (windspeed=0.3m/s and gust=0.9m/s)
To extract a field from the device string, using a lua script, it's possible to use the following code:
devValue=otherdevices['WindSensor']
--devValue='109;ESE;8;15;123' The 3rd field, "8", contains the wind speed * 10
i=0
for str in devValue:gmatch("[^;]+") do
i=i+1
if (i==3) then -- extract the third field
windSpeed=tonumber(str)/10
break
end
end
print("windSpeed="..windSpeed)
if (windSpeed>5) then
-- close the solar curtain, blinds, ...
-- ToDo...
-- if (otherdevices['devicePosition']=='Open') then
-- commandArray['deviceMotor']='Close for 50 seconds'
-- end
end