How to put logic to temperature events?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
jimbo213Mo
Posts: 8
Joined: Friday 26 October 2018 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: United States
Contact:

How to put logic to temperature events?

Post by jimbo213Mo »

Hi - Please MOVE this to the appropriate sub-board topic.
I'm a new Domoticz user [actually my teckie son set it up] and this is my first post.

SYSTEM: RaspberryPi.

My son installed a temperature probe in the freezer of our garage over-under refrigerator
I wanted to know if the compressor failed so I can remove the meat before it spoiled.
That really works fine but I'm wanting an improvement.

So now I get 2 text alerts 22 minutes apart from each other when the defrost cycle starts/stops:
  • 0,ALERT: Garage Freezer over +25F, usually is +10F
  • 0, [Recovered] ALERT: Garage Freezer over +25F, usually is +10F
Can someone suggest how to revise the Garage Freezer alerts to ONLY alert me if the RECOVERY alert does NOT come in 25 minutes? [and not alert me when the probe senses out/in range as it now does].

Just wondering ...
Thanks in advance, I'll forward the replies to my son for a Christmas-visit implementation.

I don't know what you'll want from my system so I'm pasting the following - let me know what more you need AND how I should get it.

Name: garage-freezer-temp
Show entriesSearch:
Type
When
Active Systems
Custom Message
Priority
Ignore Interval
Recovery
Temperature Greater 25 ° F http ALERT: Garage freezer above +25F, usually is +10F Normal No Yes
Showing 1 to 1 of 1 entries

Type:
When:
Value:
° F
Priority:
Ignore Interval: [this is off = red]
(If enabled, it will bypass the Notification interval specified in the Settings page)
Recovery Notification: [this is off = red]
(If enabled, a notification will be send when given condition has been recovered)
Custom Message:
(Optional)
Active Systems: [these are all ON - green]
browser
clickatell
email
gcm
http
kodi
lms
prowl
pushalot
pushbullet
pushover
pushsafer
telegram

Add
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to put logic to temperature events?

Post by waaren »

jimbo213Mo wrote: Friday 26 October 2018 21:54 My son installed a temperature probe in the freezer of our garage over-under refrigerator
I wanted to know if the compressor failed so I can remove the meat before it spoiled.
Can someone suggest how to revise the Garage Freezer alerts to ONLY alert me if the RECOVERY alert does NOT come in 25 minutes? [and not alert me when the probe senses out/in range as it now does].
I don't think it is possible to set it up like your requirement from within the notification screen. A possible solution with dzVents would look like.

Code: Select all

