Probably not but to be sure it would help to see the actual error in the log. Can you share the relevant loglines ?pvklink wrote: Thursday 13 December 2018 10:14 I get errors with the second script with a nil value. No variable is mentioned in the logging and there was a line mentioned but my script does not have so much lines.
local huidwaarde = dz.utils.round(device.usage,1)
and the device with my father in law says Usage electric so i think thats:
local huidwaarde = dz.utils.round(device.WhActual,1)
Does it makes any different qua functionality ?
Persistent data as a variable
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Persistent data as a variable
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
pvklink
- Posts: 822
- Joined: Wednesday 12 November 2014 15:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest b
- Contact:
Re: Persistent data as a variable
something about x has a nill value on a non existing line...
problem is gone by using whactual..
problem is gone by using whactual..
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
Jablotron connection, Ikea
-
pvklink
- Posts: 822
- Joined: Wednesday 12 November 2014 15:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest b
- Contact:
Re: Persistent data as a variable
My Switch went to often on and off because of a outside temperature that is flipping. Risc is that the heating device connected to it, runs defect.
So i use variable DurTImer. When the switch is On because off the temperatureaverage is above the norm, i wait For DurTimer minutes before switching the switch back to off.
But i got a error on my if then else statement...
:20.527 Status: dzVents: Info: Temperatuur trend: --------------------------------------------
2018-12-17 12:14:20.527 Status: dzVents: Info: Temperatuur trend: 03 Sensor info = Huidig gemiddelde temperatuur (8.4) is boven de norm(4), device: Zuiderparklaan-Diversen
2018-12-17 12:14:20.527 Status: dzVents: Error (2.4.9): Temperatuur trend: An error occured when calling event handler DZ_temperatuur
2018-12-17 12:14:20.527 Status: dzVents: Error (2.4.9): Temperatuur trend: ...icz/scripts/dzVents/generated_scripts/DZ_temperatuur.lua:131: attempt to index field 'lastupdate' (a nil value)
2018-12-17 12:14:20.527 Status: dzVents: Info: Temperatuur trend: ------ Finished DZ_temperatuur
if switch.state == 'On' and onoff == 'Yes' then
if tonumber(switch.lastupdate.minutesAgo) > tonumber(DurTimer) then
switch.switchOff().checkFirst().silent()
else
dz.log("04 Sensor info = device: " .. name .. " Niet uitgezet omdat timer nog niet is verlopen: " .. DurTimer )
end
end
Logging: strange that there a two historic records with a value and Verbruik.gemiddeld = 0 ????
So i use variable DurTImer. When the switch is On because off the temperatureaverage is above the norm, i wait For DurTimer minutes before switching the switch back to off.
But i got a error on my if then else statement...
:20.527 Status: dzVents: Info: Temperatuur trend: --------------------------------------------
2018-12-17 12:14:20.527 Status: dzVents: Info: Temperatuur trend: 03 Sensor info = Huidig gemiddelde temperatuur (8.4) is boven de norm(4), device: Zuiderparklaan-Diversen
2018-12-17 12:14:20.527 Status: dzVents: Error (2.4.9): Temperatuur trend: An error occured when calling event handler DZ_temperatuur
2018-12-17 12:14:20.527 Status: dzVents: Error (2.4.9): Temperatuur trend: ...icz/scripts/dzVents/generated_scripts/DZ_temperatuur.lua:131: attempt to index field 'lastupdate' (a nil value)
2018-12-17 12:14:20.527 Status: dzVents: Info: Temperatuur trend: ------ Finished DZ_temperatuur
if switch.state == 'On' and onoff == 'Yes' then
if tonumber(switch.lastupdate.minutesAgo) > tonumber(DurTimer) then
switch.switchOff().checkFirst().silent()
else
dz.log("04 Sensor info = device: " .. name .. " Niet uitgezet omdat timer nog niet is verlopen: " .. DurTimer )
end
end
Logging: strange that there a two historic records with a value and Verbruik.gemiddeld = 0 ????
Code: Select all
14:04:24.255 (weather underground rijswijk) General/Solar Radiation (Zuiderparklaan6)
2018-12-17 14:04:24.680 (dummydevices) Light/Switch (Sonoff1)
2018-12-17 14:04:24.554 Status: dzVents: Info: Temperatuur trend: ------ Start internal script: DZ_temperatuur: Device: "Zuiderparklaan-Diversen (weather underground rijswijk)", Index: 681
2018-12-17 14:04:24.556 Status: dzVents: Debug: Temperatuur trend: Processing device-adapter for Sonoff1: Switch device adapter
2018-12-17 14:04:24.556 Status: dzVents: Info: Temperatuur trend: 00 History data van 2018-12-17 13:04:22 = 8.5 graden
2018-12-17 14:04:24.556 Status: dzVents: Info: Temperatuur trend: 00 History data van 2018-12-17 13:34:23 = 8.5 graden
2018-12-17 14:04:24.556 Status: dzVents: Info: Temperatuur trend: Deviceinfo----------------------------------
2018-12-17 14:04:24.556 Status: dzVents: Info: Temperatuur trend: 00 Kwh-device................= Zuiderparklaan-Diversen
2018-12-17 14:04:24.556 Status: dzVents: Info: Temperatuur trend: 00 Switch-device.............= Sonoff1
2018-12-17 14:04:24.556 Status: dzVents: Info: Temperatuur trend: 00 Switch.onoff..............= Yes
2018-12-17 14:04:24.556 Status: dzVents: Info: Temperatuur trend: Verbruikinfo--------------------------------
2018-12-17 14:04:24.556 Status: dzVents: Info: Temperatuur trend: 00 Verbruik.norm.............= 4
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Verbruik.gemiddeld........= 0
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Verbruik.huidige waarde...= 9.8
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Verbruik.vorige waarde....= 8.5
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Verbruik.gemid. hist......= 8.5
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Verbruik.minimumwaarde....= 8.5
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Verbruik.maximumwaarde....= 8.5
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: Notificatie---------------------------------
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Notificatie.norm(in.min)..= 30
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Notificatie.verzonden.....= false
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Notificatie.aan...........= Yes
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Notificatie.receivers.....= pvkmobiel
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Notificatie.prio..........= PRIORITY_NORMAL
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 00 Notificatie.sound.........= siren
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: --------------------------------------------
2018-12-17 14:04:24.557 Status: dzVents: Debug: Temperatuur trend: Constructed timed-command: On
2018-12-17 14:04:24.557 Status: dzVents: Debug: Temperatuur trend: Constructed timed-command: On
2018-12-17 14:04:24.557 Status: dzVents: Debug: Temperatuur trend: Constructed timed-command: On NOTRIGGER
2018-12-17 14:04:24.557 Status: dzVents: Info: Temperatuur trend: 05 Sensor info = Huidig gemiddelde temperatuur (0) is onder of gelijk aan de norm(4), device: Zuiderparklaan-Diversen
2018-12-17 14:04:24.559 Status: dzVents: Info: Temperatuur trend: ------ Finished DZ_temperatuur
2018-12-17 14:04:24.645 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2018-12-17 14:04:24.681 Status: Notification: Domoticz device:Sonoff1
Code: Select all
--[[ wordt de vervanger van dz_buitentemperatuur aanzetten van lint en een timer om aan uit te voorkomen..
https://github.com/dannybloe/dzVents#historical-variables-api <<<<< This is quite old ; better use
https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting#Accessing_values_in_historical_variables
script uses a temp sensor Zuiderparklaan which uses Weather Underground with pws:ITHEHAGU40
]] --
local USAGE_SENSORS = {
['Zuiderparklaan-Diversen'] = 'Zuiderparklaan-Diversen', -- Adjust to your needs. Between every line you need to add a ",".
--['Zuiderparklaan'] = 'Zuiderparklaan', -- Adjust to your needs. Between every line you need to add a ",".
}
local USAGE_SWITCHES = {
['Zuiderparklaan-Diversen'] = 'Sonoff1', -- Name of device that switch kw_1 On/ Off
--['Zuiderparklaan'] = 'stroomlint', -- Name of device that switch kw_1 On/ Off
}
local USAGE_Norm = {
['Zuiderparklaan-Diversen'] = 4, -- is de norm, onder deze waarde gaat het device aan als onoff aanstaat
--['Zuiderparklaan'] = 4, -- is de norm, onder deze waarde gaat het device aan als onoff aanstaat
}
local USAGE_DurTimer = {
['Zuiderparklaan-Diversen'] = 30, -- is de periode waarover gemiddelde wordt berekend om pieken te voorkomen, zie gemwaarden (deze kun je niet parametriseren)
--['Zuiderparklaan'] = 30, -- is de periode waarover gemiddelde wordt berekend om pieken te voorkomen, deze wordt niet gebruikt, zie gemwaarden (deze kun je niet parametriseren)
}
local USAGE_SwitchOnOff = {
['Zuiderparklaan-Diversen'] = 'Yes', -- Adjust to your needs. Between every line you need to add a ",".
--['Zuiderparklaan'] = 'Yes', -- Adjust to your needs. Between every line you need to add a ",".
}
local USAGE_Notify = {
['Zuiderparklaan-Diversen'] = 'Yes',
-- ['Zuiderparklaan'] = 'Yes',
}
local USAGE_Pushoverreceivers = {
['Zuiderparklaan-Diversen'] = 'pvkmobiel',
--['Zuiderparklaan'] = 'pvkmobiel',
}
local USAGE_Pushoverprio = {
['Zuiderparklaan-Diversen'] = 'PRIORITY_NORMAL', --domoticz.PRIORITY_LOW, PRIORITY_MODERATE, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_EMERGENCY
--['Zuiderparklaan'] = 'PRIORITY_NORMAL', --domoticz.PRIORITY_LOW, PRIORITY_MODERATE, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_EMERGENCY
}
local USAGE_Pushoversound = {
['Zuiderparklaan-Diversen'] = 'siren',
--['Zuiderparklaan'] = 'siren',
}
return {
on = { devices = USAGE_SENSORS },
logging = {
level = domoticz.LOG_DEBUG , -- Uncomment to override the dzVents global logging setting
marker = "Temperatuur trend"
},
data = {
prevhistwaarde = { history = true, maxHours = 1 },
sendnotification = {initial = {}},
},
execute = function(dz, device)
if dz.data.prevhistwaarde.getOldest() == nil then -- Check if history is already filled (initial does not work with history persistent data
dz.data.prevhistwaarde.add(4) -- ook deze kun je niet parametriseren
end
local name = device.name
local name2 = USAGE_SWITCHES[name]
local switch = dz.devices(USAGE_SWITCHES[name])
local onoff = USAGE_SwitchOnOff[USAGE_SENSORS[name]]
local norm = USAGE_Norm[USAGE_SENSORS[name]]
local notify = USAGE_Notify[USAGE_SENSORS[name]]
local receivers = USAGE_Pushoverreceivers[USAGE_SENSORS[name]]
local prio = USAGE_Pushoverprio[USAGE_SENSORS[name]]
local sound = USAGE_Pushoversound[USAGE_SENSORS[name]]
local DurTimer = USAGE_DurTimer[USAGE_SENSORS[name]]
local huidwaarde = dz.utils.round(device.temperature,1)
local prevwaarde = dz.utils.round(dz.data.prevhistwaarde.getLatest().data,1)
local gemwaarden = dz.utils.round(dz.data.prevhistwaarde.avgSince('00:30:00'),1) --check als deze geen waarde heeft, dan prevwaarde! neem niet een te klein bereik
local avgwaarde = dz.utils.round(dz.data.prevhistwaarde.avg(),1)
local minwaarde = dz.utils.round(dz.data.prevhistwaarde.min(),1)
local maxwaarde = dz.utils.round(dz.data.prevhistwaarde.max(),1)
local now = os.time(os.date('*t'))
if huidwaarde == nil then -- onderstaande checks moeten na de locals omdat ze deze ook gebruiken!
dz.log("01 Sensor info = Geen waarde opgehaald")
end
if gemwaarde == 0 then
dz.log("02 Sensor info = Geen gemiddelde waarde opgehaald, nu vorige waarde gebruikt")
end
if dz.data.sendnotification[name] == nil then
dz.data.sendnotification[name] = false -- eerste waarde teller op false gezet -- geen notify gedaan
end
for i = dz.data.prevhistwaarde.size,1,-1 do
item = dz.data.prevhistwaarde.get(i)
dz.log("00 History data van " .. item.time.rawDate .. " " .. item.time.rawTime ..
" = " .. item.data .. " graden")
end
dz.log("Deviceinfo----------------------------------")
dz.log("00 Kwh-device................= " .. name)
dz.log("00 Switch-device.............= " .. name2)
dz.log("00 Switch.onoff..............= " .. onoff)
dz.log("Verbruikinfo--------------------------------")
dz.log("00 Verbruik.norm.............= " .. norm)
dz.log("00 Verbruik.gemiddeld........= " .. gemwaarden)
dz.log("00 Verbruik.huidige waarde...= " .. huidwaarde)
dz.log("00 Verbruik.vorige waarde....= " .. prevwaarde)
dz.log("00 Verbruik.gemid. hist......= " .. avgwaarde)
dz.log("00 Verbruik.minimumwaarde....= " .. minwaarde)
dz.log("00 Verbruik.maximumwaarde....= " .. maxwaarde)
dz.log("Notificatie---------------------------------")
dz.log("00 Notificatie.norm(in.min)..= " .. DurTimer)
dz.log("00 Notificatie.verzonden.....= " .. tostring(dz.data.sendnotification[name]))
dz.log("00 Notificatie.aan...........= " .. notify)
dz.log("00 Notificatie.receivers.....= " .. receivers)
dz.log("00 Notificatie.prio..........= " .. prio)
dz.log("00 Notificatie.sound.........= " .. sound)
dz.log("--------------------------------------------")
if gemwaarden > norm then
dz.log("03 Sensor info = Huidig gemiddelde temperatuur (".. gemwaarden ..") is boven de norm(".. norm .. "), device: " .. name .. "")
if switch.state == 'On' and onoff == 'Yes' then
if tonumber(switch.lastupdate.minutesAgo) > tonumber(DurTimer) then
switch.switchOff().checkFirst().silent()
else
dz.log("04 Sensor info = device: " .. name .. " Niet uitgezet omdat timer nog niet is verlopen: " .. DurTimer )
end
end
dz.data.sendnotification[name] = false
else
if switch.state == 'Off' and onoff == 'Yes' then
switch.switchOn().checkFirst().silent()
msg3=' Switch: ' .. name2 .. ' is aangezet'
else
msg3=' '
end
if (dz.data.sendnotification[name] == false) then
if (notify == 'Yes') then
msg1 = 'Domoticz device:' .. name2
msg2 = 'Gemiddelde temperatuur (' .. gemwaarden .. ') <= (' .. norm .. '), voor een periode van (' .. tostring(DurTimer) .. ' min)' .. msg3
dz.notify(msg1,msg2,prio,sound,receivers,dz.NSS_PUSHOVER)
dz.data.sendnotification[name] = true
end
end
dz.log("05 Sensor info = Huidig gemiddelde temperatuur (".. gemwaarden ..") is onder of gelijk aan de norm(".. norm .. "), device: " .. name .. "")
dz.data.prevhistwaarde.add(huidwaarde)
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
Jablotron connection, Ikea
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Persistent data as a variable
Almost everything in dzVents is case sensitive. Try lastUpdatepvklink wrote: Monday 17 December 2018 12:32 But i got a error on my if then else statement...
attempt to index field 'lastupdate' (a nil value)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
pvklink
- Posts: 822
- Joined: Wednesday 12 November 2014 15:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest b
- Contact:
Re: Persistent data as a variable
sh..... Everything works again
I solved the problem with flipping on/off by using .lastupdate icm DurTimer
I want to display the time of switch.LatsUpdate en calculate the estimated time
dz.log("00 Notificatie.switch.laatste update= " .. tostring(switch.lastUpdate.rawTime)) -- deze is goed
dz.log("00 Notificatie.switch.eind tijd.....= " .. tostring(now - tonumber(switch.lastUpdate.rawTime))) -- arithmetic on a nil value
ABOVE SECOND RULE DOES NOT SEEMS TO WORK
I solved the problem with flipping on/off by using .lastupdate icm DurTimer
I want to display the time of switch.LatsUpdate en calculate the estimated time
dz.log("00 Notificatie.switch.laatste update= " .. tostring(switch.lastUpdate.rawTime)) -- deze is goed
dz.log("00 Notificatie.switch.eind tijd.....= " .. tostring(now - tonumber(switch.lastUpdate.rawTime))) -- arithmetic on a nil value
ABOVE SECOND RULE DOES NOT SEEMS TO WORK
Code: Select all
--[[ wordt de vervanger van dz_buitentemperatuur aanzetten van lint en een timer om aan uit te voorkomen..
https://github.com/dannybloe/dzVents#historical-variables-api <<<<< This is quite old ; better use
https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting#Accessing_values_in_historical_variables
script uses a temp sensor Zuiderparklaan which uses Weather Underground with pws:ITHEHAGU40
]] --
local USAGE_SENSORS = {
['Zuiderparklaan'] = 'Zuiderparklaan', -- Adjust to your needs. Between every line you need to add a ",".
}
local USAGE_SWITCHES = {
['Zuiderparklaan'] = 'stroomlint', -- Name of device that switch kw_1 On/ Off
}
local USAGE_Norm = {
['Zuiderparklaan'] = 4, -- is de norm, onder deze waarde gaat het device aan als onoff aanstaat
}
local USAGE_DurTimer = {
['Zuiderparklaan'] = 200, -- is de periode die verstreken moet zijn na de laatte update van de switch in minuten om uitgezet te worden
}
local USAGE_SwitchOnOff = {
['Zuiderparklaan'] = 'Yes', -- Adjust to your needs. Between every line you need to add a ",".
}
local USAGE_Notify = {
['Zuiderparklaan'] = 'Yes',
}
local USAGE_Pushoverreceivers = {
['Zuiderparklaan'] = 'pvkmobiel',
}
local USAGE_Pushoverprio = {
['Zuiderparklaan'] = 'PRIORITY_NORMAL', --domoticz.PRIORITY_LOW, PRIORITY_MODERATE, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_EMERGENCY
}
local USAGE_Pushoversound = {
['Zuiderparklaan'] = 'siren',
}
return {
on = { devices = USAGE_SENSORS },
logging = {
level = domoticz.LOG_DEBUG , -- Uncomment to override the dzVents global logging setting
marker = "Temperatuur trend"
},
data = {
prevhistwaarde = { history = true, maxHours = 2 },
sendnotification = {initial = {}},
},
execute = function(dz, device)
local function secondsToClock(sec)
local seconds = tonumber(sec)
if seconds <= 0 then
return "00:00:00"
else
hours = string.format("%02.f", math.floor(seconds/3600))
mins = string.format("%02.f", math.floor(seconds/60 - (hours*60)))
secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60))
return hours..":"..mins..":"..secs
end
end
if dz.data.prevhistwaarde.getOldest() == nil then -- Check if history is already filled (initial does not work with history persistent data
dz.data.prevhistwaarde.add(4) -- ook deze kun je niet parametriseren
end
local name = device.name
local name2 = USAGE_SWITCHES[name]
local switch = dz.devices(USAGE_SWITCHES[name])
local onoff = USAGE_SwitchOnOff[USAGE_SENSORS[name]]
local norm = USAGE_Norm[USAGE_SENSORS[name]]
local notify = USAGE_Notify[USAGE_SENSORS[name]]
local receivers = USAGE_Pushoverreceivers[USAGE_SENSORS[name]]
local prio = USAGE_Pushoverprio[USAGE_SENSORS[name]]
local sound = USAGE_Pushoversound[USAGE_SENSORS[name]]
local DurTimer = USAGE_DurTimer[USAGE_SENSORS[name]]
local huidwaarde = dz.utils.round(device.temperature,1)
local prevwaarde = dz.utils.round(dz.data.prevhistwaarde.getLatest().data,1)
local gemwaarde = dz.utils.round(dz.data.prevhistwaarde.avgSince('00:60:00'),1) --check als deze geen waarde heeft, dan prevwaarde! neem niet een te klein bereik
local avgwaarde = dz.utils.round(dz.data.prevhistwaarde.avg(),1)
local minwaarde = dz.utils.round(dz.data.prevhistwaarde.min(),1)
local maxwaarde = dz.utils.round(dz.data.prevhistwaarde.max(),1)
local now = os.time(os.date('*t'))
if huidwaarde == nil then -- onderstaande checks moeten na de locals omdat ze deze ook gebruiken!
dz.log("01 Sensor info = Geen waarde opgehaald")
else
dz.data.prevhistwaarde.add(huidwaarde)
end
if dz.data.sendnotification[name] == nil then
dz.data.sendnotification[name] = false -- eerste waarde teller op false gezet -- geen notify gedaan
end
-- soms is gemwaarde 0 terwijl er twee records zijn met waarde! probeer het eerst op te lossen met doorlooptijden gemwaarde en histwaarde WAT NU ALS gemmiddelde echt 0 is ?
if tonumber(gemwaarde) == 0 or gemwaarde == nil then
gemwaarde = avgwaarde
dz.log("02b Sensor info = Gemwaarde was 0, daarom op avgwaarde gezet, gemwaarde:" .. tostring(gemwaarde) .. "")
else
dz.log("02c Sensor info = Gemwaarde was <> 0, , gemwaarde:" .. tostring(gemwaarde) .. "")
end
for i = dz.data.prevhistwaarde.size,1,-1 do
item = dz.data.prevhistwaarde.get(i)
dz.log("00 History data van " .. item.time.rawDate .. " " .. item.time.rawTime ..
" = " .. item.data .. " graden")
end
dz.log("Deviceinfo---------------------------------------")
dz.log("00 Kwh-device.......................= " .. name)
dz.log("00 Switch-device....................= " .. name2)
dz.log("00 Switch.onoff.....................= " .. onoff)
dz.log("Verbruikinfo-------------------------------------")
dz.log("00 Verbruik.norm....................= " .. norm)
dz.log("00 Verbruik.gemiddeld...............= " .. gemwaarde)
dz.log("00 Verbruik.huidige waarde..........= " .. huidwaarde)
dz.log("00 Verbruik.vorige waarde...........= " .. prevwaarde)
dz.log("00 Verbruik.gemid. hist.............= " .. avgwaarde)
dz.log("00 Verbruik.minimumwaarde...........= " .. minwaarde)
dz.log("00 Verbruik.maximumwaarde...........= " .. maxwaarde)
dz.log("Notificatie--------------------------------------")
dz.log("00 Notificatie.norm(in.min).........= " .. DurTimer)
-- deze kunnen weg als t niet lukt zie ook internet rawTime is een eigenschap
dz.log("00 Notificatie.switch.laatste update= " .. tostring(switch.lastUpdate.rawTime)) -- deze is goed
--dz.log("00 Notificatie.switch.eind tijd.....= " .. tostring(now - tonumber(switch.lastUpdate.rawTime))) -- deze geeft een fout aritmic on a nul value
dz.log("00 Notificatie.verzonden............= " .. tostring(dz.data.sendnotification[name]))
dz.log("00 Notificatie.aan..................= " .. notify)
dz.log("00 Notificatie.receivers............= " .. receivers)
dz.log("00 Notificatie.prio.................= " .. prio)
dz.log("00 Notificatie.sound................= " .. sound)
dz.log("-------------------------------------------------")
if gemwaarde > norm then
dz.log("03 Sensor info = Huidig gemiddelde temperatuur (".. gemwaarde ..") is boven de norm(".. norm .. "), device: " .. name .. "")
if switch.state == 'On' and onoff == 'Yes' then
if tonumber(switch.lastUpdate.minutesAgo) > tonumber(DurTimer) then
switch.switchOff().checkFirst().silent()
else
dz.log("04 Sensor info = device: " .. name .. " Niet uitgezet omdat timer nog niet is verlopen: " .. DurTimer )
end
end
dz.data.sendnotification[name] = false
else
if switch.state == 'Off' and onoff == 'Yes' then
switch.switchOn().checkFirst().silent()
msg3=' Switch: ' .. name2 .. ' is aangezet'
else
msg3=' '
end
if (dz.data.sendnotification[name] == false) then
if (notify == 'Yes') then
msg1 = 'Domoticz device:' .. name2
msg2 = 'Gemiddelde temperatuur (' .. gemwaarde .. ') <= (' .. norm .. '),' .. msg3
dz.notify(msg1,msg2,prio,sound,receivers,dz.NSS_PUSHOVER)
dz.data.sendnotification[name] = true
end
end
dz.log("05 Sensor info = Huidig gemiddelde temperatuur (".. gemwaarde ..") is onder of gelijk aan de norm(".. norm .. "), device: " .. name .. "")
end
end
}
/code]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
Jablotron connection, Ikea
Who is online
Users browsing this forum: No registered users and 1 guest