What is changed:
On the top of the code, there is a part on = { device = { }}
This is for the devices which needs to trigger the script. You also added the action devices.
When the action devices are added, they also trigger the script, which could give strange behavior.
You used quietOn and quietOff, this sets the deviceStatus to on/off without physically switching it
Changed this to switchOn/Off with addon .silent() to not trigger other scripts.
This part i don't get what you would like to do with it.
It is always triggered if the script is triggerd. Is Garage 2 sensor closed is active, then also this will activate the garage 2 relay for 2 sec. But not direct, but indirect. Because the else part of this code is true in this case and will set the device Garage 2 door to ON, because of that, the script if triggered again and then the if is true and will switch Garage 2 Relay
Code: Select all
-- if Dummi switch is pressed to activate the relay for 2sec that will open the door
if (domoticz.devices('Garage 2 Door').state == 'On') then
domoticz.devices('Garage 2 Relay').switchOn().forSec(2)
else
domoticz.devices('Garage 2 Door').switchOn().forSec(2)
end
Code: Select all
return {
on = {
devices = {
'Garage 2 Door', -- Dummy switch Garage 2 Door idx 73
'Garage 2 Sensor Closed', -- Magnet sensor Garage 2 Sensor Closed idx 76
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'Garage 2',
},
execute = function(domoticz)
-- if standart Remote control is used only to indicate the condition
if (domoticz.devices('Garage 2 Sensor Closed').state == 'On') then
domoticz.devices('Garage 2 Door').switchOn().silent()
domoticz.notify('Garage 2', 'Garage 2 Open', domoticz.PRIORITY_EMERGENCY)
else
domoticz.devices('Garage 2 Door').switchOff().silent()
domoticz.notify('Garage 2', 'Garage 2 Closed', domoticz.PRIORITY_EMERGENCY)
end
-- if Dummi switch is pressed to activate the relay for 2sec that will open the door
if (domoticz.devices('Garage 2 Door').state == 'On') then
domoticz.devices('Garage 2 Relay').switchOn().forSec(2)
else
domoticz.devices('Garage 2 Door').switchOn().forSec(2)
end
-- to switch On the garage light between sunset and sunrise
if domoticz.devices('Garage 2 Sensor Closed').state == 'On' and domoticz.time.('at nighttime') then
domoticz.devices('Garage 2 Light Light').switchOn()
else
domoticz.devices('Garage 2 Light Light').switchOff()
end
end
}