mon code est le suivant:
Code : Tout sélectionner
GNU nano 2.5.3 Fichier : script_variable_ActivationAlarme.lua
--Variable scripts receive 7 tables from Domoticz:
-- otherdevices, otherdevices_lastupdate, otherdevices_svalues, otherdevices_idx, uservariables, uservariables_lastupdate and uservariablechanged
commandArray = {}
-- Path to curl
local curl = '/usr/bin/curl'
beaconHome=0
for variableName, variableValue in pairs(uservariables) do
if string.sub(variableName,1,3)=="Tag" and variableValue ~= "AWAY" then
beaconHome=beaconHome+1
end
end
if otherdevices['Alarm'] == 'On' and beaconHome>=1 then -- switch Off Alarm because 1 beacon come back Home
table.insert (commandArray, { ['Alarm'] ='Off' } )
print('alarm OF')
commandArray['OpenURL']='http://192.168.1.22/api/callAction?deviceID=136&name=setProperty&arg1=ui.presence.value&arg2=%22Present%22'
elseif otherdevices['Alarm'] == 'Off' and beaconHome==0 then -- switch On Alarm because all beacon are away
table.insert (commandArray, { ['Alarm'] ='On' } )
print('alarm onn')
commandArray['OpenURL']='http://192.168.1.22/api/callAction?deviceID=136&name=setProperty&arg1=ui.presence.value&arg2=%22Absent%22'
end
return commandArray
Code : Tout sélectionner
2017-10-03 23:50:55.751 LUA: alarm OF
2017-10-03 23:50:55.751 EventSystem: Fetching url...
2017-10-03 23:50:55.751 EventSystem: Script event triggered: /home/schwinny/domoticz/scripts/lua/script_variable_ActivationAlarme.lua
2017-10-03 23:50:55.791 (Alarm) Light/Switch (Alarm)
2017-10-03 23:50:55.954 Error: Error opening url: http://192.168.1.22/api/callAction?deviceID=136&name=setProperty&arg1=ui.presence.value&arg2=%22Present%22
2017-10-03 23:52:09.297 LUA: alarm onn
2017-10-03 23:52:09.297 EventSystem: Fetching url...
2017-10-03 23:52:09.297 EventSystem: Script event triggered: /home/schwinny/domoticz/scripts/lua/script_variable_ActivationAlarme.lua
2017-10-03 23:52:09.336 (Alarm) Light/Switch (Alarm)
2017-10-03 23:52:09.539 Error: Error opening url: http://192.168.1.22/api/callAction?deviceID=136&name=setProperty&arg1=ui.presence.value&arg2=%22Absent%22
2017-10-03 23:54:44.603 LUA: alarm OF
2017-10-03 23:54:44.603 EventSystem: Fetching url...
2017-10-03 23:54:44.603 EventSystem: Script event triggered: /home/schwinny/domoticz/scripts/lua/script_variable_ActivationAlarme.lua
2017-10-03 23:54:44.639 (Alarm) Light/Switch (Alarm)
2017-10-03 23:54:44.843 Error: Error opening url: http://192.168.1.22/api/callAction?deviceID=136&name=setProperty&arg1=ui.presence.value&arg2=%22Present%22
Une idée ?