you are amazing!
I (you, sorry) made this script for my 85 years old father in law how lives on a houseboat. In the winter his watersuply freezes. So we bought an electric wire to warm it. We connect the wire to a smart switch/sensor. A made two lua scripts for him, one to check the temp, one to activate the switch with some rules so that the switch does not goes on or off to much. I want to get rid of LUA....because dzvents is much smarter i think...
If temp is below 4 switch must go on for x hours, but if the temp is above 4 it must go off if the timeperiod x hours is over...
[logging]
19:35:50.776 (weather underground rijswijk) General/Visibility (Zuiderparklaan-Zicht)
2018-11-22 19:35:50.779 (weather underground rijswijk) General/Solar Radiation (Zuiderparklaan6)
2018-11-22 19:35:50.845 Status: dzVents: Info: Temperatuur trend: ------ Start internal script: DZ_testmettemperatuur: Device: "Zuiderparklaan (weather underground rijswijk)", Index: 680
2018-11-22 19:35:50.846 Status: dzVents: Info: Temperatuur trend: 00 Sensor device = Zuiderparklaan
2018-11-22 19:35:50.846 Status: dzVents: Info: Temperatuur trend: 00 Sensor grenswaarde = 4
2018-11-22 19:35:50.846 Status: dzVents: Info: Temperatuur trend: 00 Sensor huidige waarde= 4.6
2018-11-22 19:35:50.846 Status: dzVents: Info: Temperatuur trend: 00 Sensor vorige waarde = 4.9
2018-11-22 19:35:50.846 Status: dzVents: Info: Temperatuur trend: 1
2018-11-22 19:35:50.846 Status: dzVents: Info: Temperatuur trend: 00 History data van 2018-11-21 18:54:26 = 4.9000000953674 graden
2018-11-22 19:35:50.846 Status: dzVents: Info: Temperatuur trend: ---------------------------------------
2018-11-22 19:35:50.846 Status: dzVents: Info: Temperatuur trend: 05 Sensor info = Temperatuur daalt
2018-11-22 19:35:50.848 Status: dzVents: Debug: Temperatuur trend: Processing device-adapter for Temperatuur: Temperature device adapter
2018-11-22 19:35:50.850 Status: dzVents: Info: Temperatuur trend: ------ Finished DZ_testmettemperatuur
[old lua script_1] the new temperature dzvents script will replace this one/
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 = 'Barometer' --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 = 394 --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
sWeatherTemp, sWeatherHumidity, sWeatherPressure = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp)
commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. sWeatherTemp}
if sWeatherTemp > 3 then
print ('Temperatuur groter dan 3, warmtelint uit')
commandArray['warmtelint']='Off'
else
print ('Temperatuur <= dan 3, warmtelint aan')
commandArray['warmtelint']='On'
end
print("waarde sensor: "..tostring(sWeatherTemp)..'xx')
end
return commandArray
[old lua script_2] For this script i made a new dzvents script
Code: Select all
local switchlint = 'warmtelint' -- schakelaar die bij onderschreiding temperatuur aangezet wordt
local switchverbruik = 'Verbruikwarmtelint' -- schakelaar die bij onderschreiding temperatuur aangezet wordt
local curwatlimit = 1 -- minimale onderwaarde temperatuur
local wacht=2000
function round2(num, numDecimalPlaces)
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
end
commandArray = {}
curwat = otherdevices_svalues["Verbruikwarmtelint"]
print ('07a Stroomlintverbruik heeft waarde' .. tonumber(curwat) .. '/')
curwat=0
if devicechanged[switchlint] == 'On' then
i = 1
while i <= wacht do
ping_success=os.execute('ping -c1 -w 1 192.168.20.1')
print ('teller:'..tostring(i)..'')
i = i + 1
end
curwat = otherdevices_svalues["Verbruikwarmtelint"]
if tonumber(curwat) > tonumber(curwatlimit) then -- lint gebruikt stroom, dus werkt
print ('07 Stroomlint werkt. Verbruikt ' .. curwat)
else
print ('07 Stroomlint werkt niet. Verbruikt ' .. curwat)
end
end
return commandArray
I made a new dzventz script for the switch as well...
Code: Select all
return {
active = true,
on = {
timer = {'every 60 minutes'} -- dit mag wel een uur worden
},
execute = function(domoticz)
local scriptnaam = 'Verbruikwarmtelint' -- naam script voor de foutmelding
local switchlint = 'fibaro' -- schakelaar die bij onderschreiding temperatuur aangezet wordt
local switchverbruik = 'Verbruikfibaro' -- sensor die verbruik van de schakelaar meet
local curwatlimit = 1 -- minimale onderwaarde wattage van het warmtelint (onder deze waarde is hij defect)
local curwat = tonumber(domoticz.devices(switchverbruik).WhActual) -- wattage van het apparaat dat aan de switch is gekoppeld, het feitelijke warmtelint
if domoticz.devices(switchlint).state == 'On' then
if tonumber(curwat) > tonumber(curwatlimit) then -- lint gebruikt stroom, meer dan de normwaarde, dus werkt
domoticz.log('PRG: ' ..scriptnaam ..': stroomlint werkt, verbruikt: ' .. curwat .. ' Watt')
else -- lint onder de normale verbruikswaarde (nog n PUSHNOTIFICATIE maken
domoticz.log('PRG: ' ..scriptnaam ..': stroomlint werkt niet, of thermo staat aan! meet geen stroom!' .. curwat .. ' Watt')
end
end
end
}
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea