Can anyone help me with a script to trigger fire alarm

Moderator: leecollings

Post Reply
andyman
Posts: 11
Joined: Monday 11 November 2013 19:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Can anyone help me with a script to trigger fire alarm

Post 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).
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

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

Post by Bikey »

Why don't you use the grouping features ot the KD101 themselves?
andyman
Posts: 11
Joined: Monday 11 November 2013 19:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

Can anyone help me with a script to trigger fire alarm

Post 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?
andyman
Posts: 11
Joined: Monday 11 November 2013 19:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
commodore white
Posts: 63
Joined: Sunday 14 July 2013 11:19
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Ipswich, UK
Contact:

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

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests