Page 1 of 1
dzVent version info and .isDevice not working
Posted: Thursday 21 June 2018 14:21
by rogzon
Hi!
I have searched thru the whole Internet for an answer on how to get the version number of my installed dzVents.....
Is there somewhere version information for dzVents?
Also I have this:
Code: Select all
return {
active = true, -- set to false to disable this script
on = {
devices = {
224, -- id
},
httpResponses = {
'scheduleinfo',
}
},
execute = function(domoticz, device)
if (device.isDevice) then
print('Device!')
end
end
}
I have taken away the http stuff for now but, what I can understand is that if I push the switch(224) the device.isDevice should return true?
It doesn't, when trying "print(device.isDevice)" i get " ... isDevice is a nil value" in my log.
Is this because a dzVent version problem?
/
Re: dzVent version info and .isDevice not working [Solved]
Posted: Thursday 21 June 2018 14:28
by snellejellep
to get your version number for dzvents you can go to <your domoticz url>/#/About
Re: dzVent version info and .isDevice not working
Posted: Monday 25 June 2018 22:09
by rogzon
For anybody else reading this..
The version info is available in the About dialog but for some reason I needed to update to 4.9700 to even have an entry stating the dzVents version...
Also device.isDevice is working now.
The only thing completely missing now is device.isSchedule which should return true if the switch would be toggled by a schedule.
It would be quite handy...
Re: dzVent version info and .isDevice not working
Posted: Monday 25 June 2018 23:06
by waaren
rogzon wrote: ↑Monday 25 June 2018 22:09
The only thing completely missing now is device.isSchedule which should return true if the switch would be toggled by a schedule.
It would be quite handy...
If you want to have information if a device state is triggered by a schedule you could use the information in the domoticz log to identify this.
Code: Select all
-- isScheduled.lua
triggerDevice = 985 -- define the switch you want to monitor
return {
on = { httpResponses = { "get_DomoticzLogLines" },
devices = { triggerDevice}},
logging = { level = domoticz.LOG_INFO,
marker = "get triggered by info from log" },
execute = function(dz, trigger)
local function askDomoticzForLogLines()
local lastLogTime = os.time(os.date('*t')) - 10 -- current Time as seconds from epoch - 10 should get enough logging
local logLevel = 2 -- loglevel (1=normal,2=Status,4=error,268435455=all
local jsonString = "/json.htm?type=command¶m=getlog&" ..
"lastlogtime=" .. tostring(lastLogTime) ..
"&loglevel=" .. logLevel
dz.openURL ({ url = dz.settings["Domoticz url"] .. jsonString, -- loglevel 2 ==>> Status:logURL,
method = "GET", callback = "get_DomoticzLogLines" })
end
-- Get information recent log entries for switch action
function isScheduled(device)
local resultTable = trigger.json.result
for i = #resultTable,1,-1 do -- Read backwards to get latest switchoperation first
if string.find(resultTable[i].message,device.name) and -- Look for Device name , update Time
string.find(resultTable[i].message,device.lastUpdate.rawTime) and -- and string Schedule...
string.find(resultTable[i].message,"Schedule") and -- and strings User: and initiated...
not(string.find(resultTable[i].message,"dzVents")) then
return true
end
end
return false
end
if trigger.isDevice then
askDomoticzForLogLines()
else
if isScheduled(dz.devices(triggerDevice)) then
dz.log(dz.devices(triggerDevice).name .. " IS triggered by schedule",dz.LOG_INFO)
else
dz.log(dz.devices(triggerDevice).name .. " NOT triggered by schedule",dz.LOG_INFO)
end
end
end
}
Re: dzVent version info and .isDevice not working
Posted: Wednesday 27 June 2018 11:52
by rogzon
Yes, that's a good idea. For now I am storing on and off time as string in a variable like this:
Code: Select all
return {
active = true, -- set to false to disable this script
on = {
devices = {
224, -- id
},
httpResponses = {
'scheduleinfo',
}
},
execute = function(domoticz, device)
if (device.isDevice) then
print('Device!')
if(device.state == 'On') then
domoticz.openURL({
url = 'http://192.001.01.02:8080/json.htm?type=schedules',
method = 'GET',
callback = 'scheduleinfo'})
end
end
if (device.isHTTPResponse and device.ok) then
print('HTTPResponse!')
local results = device.json.result
for i, node in pairs(results) do
if(node.DeviceRowID == 3) then
print(node.DevName .. ' ' .. node.Active .. ' ' .. node.Time .. ' ' .. node.TimerCmd)
if (node.TimerCmd==1) then
domoticz.variables('mvhScheduleOffTime').set(node.Time)
else
domoticz.variables('mvhScheduleOnTime').set(node.Time)
end
end
end
end
end
}
I did however succeed in my original quest which was distinguishing between a physical button push and "on by schedule" in a device event.
I simply moved the timer to a group and put my switch into that group. By setting a uservariable in the "schedule on" event I now know that it wasn't a physical button push.
This comes in handy when controlling engine heaters during winter, push the button means on for 3 hours but don't turn off if schedule has kicked in..