No announcement yet.

Watchdog script with ocelot

This topic is closed.
  • Filter
  • Time
  • Show
Clear All
new posts

    Watchdog script with ocelot

    I am trying to set up my ocelot as a watchdog to reboot my PC if (when) Homeseer stops responding. So far I have a cmax program which will toggle an appliance module off/on if homeseer does not reset a ocelot variable back to 0 in a certain period of time. The cmax script works perfectly, the problem is I can not get an event in homeseer to automatically set the ocelot variable to 0 whenever it sees that it is 1. I can get an event to set the variable when it changes to 1, but once this change is missed (say upon startup), homeseer will ignore the variable. Has anyone got such a setup to work correctly?

    HomeSeer Status

    My setup has an event that watches the Ocelot variable and resets it to 1 when it reaches 550. If it continues to 700, then the CMAX program will force the reset.


    I Pledge Allegiance to the flag of the United States of America and to the Republic for which it stands, one Nation under God, indivisible, with liberty and justice for all.
    The REAL Pledge of Allegiance


      just use a recurring event say every 5 minutes and set the variable value to 0. It doesnt have to see the 1 as long as you keep resetting the timer. I use this script for a watchdog to toggle a dpdt relay. One set of contacts is for the reset and one set for the power button. As long as you set your power off to 4 seconds in the bios, you wont shut down the pc if homeseer quits, but the power is still on.
      If timer 0=0 ~pwr fail timer resets
      or variable 0=2 ~heartbeat resets

      Then timer 0=1 ~reset timer & variable
      Then variable 0=0 ~Start counting seconds

      If timer 0=750 ~close relay, restart
      then mod 2/8 set on computer at 12.5 min.
      If timer 0=752 ~relay on for 2 seconds
      Then mod 2/8 set off

      Then timer 0=1 ~reset timer & variable
      Then variable 0=0
      then create an event in Hs that runs every 6 minutes and sets the variable 0 to 2.

      btw my machine wont power up on pwr failure and it will restart 12.5 minutes after the power is restored.


        I was wondering if this could be a problem:
        What if you shut down HomeSeer to work in CMAX.
        Ocelot never sees the "ping" from HomeSeer, so shuts down the PC. You loose your work.

        Possible work around: Create a variable to send to Ocelot to tell it you have closed HomeSeer and don't try to shut down the PC. When you start HomeSeer, you tell Ocelot that HomeSeer is up, so run the Watchdog. (What if you don't like Watchdogs? Can you have a WatchCat? )




          Youre right. you could always use the startup and shutdown script in Hs to change the variable to another number which cmax would then disregard.


            I am using two variables in the script - one is the actual variable that is watched, another is an "enable" variable, which is set to 0 when a reset happens, then set to 1 in the HS startup script. I can also set it to 0 when I want to work on something, so that the PC does not get rebooted. The ocelot will not cycle the power unless the enable variable is set to 1

            HomeSeer Status


              would you be willing to share your watchdog (I like watchcat)script? Based on what you said it's exactly what I was looking for.
              BTW - your WEB looks GREAT. What program did you use to create your floor plan? It looks cool!



                One of the first CMAX sequences I wrote. In a development environment I have HS up and down all the time so I really never enable it.

                <pre class="ip-ubbcode-code-pre">

                ‘Logic for WDT function
                ‘HS sets Variable 10 within 15 minute window
                ‘If not reset then ocelot runs B7 off 5 times and
                Variable #9 set to 0 to disable WDT function
                If Variable#9 = 0
                Then Timer#10 = 0
                If Variable#10 = 0
                Then Timer#10 = 1
                Then Variable#10 = 1
                If Timer#10 &gt;910 Then
                Timer#10 = 0
                If Timer#10&gt;905
                AND Timer#11 becomes &gt; 1
                Then Quick On X10 B/7 On
                Then Timer#11 = 1
                If Timer #10 &gt;900
                AND Timer#10 &lt;906
                AND Timer#11 becomes &gt; 1
                Then Quick Off X10 B/7 Off
                Then Timer#11 = 1
                If Timer#10 becomes &gt; 900
                Then Timer#11 = 1



                  What about the opossite site - the HS script?
                  I assume you have to have one script in OCELOT (CMAX) and one in HS. Correct??



                    It is simply a periodic event every 5 minutes to set ocelot variable 10 = 0. The ocelot, when it does not see it for 15 minutes will cycle power on appliance module into which the computer is plugged.

                    I actually run Guardian Angel, which is in the script library, to do my Watchdog function. It runs as a real-time process and monitors CPU utilization of a process or all processes. It will restart the offending process or reboot the PC in a contolled manner. I believe I have it setup for 95% utilization for 5 minutes. The advantage here is that it gives each running process a chance to exit gracefully while a hard power reset could leave the PC disk in an indeterminate state.

                    My intent was to run both so it would first do a soft restart before a hard one. Like I said before, I have not actually run the ocelot WDT after it was intially done because my HS machine is up and down all the time with development activities and I did not want to be bothered with remembering to set the override.


                      I attached my script, I can't find an easy way to save it as text.

                      I use two ocelot variables, they get set in
                      'start watchdog enable
                      hs.SetDeviceValue "[2", 0
                      hs.SetDeviceValue "[3", 1

                      The I have an event called "Pet Watchdog" that runs every 5 minutes That sets the Watchdog monitor variable to off.

                      It has run for 2 or 3 months now with no problems. Of course, like my cable modem reset script, ever since I started running it I have had not had any problems that need to fire a reset.

                      I made the room diagrams with Visio.

                      HomeSeer Status
                      Attached Files


                        Now when you mention the modem reset..
                        What kind of script are you using? I made one but I'm not too happy with it. I do have sattelite broadband and that darned modem needs reset at least 2-3 times a day.
                        Can you post it?

                        I use your Guardian Angel and it working fine, but sometimeses the HS gets hang with processor staying at low treshold.
                        For example lately my HS gets hang (from time to time when ATT voice is activated and HS is speaking. I didn't figure why yet.


                          If you are interested I should be able to add a method to interact with homeseer so that if it does not respond in the timeout interval then the same actions will be taken as if the CPU was pegged. Same concept as the external watchdog, but using a real-time process rather than something external.

                          If I have it create an instance of homeseer, check a device or global variable, and then destroy that instance if will be able to see if homeseer is updating it. My concern is that creating an instance of homeseer in a real-time process may be chancy.

                          If I go the other route then Guardian Angel needs to become an ActiveX with a WDT method that can be called by homeseer. This is a more general case where any application can use it.

                          Other handshakes such as using the file system with guarding angel deleting a file and homeseer or other application creating it periodically.


                            Called every 15 minutes - My cable modem is plugged into an x10 appliance module

                            The "cycle Cmodem" event turns the x10 module off for 30 seconds, then turns it back on I suppose I could do that right in the script, but I was not as fluent in scripting when I wrote this


                            sub checkcmodem()
                            dim page
                            dim iBytes

                            'ping yahoo
                            on error resume next
                            page = hs.GetURLIE("", False)
                            iBytes = len(page)
                            'hs.writelog "yahoo",cstr(iBytes)

                            if iBytes &lt; 10 then
                            hs.writelog "Error", "Unable to ping yahoo"
                            'yahoo is no good try
                            page = hs.GetURLIE("", False)
                            iBytes = len(page)
                            'hs.writelog "",cstr(iBytes)
                            if iBytes &lt; 10 then
                            'neither is good, reboot cable modem
                            hs.TriggerEvent "Cycle cmodem"
                            end if
                            end if

                            end sub

                            HomeSeer Status


                              <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Originally posted by Stuart:
                              I use this script for a watchdog to toggle a dpdt relay. One set of contacts is for the reset and one set for the power button. As long as you set your power off to 4 seconds in the bios, you wont shut down the pc if homeseer quits, but the power is still on.<HR></BLOCKQUOTE>

                              Stuart, exactly what dpdt relay are you using (maybe a part number or web link)?
                              Hardware: i5-6400T w/16GB RAM & SSD w/HS3Pro, Z-Net, Harmony Hub x2, Echo Dot x2, Ocelot
                              Plugins: Z-wave, HSTouch, BLBackup, Harmony, GTS CPUXA, UltraMon3, Nest
                              HSTouch: Multiple Android Devices; 5 x ToteVision MD-1001 10.1" Win 7 Tablets
                              Devices: Cooper RF9501 x4, RF9517 x6, RF9534 x1, RF9540-N x7, RF9542 x1, RF9542-Z x2, RFHDSCG x1, RFWC5 x5; Intermatic HA02 x6; FortrezZ MIMOLite x3; Leviton VRPD3-1LW x4, VRR15-1LZ x6; Nest Tstat & 9x Protects; Dragon PD-100 x3, PA-100 x3