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..