How to do freezer temperature alerts properly.

Moderator: leecollings

Post Reply
jasongodwin
Posts: 4
Joined: Sunday 26 February 2017 17:35
Target OS: Linux
Domoticz version:
Contact:

How to do freezer temperature alerts properly.

Post by jasongodwin »

Hi, I've got domoticz up and running and have it reporting on five ice cream freezers.

The problem is, every day, the freezers do an automatic defrost, and also, every day, we open the freezers to remove and replace ice creams.

What I'd like are freezer alerts if the temperature is say warmer than -15 degrees for more than 10 minutes. When my employees leave at night, the place the ice creams back into the freezer, and the freezer temperature drops to say -5 degrees, but only for a few minutes. And would soon recover the temperature. But if they leave the door open, then it'll never get down to temperature, and the ice creams will be ruined. I don't want to receive alerts unless xxxx minutes have passed. I have no idea how to do this, anyone can help ?

Many thanks.

Jason
rjblake
Posts: 142
Joined: Friday 21 October 2016 9:25
Target OS: NAS (Synology & others)
Domoticz version:
Location: Netherlands
Contact:

Re: How to do freezer temperature alerts properly.

Post by rjblake »

Jason - what devices/device type are you using for the monitoring of the freezers? Are three 5 separate devices? How often do you record/get the temperature? The logic is fairly simple (note when it first went over -15 and if still over 10mins later then send alert) and its just a decision on whether to use Blockly, LUA or a Python or PHP script
User avatar
berny
Posts: 6
Joined: Saturday 17 December 2016 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: belgium
Contact:

Re: How to do freezer temperature alerts properly.

Post by berny »

maybe you can use this example? ....

http://www.domoticz.com/wiki/Event_scri ... 10_minutes
jasongodwin
Posts: 4
Joined: Sunday 26 February 2017 17:35
Target OS: Linux
Domoticz version:
Contact:

Re: How to do freezer temperature alerts properly.

Post by jasongodwin »

Hi Rj, i've got four boxes that I had built for me which connect to the domoticz server via wifi, most have just one probe, but one of them has three probes..

I believe they take the temperature once every minute. What I don't understand is how to get a script to note when it first goes over -15 degrees, and then see if ten minutes later its still over -15..... I could give you username/password access and I'd be really grateful if you could point me in the right direction.......
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: How to do freezer temperature alerts properly.

Post by Egregius »

I would store the timestamp when temperature first goes over -15 and then use that in future checks.
For example (using pass2php):

Code: Select all

if(apcu_fetch('sfridge1') > -15){
    $time_fridge1_warning=apcu_fetch('time_fridge1_warning');
    if($time_fridge1_warning==0) apcu_store('time_fridge1_warning',time);
    elseif($time_fridge1_warning < time - 900) telegram('Warning: Fridge 1 hotter than -15° for more than 15 minutes',false);
}else{
    apcu_store('time_fridge1_warning',0);
} 

berny wrote:maybe you can use this example? ....

http://www.domoticz.com/wiki/Event_scri ... 10_minutes
Don't think that will work as the last update time will change upon every new temperature.
rjblake
Posts: 142
Joined: Friday 21 October 2016 9:25
Target OS: NAS (Synology & others)
Domoticz version:
Location: Netherlands
Contact:

Re: How to do freezer temperature alerts properly.

Post by rjblake »

jasongodwin wrote:Hi Rj, i've got four boxes that I had built for me which connect to the domoticz server via wifi, most have just one probe, but one of them has three probes..

I believe they take the temperature once every minute. What I don't understand is how to get a script to note when it first goes over -15 degrees, and then see if ten minutes later its still over -15..... I could give you username/password access and I'd be really grateful if you could point me in the right direction.......
Jason - happy to take a look later this week if you want.
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: How to do freezer temperature alerts properly.

Post by Nautilus »

Egregius wrote:
berny wrote:maybe you can use this example? ....

http://www.domoticz.com/wiki/Event_scri ... 10_minutes
Don't think that will work as the last update time will change upon every new temperature.
One option is to combine this to a uservariable that e.g. updates to "1" when temp is above -15 (with condition that variable is not yet at this value) and to "0" when below (also here a condition not to update if variable already = 0). Then you can use the logic in the wiki article to check "uservariable_lastupdated" timestamp.

Or you could use the variable as counter (lua time scripts run once every minute) so that if temp is above -15, variable value = variable value + 1 (reset to 0 when below -15). Then send the notification when counter value hits 10.
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: How to do freezer temperature alerts properly.

Post by Egregius »

That's about the same I do, only difference is that I like to keep Domoticz as clean as possible and do everything I can do in php/cache there.
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: How to do freezer temperature alerts properly.

Post by Nautilus »

Egregius wrote:That's about the same I do, only difference is that I like to keep Domoticz as clean as possible and do everything I can do in php/cache there.
Sure, I just think with this type of questions the discussion should first and foremost focus on the tools available directly in Domoticz.

I'm sure the same thing can be accomplished in pretty much any given programming language and with nearly unlimited number of different approaches :) Yours with php/cache being probably the finest / most comprehensive of the ones displayed here and thus of course worth mentioning as well. But I guess we all agree it might not be the easiest for a beginner...:)
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: How to do freezer temperature alerts properly.

Post by Egregius »

Nautilus wrote:But I guess we all agree it might not be the easiest for a beginner...:)
That's true, but once running... :D

Either way, the approach will be something like this:
Store timestamp of when treshold is passed or count how many times a time script has run with that treshold.
While typing been thinking that counting could even be better in this case.
If the script runs every minute:

Code: Select all

