Page 1 of 1

Fire detection script by checking room temperatures

Posted: Sunday 03 April 2022 15:25
by psubiaco
Hi,
has anyone written a LUA script for Domoticz that checks room temperatures, and in case that a room temperature increases too fast, send a fire alarm by Telegram, Email, internal siren, ...?
Thanks.

Re: Fire detection checking room temperatures

Posted: Sunday 03 April 2022 15:36
by McMelloW
There is an example in the DzVents wiki. Very simple

Code: Select all

return
{
    on =
    {
        devices = {
            'myDetector',
            'roomTemp'
    }
},
    execute = function(domoticz, device)
        if ((device.name == 'myDetector' and device.active) or
            (device.name == 'roomTemp' and device.temperature >= 45)) then
            domoticz.notify('Fire', 'The room is on fire', domoticz.PRIORITY_EMERGENCY)
        end
    end
}

Re: Fire detection checking room temperatures

Posted: Sunday 03 April 2022 16:58
by psubiaco
hmm, that's too basic example!

I've decided to write a new script that detects fire by checking the rooms temperature:
* read a configuration file with the list of room name, temperature sensor name, deltaT to trigger the alarm
* stores in a variable, json encoded, the list of average temperature for each room
* when in one or more rooms the Temperature > Average_temperature + deltaT => send notification by Telegram
* works with both simple temperature and temperature+humidity(+barometric) sensors.

You can find the fire detector scripts in https://github.com/CreasolTech/domoticz_lua_scripts : they have to be placed into Domoticz scripts/lua directory:

* script_time_fireAlarm.lua => lua script triggered every minute
* config_fireAlarm.lua => configuration file
* globalvariables.lua => another configuration file with telegram API information and something else
* globalfunctions.lua => some functions that are used from my scripts

I'm just checking the script now... if you have any suggestions, please let me know!
I hope this script can be helpful even for you!!

Re: Fire detection checking room temperatures

Posted: Monday 04 April 2022 7:52
by psubiaco
I've updated the fire detection script again. You can download from github https://github.com/CreasolTech/domoticz_lua_scripts