Page 1 of 1

Can anyone help me with a script to trigger fire alarm

Posted: Wednesday 17 February 2016 14:44
by andyman
Hello guys. I have now programmed all of my KD101 with unique ID's so finally I am able to see which detector is detecting smoke (Panic). I want to group them together, but it seems that blockly has some limitations in ifelse statements. Maybe a LUA script is the best, but my knowledge is not that good on Lua so I was wondering if someone has an example script og something that can help me get started.

I have tried with sub/slave devices, but it does not seem to work well.
I have tried to create a group of detectors, this seems to work, but since I have 10 smoke detectors the will be a lot of ifelse statements.

What I am trying to do:
If smoke detector A goes into Panic, then Alert all of the other detectors (or a group with all the detectors).

Re: Can anyone help me with a script to trigger fire alarm

Posted: Thursday 18 February 2016 8:09
by Bikey
Why don't you use the grouping features ot the KD101 themselves?

Re: Can anyone help me with a script to trigger fire alarm

Posted: Thursday 18 February 2016 8:50
by andyman
If I use the grouping til the KD101, then I will only see one device (masterdevice) and then I will not be able to know wich detector is detecting smoke fast.

Se also: http://www.domoticz.com/forum/viewtopic.php?f=4&t=3638

Can anyone help me with a script to trigger fire alarm

Posted: Monday 29 February 2016 9:20
by Bikey
That is true. So then the only thing you can do is to sent a 'panic' command to all the other sensors if one is triggered and keep repeating that every 10 seconds as long as you want to have alarm sound. You can split that in multiple blockley's each handling the alarm from one sensor. With 10 smoke detectors (are you living in a hotel?), that is al lot of blockley's :-)
Just another thought: I haven't tried it but could you please smoke all detectors in a scene to activate them all at once?

Re: Can anyone help me with a script to trigger fire alarm

Posted: Monday 29 February 2016 9:55
by andyman
Big house, a lot of rooms :-P . I have tried a scene/group and I am able to trigger the siren from the group so the only thing is all the blockleys. For now i have set all the detectors to send a pushover, emergency with self defined siren on my mobile phone so I will definetly wake up.

Re: Can anyone help me with a script to trigger fire alarm

Posted: Thursday 17 March 2016 9:54
by commodore white
Hi. I'm trying to do much the same. As yet I only have one Fire Alarm but several PIRs.

I'm converting all my scripts to dzVents because managing events is such a breeze. Attached are two scripts I've developed so far:

Code: Select all

-- /lua/scripts/pir.lua by commodore white

return {
  active = true,
	on = { 'pir*' },                            -- script runs if any PIR turns on or off
	execute = function(domoticz, detector)      -- detector gets the id of the active PIR
 
		if    (detector.state == 'Motion' or detector.state == "On")
    and   domoticz.security ~= domoticz.SECURITY_DISARMED
    then  -- domoticz.setScene('Intruder Alarm', 'On')  -- could turn on a scene
          -- domoticz.devices("fireAlarm").switchOn()   -- or a fire alarm
          domoticz.notify('Security Breach @ ' .. detector.name, '', domoticz.PRIORITY_EMERGENCY, domoticz.SOUND_SIREN)
	  end -- if motion
      
	end -- execute
}
and ...

Code: Select all

--[[ /lua/scripts/fire.lua by commodore white

Notifies which alarm has been triggered, then switches it off after a period.
Several switch off commands are sent to ensure the alarm does not become annoying.

All fire alarms have names that begin with the characters "fire", for example, fireLounge, fireGarage, etc

--]]

return {
	active = true,
	on = { "fire*" },                                -- 

	execute = function(domoticz, sounder)
 
    if sounder.state == "On" then        
 
       local DURATION = 40
     
        domoticz.notify("FIRE ALARM: " .. sounder.name, '',
          domoticz.PRIORITY_EMERGENCY,
          domoticz.SOUND_SIREN)
          
        sounder.devices.switchOff().after_sec(DURATION+0)
        sounder.devices.switchOff().after_sec(DURATION+5)
        sounder.devices.switchOff().after_sec(DURATION+10)
        
    end -- if sounder On

	end -- function
}
Perhaps this helps. Peter