return {
    on      = { timer     = { "every 5 minutes" }},

    data = { temperatures = { history = true, maxItems = 6 },
             notifyCounter= { initial = 0                  }},
    
    execute = function(dz)    
        if dz.data.temperatures.getLatest() == nil then
            dz.data.temperatures.add(10)                               -- initialize persistent historical data
        end
        
        local freezerTemp       = dz.devices("garage-freezer-temp").temperature
        local minTemp30Minutes  = dz.data.temperatures.minSince('00:30:00')     -- get lowest temperature in last 30 minutes
        local highTemp          = 25  
        local notifyFrequency   = 6                                             -- NotifyFrequency (1 = 5 minutes, 12 = 1 hour, etc)    
        dz.data.temperatures.add(freezerTemp)                                   -- store current temperature in persistent data
        if freezerTemp > highTemp and minTemp30Minutes > highTemp then          -- Temperature too high for too long
             if (dz.data.notifyCounter % notifyFrequency) == 0 then           -- modulo
                dz.notify("Freezer temperature too high for more than 25 minutes")  
            end
             dz.data.notifyCounter = dz.data.notifyCounter + 1
        else
            dz.data.notifyCounter = 0
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
DeBaat
Posts: 33
Joined: Saturday 27 January 2018 14:52
Target OS: NAS (Synology & others)
Domoticz version: V3.8153
Contact:

Re: How to put logic to temperature events?

Post by DeBaat »

Hai,
Would it be possible to set the limit to another value before warning?

I can imagine the freezer would not reach e.g. 100F if it is working ok.
So you would only need to be informed when the temperature is not below the critical value.
jimbo213Mo
Posts: 8
Joined: Friday 26 October 2018 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: United States
Contact:

Re: How to put logic to temperature events?

Post by jimbo213Mo »

@DeBaat I thought of that ... the maximum temp reached at the defrost cycle is 46.6F so YES, I could certainly set the cycle to 47F.
The defrost cycle only lasts 23 minutes - then the temp goes back to -1.5F - not too long for the contents to defrost and spoil.
So I'm thinking my criteria SHOULD be time-sensitive.
If it is over the normal high of +15F [see daily chart below] for more than 25 minutes THEN i should be concerned.
That might just be the same as an action over 47F ... I'll just have to think about that.
I still want to be notified of HOW LONG it has been over 47F ... a few minutes would be OK.
An hour and the food is starting to thaw.
Over 47F for 5 hours and it's getting time to pitch the food.

But Hey - thanks for the constructive comment. It got me thinking.
So how could I add a timer variable ... how long is the temp over 47F ??
Attachments
last 24 hours
last 24 hours
chart last 24hours.png (108.09 KiB) Viewed 991 times
last 365 days
last 365 days
chart last year.png (92.43 KiB) Viewed 996 times
jimbo213Mo
Posts: 8
Joined: Friday 26 October 2018 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: United States
Contact:

Re: How to put logic to temperature events?

Post by jimbo213Mo »

@waaren
Thanks for the idea - I am a 70 yr old "teckie" so I'm trying hard to keep up with this new stuff.
I think I may have found a way to incorporate your code ... see the attachment.
Please advise is the { and } look right.
Thanks A LOT ... Jim
GF dz code.png
GF dz code.png (73.31 KiB) Viewed 984 times

I'm getting this ERROR MESSAGE
2018-10-28 18:26:00.905 Status: dzVents: Error (2.4.6): error loading module 'dzGF_Over25forOver30Min' from file '/home/automate/scripts/dzVents/generated_scripts/dzGF_Over25forOver30Min.lua':
2018-10-28 18:26:00.905 ...ts/dzVents/generated_scripts/dzGF_Over25forOver30Min.lua:1: unexpected symbol near '}'
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to put logic to temperature events?

Post by waaren »

jimbo213Mo wrote: Monday 29 October 2018 0:04 ..I'm getting this

Code: Select all

2018-10-28 18:26:00.905 Status: dzVents: Error (2.4.6): error loading module 'dzGF_Over25forOver30Min' from file '/home/automate/scripts/dzVents/generated_scripts/dzGF_Over25forOver30Min.lua':
2018-10-28 18:26:00.905 ...ts/dzVents/generated_scripts/dzGF_Over25forOver30Min.lua:1: unexpected symbol near '}'
as explained in my reply to your PM, the } at position 1 on line 1 was not in the script I posted and it causes the error.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
DeBaat
Posts: 33
Joined: Saturday 27 January 2018 14:52
Target OS: NAS (Synology & others)
Domoticz version: V3.8153
Contact:

Re: How to put logic to temperature events?

Post by DeBaat »

jimbo213Mo wrote: Sunday 28 October 2018 22:22 So how could I add a timer variable ... how long is the temp over 47F ??
Nice to see the way you think.
How about running the script every minute and keep track of the number of minutes in a separate variable?
Something like this:

IF temp OK
THEN NumDefrostMinutes = 0;
ELSE NumDefrostMinutes + 1;

And then you could add logic to be warned when a certain threshold is reached, like this:

IF NumDefrostMinutes > Threshold
THEN Signal ERROR;

Unfortunately I don't know the exact code for this.
Hope this helps.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest