Haiku Flag email

heffneil

Active Member
I have a script that emails me daily the value of a flag. the problem is that a flag in the omnipro can only reach 200 so It starts over at 0 when it reaches 201. Anyway I would prefer it emails me each time it reaches 200 I guess so I can get an accurate measurement.

Any ideas?

Thanks,

Neil
 
You could make the script count the number of roll overs, maybe even store the roll over count in another flag if you want to be able to keep a record of the count.

Or of course yes, you can check the value and when its 200 send out an email.
 
function onRefreshConfig(forced) {
controller.refreshUnits;
}

function onSyncStart(forced) {
var now = new Date();
if(now.getHours() == 15 && now.getMinutes() == 08) {
var msg = 'My flag status: ' + controller.unitWithName('Pool Water').flagDescription;
helper.mail(controller, '[email protected]', 'Pool Water Meter', msg);
}
}
 
So how does this meter work? It just increments the flag based on something happening? Just trying to understand the logic.
 
Yes sorry I have a program on the controller that every time the meter goes not ready to increment the flag. The meter is a reed switch. Thanks!
 
It would be easy to script it to store the value in HaikuHelper, do you need it to be very persistent? Or is that enough for your tracking purposes? It would count in memory and if you restarted HaikuHelper it would start from 0 again. You'd still have the previous e-mails of course. Do you want it to work like that? Or do you need it more exact?
 
All I want to do is obtain the value of the flag daily but my problem is that it will reach 200 before a day is up and the next day it might be 3 when yesterday it was 150? I want the daily flag count. On sunday morning I reset the flag to 0 anyway so I can the new weekly value. I had assumed that I wouldn't put more then 200 gallons a week but I am wrong :( Any way to get a daily and weekly total would be ideal.

Thanks!

Neil
 
Haven't tested it, but this should work:

Code:
var poolMeterDay = 0;
var poolMeterWeek = 0;
 
function onSyncStart(forced, timestamp) {
    var date = new Date(timestamp);
 
    if(date.getHours() == 0 && date.getMinutes() == 00) {
        sendPoolMeterReport();
        poolMeterDay = 0;
        if(date.getDay() == 0) poolMeterWeek = 0;
    }
}
 
function onButtonActivate(button) {
    if(button.name == "PoolMeter") incrementPoolMeter();
}
 
function incrementPoolMeter() {
    poolMeterDay += 1;
    poolMeterWeek += 1;
}
 
function sendPoolMeterReport() {
    var report = "Pool Meter Report: Week = " + poolMeterWeek + " Day = " + poolMeterDay;
    helper.sendMail(controller, "[email protected]", "Pool Meter Report", report);
    helper.log(controller, report);
}

Just create a button named PoolMeter and make your controller activate this button every time the sensor trips. This will give you daily and weekly count starting on Sunday via e-mail as well as log it to the HaikuHelper log.
 
Or you can also just read the reed switch in HaikuHelper directly... instead of onButtonActivate use onZoneNotReady(zone) and then do if(zone.name == "yoursensorsname") incrementPoolMeter();

This would be better as it takes the extra load off the controller.
 
Lupin I love the idea - can you provide some coding assistance here? I would be happy to remove the programming on the controller and get the data in to HH and then email it daily and clear the value weekly. I mean that would be ideal considering the number isn't limited and I can dump the flag. Love the idea. If you could help would love it even more!

Thanks,

Neil
 
Back
Top