Announcement

Collapse
No announcement yet.

How To Poll Z-Wave Thermostat?

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

  • joshljoshl
    replied
    Originally posted by MarkHargrove View Post
    I'll have to do some more testing to make sure this approach works consistently, but this might be a workaround until I have time to test hs.PollDevice() with a clean HS installation.
    Hey Mark, I'm having this same issue and ran across this thread. Your solution of pragmatically hitting the plugin refresh button appears to be the best bet, just curious if it's still working reliably this way or if you've switched to some other method?

    I just started using Homeseer and am a complete scripting newbie - using the search function now, but if you could provide any tips as to what other lines need to be in my poll_therm.vb file in addition to your code snippet, I would be most appreciative!

    Thanks!

    Leave a comment:


  • reidfo
    replied
    Solved (I Think)

    I have been stumped by this same problem for a while with my 2gig thermostats. I *just* noticed that there's an option in the device configuration to poll the thermostat.

    Poll device for status every # seconds (0=no poll):

    I set that and now it appears my thermostats are updating properly. Now when I go to the ZWave Thermostats page they show the correct temperature without me having to manually click the update button.

    Leave a comment:


  • BrianNH
    Guest replied
    I have the same problem with the 2Gig thermostats. Bought three of them a few months ago and they setup easily. But they do not auto poll and update Homeseer with temp changes. Which makes them very unreliable thermostats. If I hit poll devices or update them manually as mentioned above it, they update just fine.

    Has this been fixed yet? Running version "Professional Edition 2.5.0.20"

    Leave a comment:


  • rmasonjr
    replied
    cool! Thanks for sharing the code!

    Leave a comment:


  • MarkHargrove
    replied
    Other than a suspicion that my HS installation is somehow damaged, I've not been able to figure out how to make hs.PollDevice(...) work. I'm told that hs.PollDevice() will NOT generate the logging data we're seeing when Z-Wave logging the for the plugin is enabled, but that it "takes a while" and that I might have to poll multiple times before I see a result. I tried a variety of delays, a multiple number of polls (with various delays between them) and a large amount of patience -- none of which worked. The status for my thermostats never updated unless I clicked the 'update' button on the thermostat status page.

    It's possible that my HS installation is indeed damaged in some way; it's years old. Just before I started to stand up a new server with a fresh installation of HS to verify if that was my problem or not, I had one of those "now wait just a second" thoughts:

    If the 'update' button always generates a poll, then why I don't just programmaticly "click" the button when I need HS to poll the thermostats?

    By examining the page source of the ZWStat_status page, I see that the 'update' button is simply setting a few form fields, a couple of which are type 'HIDDEN', and then doing an HTTP POST right back to itself. Well, OK -- I can do that in code:

    Code:
    private void pollThermostat(int thermostatNo)
    {
        WebRequest req = WebRequest.Create("http://<hostname>/ZWStat_status");
        string postData = "Therm1=&ref_page=ZWStat_status&poll=Update&LabelNumber=" 
                             + thermostatNo.ToString();
    
        byte[] send = Encoding.Default.GetBytes(postData);
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.ContentLength = send.Length;
    
        Stream sout = req.GetRequestStream();
        sout.Write(send, 0, send.Length);
        sout.Flush();
        sout.Close();
    }
    When I execute this code within my button_click event, I see exactly the same debug output as if I'd clicked the button manually -- and the thermostat status updates within a few seconds!

    I'll have to do some more testing to make sure this approach works consistently, but this might be a workaround until I have time to test hs.PollDevice() with a clean HS installation.

    Leave a comment:


  • rmasonjr
    replied
    I enabled logging and saw the same thing you did - the "update" button on the ZWave Thermostats page did a lot more than just a hs.PollDevice() - strange...

    Leave a comment:


  • MarkHargrove
    replied
    I'm also working this problem in the paid support forum. RJH is insisting that hs.PollDevice("devicecode") works. He's tested in on multiple systems against multiple thermostats. I believe him -- it just doesn't work on my system.

    I don't know whether my HSPro license allows me to set up another HS Server on a separate box so I can test just this one thing there -- it must be something screwed up with my libraries, or something related to my installation. I've asked RJH about the licensing issue but if anybody here knows the answer (about being able to set up a test server), I'd love to know. My "production" system has been kept updated, and is currently up to date, but its otherwise my original installation from many years ago with the usual large collections of plugins, etc. Maybe it's time for a fresh start.

    Leave a comment:


  • rmasonjr
    replied
    I suspect that the poll inside the Plugin is doing some more granular "Gets" on the individual properties of the thermostats; temp, setpoints, hold status, etc.
    A vanilla hs.pollDevice() might just be returning the ZWave capabilities?

    Inside the ZWave Thermostats DLL, there is a method called "ForcePoll()" but It does not appear to be exposed so that you can call it in a script.

    So, the only options I see are: create a standalone script that mimics what the web page is doing. A view/source on that page shows the update button sending up to a <form> as Therm1. You might be able to trick HS into thinking that the button sent the request to poll.

    The only other option is to open a feature request to have that plugin expose it's own "poll" method so it is accessible via scripting.

    Leave a comment:


  • MarkHargrove
    replied
    I'm running 2.5.0.23.

    I'm pulling my hair out on this one. There clearly IS a way to poll, because the 'update' button on ZWave Thermostats Status page issues a poll that I can see in the log (with debugging turned on). No such poll results from a call to hs.PollDevice('xx') on my system.

    -M.

    Leave a comment:


  • Rupp
    replied
    What version of HomeSeer are you running? There was an issue with an older version of HS where this was not working.

    Leave a comment:


  • MarkHargrove
    replied
    I did see that post, but the method doesn't work from an application -- it doesn't appear to do anything.

    A snippet from my code looks like this:

    Code:
    Scheduler.HSPI_ZWAVETHERM.HSPI pi = (Scheduler.HSPI_ZWAVETHERM.HSPI)hs.Plugin("ZWave Thermostats");
    hs.PollDevice("q13");
    hs.PollDevice("q16");
    double upTemp = pi.GetTemp(2);
    double downTemp = pi.GetTemp(1);
    int mode1 = pi.GetModeSet(1);
    int mode2 = pi.GetModeSet(2);
    int currMode1 = pi.GetCurrentMode(1);
    int currMode2 = pi.GetCurrentMode(2);
    bool operating1 = pi.GetOperating(1);         
    bool operating2 = pi.GetOperating(2);
    ...where q13 and q16 are the Z-Wave root devices for my two thermostats. The values retrieved are valid (in the sense that they are reasonable values), but they do not usually reflect the current state of the thermostat. Temperatures reported are inaccurate, current operating mode reported is inaccurate, etc.

    If I visit the HomeSeer web page named 'ZWave Thermostats Status' the individual thermostats reflect the same (usually) inaccurate status values.

    When I click the 'Update' button on each individual thermostat, the web page clearly is performing a poll, because the thermostat status values on the web page update to reflect the correct values from the tstat (and, as it happens, so does my application the next time it runs the code above).

    It's clear to me that my code is getting "good" values from HomeSeer as it believes them to be at time my code runs -- the problem is that HS itself is out of date with respect to the thermostats themselves.

    I've noticed on the configuration screen for the two zwave tstats that the polling interval is set to zero (which apparently means "do not poll"). I thought that perhaps that was the culprit, and changed it to 30 seconds -- but that appears to have no effect. Neither the web page nor my application shows any state change after the polling interval has elapsed.

    Obviously, there is a polling method -- it clearly gets executed whenever we click on the 'Update' button for a zwave thermostat on the zwave thermostats status page. I just don't understand the correct way to invoke it yet!

    Leave a comment:


  • rmasonjr
    replied
    I thought that hs.PollDevice would update the mode and any other status fields for a device.
    In this example, Macromark says to use PollDevice for HSTouch:
    http://board.homeseer.com/showthread...ght=thermostat

    Leave a comment:


  • MarkHargrove
    started a topic How To Poll Z-Wave Thermostat?

    How To Poll Z-Wave Thermostat?

    From an external application (in this case, C# project), how do I poll a z-wave thermostat to update it's status?

    Calling hs.PollDevice("xx") where xx is my z-wave thermostat root device doesn't change the status values I get back after doing a GetCurrentMode(...) method call from the plugin object.

    From the web interface (under the ZWave Thermostat Status button), the status showed there is also wrong/out of date -- until I click the little 'Update' button. At that point the correct status is displayed on the web page and also in my application. The web page button seems to be attached to something called ZWStat_status -- but I cannot figure where/what that is.

    What is the correct way to ask HS to poll a Z-wave tstat for up-to-date status values from a script or application using the hs APIs?
Working...
X