I wrote this script:
Code: Select all
return {
active = true,
logging = {
level = domoticz.LOG_DEBUG,
marker = "TEST_"
},
on = {
devices = {
'temperature1'
},
},
execute = function(domoticz, device)
domoticz.log("---aaaaaaaaaaaaaaaaaaaaaaaaa")
domoticz.log(device.name)
domoticz.log(device.temperature)
domoticz.log("---bbbbbbbbbbbbbbbbbbbbbbbbb")
end
}
I have DHT22 sensor. In Domoticz type
"Temperature + Humidity"
it works:
Code: Select all
2017-12-14 17:48:45.643 dzVents: Info: Handling events for: "temperature1", value: "11.15;54.10;0"
2017-12-14 17:48:45.644 dzVents: Info: TEST_: ------ Start internal script: temperature_test: Device: "temperature1 (test)", Index: 10
2017-12-14 17:48:45.644 dzVents: Info: TEST_: ---aaaaaaaaaaaaaaaaaaaaaaaaa
2017-12-14 17:48:45.644 dzVents: Info: TEST_: temperature1
2017-12-14 17:48:45.644 dzVents: Info: TEST_: 11.14999961853
2017-12-14 17:48:45.645 dzVents: Info: TEST_: ---bbbbbbbbbbbbbbbbbbbbbbbbb
2017-12-14 17:48:45.645 dzVents: Info: TEST_: ------ Finished temperature_test
But I have virtual domoticz thermometer, that extract only temperature from DHT22 "Temperature + Humidity". I'm using this code found something at domoticz wiki/forum:
Code: Select all
# /home/domoticz/domoticz/scripts/lua/script_device_DHT22.lua
-- http://www.domoticz.com/wiki/Virtual_weather_devices#Scraping_only_temperature
--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 = 'dht22' --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 = 14 --idx of the virtual temperature sensor you need to change this to your own Device IDx
local idxh = 15 --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
sWeatherTemp, sWeatherHumidity, 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|' .. tostring(sWeatherPressure) .. ';' .. tostring(sWeatherPressForcast)}
end
return commandArray
This sdcript update value on domoticz widget, but cannot trigger change action in dzVents. How can I use this script-updated-virtual domotcz sensor?