Re: Scraping only the temperature from WeatherUnderground se
Posted: Tuesday 10 February 2015 18:51
If this the correct way to control via the temperature
Open source Home Automation System
https://forum.domoticz.com/
Code: Select all
sWeatherTemp, sWeatherHumidity, sWeatherHumidityStat, sWeatherBarometer, sWeatherBarometerFor = otherdevices_svalues[capteurwu1]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
commandArray[1]={['UpdateDevice'] = idx1 .. '|0|' .. tostring(sWeatherTemp)}
commandArray[2]={['UpdateDevice'] = idx2 .. '|' .. tostring(sWeatherHumidity) .. '|' .. '|' .. tostring(sWeatherHumidityStat) .. '|'}
Code: Select all
--script_device_tempCresta.lua
local sensorLR = 'ThermoRFXCOM' --Original sensor of wunderground carrying the 0001 ID
local idx = 102 --idx of your manual created virtual temp sensor
commandArray = {}
if devicechanged[sensorLR] then
sWeatherTemp, sWeatherHumidity = otherdevices_svalues[sensorLR]:match("([^;]+);([^;]+)")
--sWeatherTemp = tonumber(sWeatherTemp)
commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp)
end
return commandArray
local idx = 102 --idx of the virtual temperature sensor you created above
Added a cresta sensor from my neighbors to DomoticzDutchHans wrote:Hello all,
There is something strange.. when I look in the Logfile the lua script is not triggered.
I am not a programmer, I try to read code and understand it. I have tried to change the WU script for my needs... but I have no idea
But am I missing something?
The WU script is triggered, thats what the log says, but my Cresta lua file isnt.
What am i doing wrong?
Hope someone can help me out.Code: Select all
--script_device_tempCresta.lua local sensorLR = 'ThermoRFXCOM' --Original sensor of wunderground carrying the 0001 ID local idx = 102 --idx of your manual created virtual temp sensor commandArray = {} if devicechanged[sensorLR] then sWeatherTemp, sWeatherHumidity = otherdevices_svalues[sensorLR]:match("([^;]+);([^;]+)") --sWeatherTemp = tonumber(sWeatherTemp) commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp) end return commandArray
Kind regards, Hans
Code: Select all
--script_device_sensorCR.lua
local sensorcr = 'Weerstation' --name of the sensor that gets created when you add the Cresta device (and that contains multiple values like temperature, humidity, barometer etc)
local idx = 327 --idx of the virtual temperature sensor you created for scrapping the temperature
commandArray = {}
if devicechanged[sensorcr] then
sCrestaTemp, sCrestaHumidity, sCrestaPressure = otherdevices_svalues[sensorcr]:match("([^;]+);([^;]+);([^;]+)")
sCrestaTemp = tonumber(sCrestaTemp)
commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sCrestaTemp)
end
return commandArray
Code: Select all
--script_device_sensorCR.lua
local sensorcr = 'Weerstation' --name of the sensor that gets created when you add the Cresta device (and that contains multiple values like temperature, humidity, barometer etc)
local idx = 435 --idx of the virtual temperature sensor you created for scrapping the temperature
commandArray = {}
if devicechanged[sensorcr] then
sCrestaTemp, sCrestaHumidity, sCrestaPressure = otherdevices_svalues[sensorcr]:match("([^;]+);([^;]+);([^;]+)")
sCrestaHumidity = tonumber(sCrestaHumidity)
commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sCrestaHumidity)
end
return commandArray
Code: Select all
2015-05-27 21:10:00.430 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_sensorWU.lua
2015-05-27 21:10:00.420 (WeatherUnderground) Temp + Humidity + Baro (WUCombo)
2015-05-27 21:10:00.440 Hardware Monitor: Fetching data (System sensors)
2015-05-27 21:10:00.437 (WeatherUnderground) Wind (Wind)
2015-05-27 21:10:00.450 (WeatherUnderground) UV (UV)
2015-05-27 21:10:00.476 (WeatherUnderground) Rain (Rain)
Code: Select all
local sensorwu = 'WUCombo' --name of the sensor that gets created when you add the WU device (and that contains multiple values like $
local idx = 14065 --idx of the virtual temperature sensor you created above
commandArray = {}
if devicechanged[sensorwu] then
sWeatherTemp, sWeatherHumidity, sWeatherPressure = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp)
commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(sWeatherTemp)
end
return commandArray
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 enviroment get the 'Idx' or 'Name' off the Device tab. By default only the Temp is 'uncommented or enabled' in this script.
local sensorwu = 'ChangeME' --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 = 999 --idx of the virtual temperature sensor you need to change this to your own Device ID
local idxh = 999 --idx of the virtual humidity sensor you need to change this to your own Device ID
local idxp = 999 --idx of the virtual pressure sensor you need to change this to your own Device ID
--
commandArray = {}
if devicechanged[sensorwu] then
sWeatherTemp, sWeatherHumidity, sHumFeelsLike, sWeatherPressure = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp)
sWeatherHumidity = tonumber(sWeatherHumidity)
sWeatherPressure = tonumber(sWeatherPressure)
--parseDebug = ('WU Script Parsed Temp=' .. sWeatherTemp .. ' Humidity=' .. sWeatherHumidity .. ' Pressure=' .. sWeatherPressure)
--print(parseDebug)
commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. sWeatherTemp}
--commandArray[2] = {['UpdateDevice'] = idxh .. '|' .. tostring(sWeatherHumidity) .. '|' .. tostring(sHumFeelsLike)}
--commandArray[3] = {['UpdateDevice'] = idxp .. '|0|' .. sWeatherPressure}
end
return commandArray
found my error I was using the ID and not the idxspudgunman wrote:note sure what I am missing here - new to this whole project and wondering where to troubleshoot next, I have also tried this on the SVN build with same results (the results that my virtual temp device wont update)
Code: Select all
sWeatherTempwu, sWeatherHumiditywu, sWeatherPressurewu = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+)")
sWeatherTempwu = tonumber(sWeatherTempwu)
sWeatherHumiditywu = tonumber(sWeatherHumiditywu)
if (sWeatherHumiditywu > 60 ) then
verw = 3 -->60 = 3 wet
elseif (sWeatherHumiditywu < 25 ) then
verw = 2 --<25 = 2 dry
else
verw = 1 -->=25 of <=60 = 1 comfortable
end
commandArray[2]={['UpdateDevice'] = idxwut .. '|0|' .. tostring(sWeatherTempwu)}
commandArray[3]={['UpdateDevice'] = idxwuh .. '|' .. tostring(sWeatherHumiditywu) .. '|' .. tostring(verw)}
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 enviroment get the 'Idx' or 'Name' off the Device tab. By default only the Temp is 'uncommented or enabled' in this script.
local sensorwu = 'ChangeME' --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 = 999 --idx of the virtual temperature sensor you need to change this to your own Device ID
local idxh = 999 --idx of the virtual humidity sensor you need to change this to your own Device ID
local idxp = 999 --idx of the virtual pressure sensor you need to change this to your own Device ID
--
commandArray = {}
if devicechanged[sensorwu] then
sWeatherTemp, sWeatherHumidity, sHumFeelsLike, sWeatherPressure = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp)
sWeatherHumidity = tonumber(sWeatherHumidity)
sWeatherPressure = tonumber(sWeatherPressure)
--parseDebug = ('WU Script Parsed Temp=' .. sWeatherTemp .. ' Humidity=' .. sWeatherHumidity .. ' Pressure=' .. sWeatherPressure)
--print(parseDebug)
commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. sWeatherTemp}
--commandArray[2] = {['UpdateDevice'] = idxh .. '|' .. tostring(sWeatherHumidity) .. '|' .. tostring(sHumFeelsLike)}
--commandArray[3] = {['UpdateDevice'] = idxp .. '|0|' .. sWeatherPressure}
end
return commandArray
Code: Select all
sPressiureFeelsLike = 3 --basically just a placeholder I dont know what this should be
commandArray[3] = {['UpdateDevice'] = idxp .. '|' .. sPressiureFeelsLike .. '|' .. sWeatherPressure}