Logging a TEMPERATURE value in OmniPro2 automation?

BirdingPix

Member
Hello all... just got my new HAI OmniPro2 controller going and using PC Access to write some automation.  
 
I have a few "Extended Range Temperature Sensors" ... and want to log the temp values at various times of the day.  I can see in the PC Access automation tab the ability to access the desired TEMP SENSOR (which is connected to a ZONE)... but no simple way to read the CURRENT VALUE of temp!? 
 
I have poked around and maybe the way is to have something like this... but this seems way too many lines of code:
 
WHEN Front Temp SECURE
     AND IF Front Temp CURRENT READING IS 50
          THEN LOG MESSAGE 5   (and then I set MESSAGE 5 to something like 'Front Temp is currently 50 degrees')
 
But this would require many nested IFs, and MESSAGES, one for each temp value !  (e.g. 51 degrees, 52 degrees, 53 degrees, etc).   It would be crazy to have 50 values and MESSAGES.  
 
Isn't there are way to just read the current value and LOG than value directly??
 
Thanks so much... and I have lots of questions on other stuff too.
 
Any help much appreciated!
 
all the best,
Dave
 
Huffman, TX 
 
 
 
 
 
 
Welcome to the CocoonTech forum BirdingPix.  Here today utilize software called Homeseer. 
 
That said it does read the aux temperature sensors on my OmniPro2's.
 
Isn't there are way to just read the current value and LOG than value directly??
 
Yes and no.  Simplest way if you want to tinker is to create a message with a aux temperature reading and read the message via a simple 3 wire serial connection using the Omni pro-link serial mode.
 
You would start with some like you have posted above.   It would be many programming lines.
 
 
If you are in to some tinkering a Cocoontech user has provided some basics to be able to do this via a network connection and you can run it on an RPi2.
 
Have a read over here.
 
Another user has also done this on an Ardunio using a serial port on the OPII.  Have a search and read under the HAI section.
 
You can also do this with OpenHab.
 
All of the above methods though require external device use.
 
@Bob,
 
Found this little bit of code to read the aux temps.  How easy would it be to add this or use this in your example above?
 
Code:
/********************************************************************************/

int do_sensor_stat(hai_comm_id *id, int argc, char *argv[])
{
    aux_stat data;
    int first, last, start, end;
    int err, i;
    int printAll = 0;

    /* Check arguments */
    if (argc > 3)
        return EINVAL;

    /* Setup arguments */
    if (argc > 1 && strcmp_no_case(argv[1], "all") == 0) {
         printAll = 1;
    }
    if (argc == 1 || printAll)
    {
        first = 1;
        last = max_auxs;
    }
    else
    {
        first = atoi(argv[1]);
        if (argc > 2)
            last = atoi(argv[2]);
        else
            last = first;
    }

    /* Check range */
    if ((first < 1) || (last < first) || (last > max_auxs)) {
         printf("error: sensor not in range from 1 to %d\n", max_auxs);
         return EINVAL;
    }

    /* Init loop parms */
    start = first;
    end = start + 25;
    if (end > last)
        end = last;

    /* Loop to get all sensors */
    while(start <= last)
    {
        /* Request aux status */
        if ((err = omni_aux_stat(id, start, end, &data)) != 0)
            return err;

        /* Print aux status */
        for (i = 0; i < (end - start + 1); i++)
        {
            /* Skip ones that are not temp sensors */
            if (data.auxs[i].temp == 0)
                continue;
            /* Skip unnamed */
            if (name_cache_valid && !printAll && (argc == 1) && !is_named(NAMES_ZONE, i + start))
                continue;

            if (!csv)
            {
                printf("%3d : ",  i + start);
                print_name_fixed(stdout, NAMES_ZONE, i + start);
                printf(" : %s\n",  data.auxs[i].status ? "On" : "Off");
                printf("   Temp: %3dF, %5.1fC\n", GETF(data.auxs[i].temp),
                    GETC(data.auxs[i].temp));
                printf("   High: %3dF, %5.1fC\n", GETF(data.auxs[i].high_setpoint),
                    GETC(data.auxs[i].high_setpoint));
                printf("   Low:  %3dF, %5.1fC\n", GETF(data.auxs[i].low_setpoint),
                    GETC(data.auxs[i].low_setpoint));
            }
            else
            {
                printf("%d,",  i + start);
                print_name(stdout, NAMES_ZONE, i + start);
                printf(",%s,",  data.auxs[i].status ? "On" : "Off");
                printf("%d,%.1f,", GETF(data.auxs[i].temp),
                    GETC(data.auxs[i].temp));
                printf("%d,%.1f,", GETF(data.auxs[i].high_setpoint),
                    GETC(data.auxs[i].high_setpoint));
                printf("%d,%.1f\n", GETF(data.auxs[i].low_setpoint),
                    GETC(data.auxs[i].low_setpoint));
            }
        }
        
        /* Next block */
        start = end + 1;
        end = start + 25;
        if (end > last)
           end = last;        
    }

    return 0;
}

/********************************************************************************/
 
It would be really time consuming to modify my "bare bones" project to accomodate the above function.  So, instead, I zipped up a copy of Chuck Cannon's old library which demonstrates all the commands for the OP2 panel.  It is attached but has a TXT file extension since I'm not allowed to upload zip files.
 
You can compile it by using the COMP.BAT file on a windows box.  The HAI.CONF file has to be edited for the correct ip, port etc. and copied to the C:\Windows folder. You'll then have to rename HAI.CONF in C:\Windows to HAI.INI. After  which, you can execute the app and it will allow you to run the various OP2 commands.  The source code will allow you to see how the  above function is implemented in this app.
 
This app uses the UDP protocol and will crash when you attempt to exit.  This is due to the original author incorrectly using a bad socket close statement.  Otherwise, there are no problems with the app.
 
Finally, I'm using the MS command line compiler (CL.EXE) to compile.
 
 
 

Attachments

  • hai-hai.txt
    52.4 KB · Views: 8
Back
Top