Script sending muliple messages
Posted: Sunday 06 September 2020 19:59
Hi,
I wrote an alarm script.
I have an alarm pad with an fibaro Smart implant attached. If I switch of the alarm ('Alarm Switch 1') by this box, the message 'Alarm uitgeschakeld' is send 3 times. I thought I fixed it with the uservariable 'Var Alarm. This fixed sending it 20 times, but it's still sending it 3 times.
'Alarm Switch 1' is an push-on button (also tried on/off button) with an of delay of 1 sec.
In the button log on 1 'on' is logged and then of, so no multiple 'on's' here.
Is there a way how to fix this different?
The same problem come up when I used an 433 button, but thisone is sending multiple 'on's'
Hope you can help:
I wrote an alarm script.
I have an alarm pad with an fibaro Smart implant attached. If I switch of the alarm ('Alarm Switch 1') by this box, the message 'Alarm uitgeschakeld' is send 3 times. I thought I fixed it with the uservariable 'Var Alarm. This fixed sending it 20 times, but it's still sending it 3 times.
'Alarm Switch 1' is an push-on button (also tried on/off button) with an of delay of 1 sec.
In the button log on 1 'on' is logged and then of, so no multiple 'on's' here.
Is there a way how to fix this different?
The same problem come up when I used an 433 button, but thisone is sending multiple 'on's'
Hope you can help:
Code: Select all
return {
on = {
devices = { 'Alarm Switch 1',
'Alarm Switch 2',
'Button alarm beneden',
'Button alarm uit boven',
'Motion Bijkeuken',
'Motion Zithoek',
'Motion Speelhoek',
'Motion Eetkamer',
'Motion Keuken',
'Motion Overloop',
'Motion Badkamer',
'Alarm hele huis',
'Alarm beneden'},
'Trigger alarm beneden',
'Trigger alarm hele huis'
},
data = {},
logging = {},
execute = function(dz, Item)
if dz.devices('Alarm Switch 2').state == 'On' and
(dz.variables('Var Alarm').value == 0 or
dz.variables('Var Alarm').value == 2)then
dz.devices('Trigger alarm hele huis').switchOn() -- Alarm trigger hele huis inschakelen
end
if dz.devices('Trigger alarm hele huis').state == 'On' and
dz.devices('Motion Bijkeuken').state == 'Off' and
dz.devices('Motion Zithoek').state == 'Off' and
dz.devices('Motion Speelhoek').state == 'Off' and
dz.devices('Motion Eetkamer').state == 'Off' and
dz.devices('Motion Keuken').state == 'Off' and -- Of ergens anders beneden
dz.devices('Motion Overloop').state == 'Off' and
dz.devices('Motion Badkamer').state == 'Off' then
dz.devices('Alarm hele huis').switchOn()
dz.notify('Alarm hele huis ingeschakeld')
dz.variables('Var Alarm').set(1)
end
if dz.devices('Button alarm beneden').state == 'On' and
(dz.variables('Var Alarm').value == 0 or
dz.variables('Var Alarm').value == 1) then
dz.devices('Trigger alarm beneden').switchOn() -- Alarm trigger beneden inschakelen, voor de nacht, alleen de sensoren beneden triggeren het alarm
end
if dz.devices('Trigger alarm beneden').state == 'On' and
dz.devices('Motion Bijkeuken').state == 'Off' and
dz.devices('Motion Zithoek').state == 'Off' and
dz.devices('Motion Speelhoek').state == 'Off' and
dz.devices('Motion Eetkamer').state == 'Off' and
dz.devices('Motion Keuken').state == 'Off' then -- Of ergens anders beneden
dz.devices('Alarm beneden').switchOn()
dz.notify('Alarm beneden ingeschakeld')
dz.variables('Var Alarm').set(2)
end
if (dz.devices('Button alarm uit boven').state == 'On' or
dz.devices('Alarm Switch 1').state == 'On') and
(dz.variables('Var Alarm').value == 1 or
dz.variables('Var Alarm').value == 2) then
dz.devices('Trigger alarm hele huis').switchOff()
dz.devices('Trigger alarm beneden').switchOff() -- Alarm uitschakelen
dz.devices('Alarm hele huis').switchOff()
dz.devices('Alarm beneden').switchOff()
dz.devices('Alarm Sirene').switchOff()
dz.notify('Alarm uitgeschakeld')
dz.variables('Var Alarm').set(0)
end
if dz.devices('Alarm hele huis').state == 'On' and -- Als het alarm aan staat
(dz.devices('Motion Bijkeuken').active.forSec(30) or -- En er beweging langer dan 30 sec beweging is in de bijkeuken
dz.devices('Motion Zithoek').active or
dz.devices('Motion Speelhoek').active or
dz.devices('Motion Eetkamer').active or
dz.devices('Motion Keuken').active or -- Of ergens anders beneden
dz.devices('Motion Overloop').active or
dz.devices('Motion Badkamer').active) then -- Of ergens boven
dz.devices('Alarmsituatie hele huis').switchOn() -- Alarm hele huis aan
dz.notify('Alarm hele huis')
end
if dz.devices('Alarm beneden').state == 'On' and -- Als het alarm aan staat
(dz.devices('Motion Bijkeuken').active or
dz.devices('Motion Zithoek').active or
dz.devices('Motion Speelhoek').active or
dz.devices('Motion Eetkamer').active or
dz.devices('Motion Keuken').active) then -- Als er beweging is beneden
dz.devices('Alarmsituatie beneden').switchOn() -- Alarm beneden aan
dz.notify('Alarm beneden')
end
-- if dz.devices('Alarmsituatie beneden').state == 'On' or
-- dz.devices('Alarmsituatie hele huis').state == 'On' then
-- dz.devices('Alarm Sirene').switchOn()
-- end
end
}