If temp > treshold{
	count = count + 1
	If count > 15 {
		send notification
		set count = 0
	}
}else{
	set count = 0
}
Where or how the count is stored doesn't mather of course ;)
The advantage would be that the notification is repeated every 15 minutes until the temp drops below the treshold.
rjblake
Posts: 142
Joined: Friday 21 October 2016 9:25
Target OS: NAS (Synology & others)
Domoticz version:
Location: Netherlands
Contact:

Re: How to do freezer temperature alerts properly.

Post by rjblake »

Egregius wrote:
Nautilus wrote:But I guess we all agree it might not be the easiest for a beginner...:)
...
While typing been thinking that counting could even be better in this case.
...
The advantage would be that the notification is repeated every 15 minutes until the temp drops below the treshold.
My thoughts exactly - the 'issue' of temperature being over would need to be fixed to correct temperature or else notifications would continue to be received. Downside is that if there is a problem taking a long time...Possibly create a single dummy device to record the highest temperature (above -15) which could also be used to log the trend (i.e. if it takes 14mins to get back to -15deg after nightly activities, then you could adjust script to avoid unneeded notifications). As Nautilus said, might be simplest to create something using LUA directly in Domoticz; although a PHP or Python script running permanently in the background would probably be more elegant; but requires 'other stuff'
jasongodwin
Posts: 4
Joined: Sunday 26 February 2017 17:35
Target OS: Linux
Domoticz version:
Contact:

Re: How to do freezer temperature alerts properly.

Post by jasongodwin »

I'm happy to pay for someone to connect to my installation, and write the scripts..........
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: How to do freezer temperature alerts properly.

Post by Egregius »

Isn't it more fun do search and do it yourself?
Further more, what if in some time something goes wrong? If someone else has done it you can start over... If you created it yourself you'll probably be able to fix it.
rjblake
Posts: 142
Joined: Friday 21 October 2016 9:25
Target OS: NAS (Synology & others)
Domoticz version:
Location: Netherlands
Contact:

Re: How to do freezer temperature alerts properly.

Post by rjblake »

@jasongodwin - dropped you a PM, but it really is not a big one to solve (few minutes) - some simple easy to read code below (you just need to update to match fridge temperature device names and add a User Variable (under setup->more options->User Variables). I've tried to add comments to explain and show what it does/where it does

Code: Select all

--
-- Checks freezer temperatures and if greater than 'desired_temperature' (e.g. -15) over a period of 'time_before_alert' (e.g. 10 minutes) send alert
--
-- 
-- Some configuration variables
--
desired_temperature = -15
time_before_alert = 10 

--
-- Variables to be added to Domoticz
--
problem_counter = tonumber(uservariables['freezer_problem_counter']) 

commandArray = {}
print('Freezer Temperature Check')

--
-- Looks up the temperatures from the Domoticz devices using their name (not idx)
--
freezer_temp1 = tonumber(otherdevices_svalues['Freezer#1']:match("([^;]+)"))
freezer_temp2 = tonumber(otherdevices_svalues['Freezer#2']:match("([^;]+)"))
freezer_temp3 = tonumber(otherdevices_svalues['Freezer#3']:match("([^;]+)"))
freezer_temp4 = tonumber(otherdevices_svalues['Freezer#4']:match("([^;]+)"))
freezer_temp5 = tonumber(otherdevices_svalues['Freezer#5']:match("([^;]+)"))
local t = {freezer_temp1, freezer_temp2, freezer_temp3, freezer_temp4, freezer_temp5}

print('Freezer Temp:'..freezer_temp1..":"..freezer_temp2..":"..freezer_temp3..":"..freezer_temp4..":"..freezer_temp5)

--
-- if any of the freezers temperatures are above the desired temperatures, increment counter by 1 (=1 minute)
--
if (freezer_temp1 > desired_temperature) or (freezer_temp2 > desired_temperature) or (freezer_temp3 > desired_temperature) or (freezer_temp4 > desired_temperature) or (freezer_temp5 > desired_temperature) then 
    problem_counter = problem_counter + 1
    print('Freezer Temperature Problem for: '..problem_counter..' minutes')
    local key, max = 1, t[1]
    for k, v in ipairs(t) do
        if t[k] > max then
            key, max = k, v
        end
    end
    -- print(key, max)
    print('Freezer#'..key..' has a temperature of: '..max..' degrees')
    commandArray['Variable:freezer_problem_counter'] = tostring(problem_counter)
end

--
-- if the temperatures are ALL at desired temperature print all okay
-- if temps were not previously ok and notification had previously been sent, sent a 'Back to normal' notification 
--
if  (freezer_temp1 <= desired_temperature) and (freezer_temp2 <= desired_temperature) and (freezer_temp3 <= desired_temperature) and (freezer_temp4 <= desired_temperature) and (freezer_temp5 <= desired_temperature) then
    print('Freezer Temperatures looking good')
    if (problem_counter >= time_before_alert) then
        print('Send Alert to notify freezer temperature is back to normal') -- this needs to be updated to reflect the required alert method
    end
    problem_counter = 0
    commandArray['Variable:freezer_problem_counter'] = tostring(problem_counter)
end    

--
-- If value of 'time_before_alert' e.g. 10(=10 minutes) met, send a notification
--
if (problem_counter == time_before_alert) then
    -- need to also add some logic here for how often to send notifications (i.e. every minute, every 5mins, etc.)
    print('Send Freezer Alert using some method') -- this needs to be updated to reflect the required alert method
end

return
jasongodwin
Posts: 4
Joined: Sunday 26 February 2017 17:35
Target OS: Linux
Domoticz version:
Contact:

Re: How to do freezer temperature alerts properly.

Post by jasongodwin »

Sincere thanks to everyone here. Your responses have been nothing short of amazing. Thank you. Best, Jason
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest