I was facing the same problem. Important to know is that a pressure sensor needs the pressure in bar, a barometer needs the pressure in hPa and weather underground supplies the pressure in hPa. Further a barometer also needs a so called BAR_FOR = Barometer forecast (see domoticz json/api docs for more details). I think weather underground supplies this forecast also.
I think I have fixed the problems for both types of sensors in LUA. I added an index for a barometer sensor, I also read the last value of the Temperature-Humidity-Barometer object (stored it in sWeatherPressureForecast ) and converted from hPa to bar.
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 = 'TempHumiBaro-WU' --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 = 51 --idx of the virtual temperature sensor you need to change this to your own Device IDx
local idxh = 52 --idx of the virtual humidity sensor you need to change this to your own Device IDx
local idxp = 54 --idx of the virtual pressure sensor you need to change this to your own Device IDx
local idxb = 53 --idx of virtual barometer sensor you need to change this to your own Device IDx
--
commandArray = {}
if devicechanged[sensorwu] then
sWeatherTemp, sWeatherHumidity, sHumFeelsLike, sWeatherPressure, sWeatherPressureForecast = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp)
sWeatherHumidity = tonumber(sWeatherHumidity)
sHumFeelsLike = tonumber(sHumFeelsLike)
sWeatherPressure = tonumber(sWeatherPressure) -- hPa
sWeatherPressureBar = sWeatherPressure/1000 -- bar
sWeatherPressureForecast = tonumber(sWeatherPressureForecast)
parseDebug = ('WU Script Parsed Temperat=' .. sWeatherTemp)
print(parseDebug)
parseDebug = ('WU Script Parsed Humidity=' .. sWeatherHumidity)
print(parseDebug)
parseDebug = ('WU Script Parsed HumidityFeelsLike=' .. sHumFeelsLike)
print(parseDebug)
parseDebug = ('WU Script Parsed Pressure=' .. sWeatherPressure .. ' hPa')
print(parseDebug)
parseDebug = ('WU Script Parsed Pressure=' .. sWeatherPressureBar .. ' bar')
print(parseDebug)
parseDebug = ('WU Script Parsed PressureForecast=' .. sWeatherPressureForecast)
print(parseDebug)
commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. sWeatherTemp}
commandArray[2] = {['UpdateDevice'] = idxh .. '|' .. tostring(sWeatherHumidity) .. '|' .. tostring(sHumFeelsLike)}
commandArray[3] = {['UpdateDevice'] = idxp .. '|0|' .. sWeatherPressureBar}
commandArray[4] = {['UpdateDevice'] = idxb .. '|0|' .. sWeatherPressure .. ';' .. sWeatherPressureForecast}
end
return commandArray
I see that values are read correctly. I still see some weird behaviour of the pressure sensor. It only stores one decimal, everything between 0.95 and 1.05 bar is seen as 1.0 bar. I send 1.019 bars, which is stored as 1.0 bar. The differences in air pressure are normally not that big, so a lot of info is lost.