Announcement

Collapse
No announcement yet.

New - RainMachine Plug-in

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • New - RainMachine Plug-in

    UPDATE: An updated version of the plug-in has been released to the HomeSeer store and is available through the standard HomeSeer updater. There is also now a dedicated forum for this plug-in. See https://forums.homeseer.com/forum/ir...machine-bpwwer

    The original test version described here, will continue to function but will not be getting bug fixes or updates.


    I have a plug-in for the RainMachine irrigation controllers available for testing.

    Right now, it probably only works with 1st generation hardware since that's what I have. It looks like there may be API differences with newer hardware, but the documentation isn't real clear with exactly what.

    To get/install the plug-in first grab the updater_override.txt file (attached) and place it in your homeseer directory. Then from the manage plug-ins menu in HomeSeer, select the plug-in from the available updates (should be the only one) and download/install it.

    After starting the plug-in, you'll need to go to the plug-in's configuration page and enter the IP address and Password for the RainMachine. Currently, this only supports direct access to the RainMachine. You can also adjust the polling time, the default is 10 seconds.

    The plug-in will create devices for each zone and each program you created on the RainMachine. From HomeSeer, you can see the time remaining on each zone that is currently active and can manually set an immediate run time for each zone. The programs can be started and stopped from the HomeSeer interface.

    There isn't any ability to program the RainMachine in the plug-in. That ability seems somewhat redundant with the programmability built into the device itself.

    Feedback and bug reports welcome.
    --
    Bob Paauwe
    ISYInsteon Plug-in
    http://www.bobsplace.com/ISYInsteon/

  • #2
    Thanks I was looking at getting this Irrigation system. I have the 2gig at the moment but don't like it that much. when i get it i will have to try your plugin. thanks for putting a plugin together on this device.

    Comment


    • #3
      Hi Bob,

      Thanks for deciding to make the plugin for RainMachine. I have a 2nd Generation Touch, and you are correct, this plugin is not working with it.

      From the log:
      Code:
      Jan-15 12:06:01 PM	 	RainMachine	Authentication: The remote server returned an error: (417) Expectation Failed.
      Jan-15 12:06:01 PM	 	RainMachine	APIVersion: The remote server returned an error: (404) Not Found.
      If you can get the plugin to work with Gen1 and Gen2, it would be a great addition to HS3.

      Thanks again.
      Kevin

      Comment


      • #4
        Originally posted by kevins669 View Post
        Hi Bob,

        Thanks for deciding to make the plugin for RainMachine. I have a 2nd Generation Touch, and you are correct, this plugin is not working with it.

        From the log:
        Code:
        Jan-15 12:06:01 PM	 	RainMachine	Authentication: The remote server returned an error: (417) Expectation Failed.
        Jan-15 12:06:01 PM	 	RainMachine	APIVersion: The remote server returned an error: (404) Not Found.
        If you can get the plugin to work with Gen1 and Gen2, it would be a great addition to HS3.

        Thanks again.
        Kevin
        Hi Kevin,

        Thanks for trying it out. Looks like the authentication is one of the areas that's different between the hardware versions. I made some changes for version 3.0.0.1 to try and handle the newer hardware.

        One "trick" that can help when debugging is to turn on developer mode for the plug-ins. It's a checkbox on manage plug-in's page. With that checked, a console window will open for each plug-in when it starts. I do output some additional debugging messages to that window so that will help track down issues.

        With the override file in place, you should see version 3.0.0.1 now.
        --
        Bob Paauwe
        ISYInsteon Plug-in
        http://www.bobsplace.com/ISYInsteon/

        Comment


        • #5
          Originally posted by bpwwer View Post
          Hi Kevin,

          Thanks for trying it out. Looks like the authentication is one of the areas that's different between the hardware versions. I made some changes for version 3.0.0.1 to try and handle the newer hardware.

          One "trick" that can help when debugging is to turn on developer mode for the plug-ins. It's a checkbox on manage plug-in's page. With that checked, a console window will open for each plug-in when it starts. I do output some additional debugging messages to that window so that will help track down issues.

          With the override file in place, you should see version 3.0.0.1 now.
          Bob,

          I just tried the new version, and I get the same two errors in the log. In the developer window, I get the following (I will abbreviate, as I am not at home, and can't copy/paste):

          Code:
          Plugin Connected to HS
          Host API = 3, HS 3.0.0.398 (4)
          RainMachine Connected, waiting to be initialized...
          CONFIG_CHANGE:  Events Saved    type = 1   ddd = 0   dac = 0
          I am glad to test anything you need.

          Thanks!

          Comment


          • #6
            Hmm, I changed the error message for the authentication step so it should have been a bit different.

            First, did you configure the IP address and account info? After the plug-in starts you'll need to go into it's configuration page to set those.

            If you did set that information, then the second error you're seeing is really strange. The error is indicating that the IP address is wrong (or I'm really missing something basic for the newer hardware).

            It should be simply accessing "http://<your RM IP address>/api/4/apiVer"

            You can enter that URL in a browser and should get a response from the RainMachine. If that doesn't work try: "https://<your RM IP:8080/api/4/apiVer"

            The docs show using https and port 8080 so maybe that's another difference.

            Looking at some of the API changes in the docs, I suspect that there are going to be a lot more issues and I may need to actually have to account for the specific API version when parsing the responses from the RainMachine.
            --
            Bob Paauwe
            ISYInsteon Plug-in
            http://www.bobsplace.com/ISYInsteon/

            Comment


            • #7
              Originally posted by bpwwer View Post
              Hmm, I changed the error message for the authentication step so it should have been a bit different.
              Hi Bob,

              My apologies on the message... it is similar, though!

              Code:
              Failed to get responst to authentication request: The remote server returned an error: (417) Expectation Failed.
              I do get the API response, when using port 8080. I do always have to specify the port when logging in locally, so it looks like you would need to add it to the config screen. It is reporting as the current RM API, 4.5.

              I appreciate your hard work on this. I have been really hoping someone would write a simple plugin to at least bring the basics to HS. I know you don't own a Gen 2 model, so anything you do to help does not go without thanks.

              Comment


              • #8
                Originally posted by kevins669 View Post
                Hi Bob,

                I do get the API response, when using port 8080. I do always have to specify the port when logging in locally, so it looks like you would need to add it to the config screen. It is reporting as the current RM API, 4.5.
                Is that with http or https? The docs seem to indicate that https is needed for newer hardware but not with my old hardware.

                You can add the port along with the IP address in the config screen. Just use IP:PORT so something like 192.168.1.1:8080 will work. I can make that more clear on the screen. The port is another difference in the hardware versions, mine doesn't require any port as it's on the standard http port 80.

                If using just http works, you should get a bit farther after adding the port number into the config option. Otherwise I need to all the queries to use (or allow) https since http is currently hard coded.
                --
                Bob Paauwe
                ISYInsteon Plug-in
                http://www.bobsplace.com/ISYInsteon/

                Comment


                • #9
                  It needs HTTPS.

                  Getting more messages in the log, when adding port to the IP:

                  Code:
                  Plugin: RainMachine Instance:  3.0.0.1 starting...
                  RainMachine Connecting to server at 127.0.0.1...
                  RainMachine Connected to HomeSeer at IP address 127.0.0.1
                       Host API version = 3 HomeSeer 3.0.0.398 (4)
                       Callback API version = 3
                  RainMachine Connected, waiting to be initialized...
                  CONFIG_CHANGE: Events Saved  type = 1  ddd = 0  dac = 0
                  CONFIG_CHANGE: Event Trigger Added  type = 1  ddd = 11  dac = 3
                  CONFIG_CHANGE: Event Action Added  type = 1  ddd = 11  dac = 3
                  CONFIG_CHANGE: Group Added=Delayed Actions  type = 2  ddd = 430604794  dac = 1
                  CONFIG_CHANGE: Event Added  type = 1  ddd = 11  dac = 1
                  Unknown save_options = Submit
                  Thanks!

                  Comment


                  • #10
                    Ok, try 3.0.0.2 and see if you get some real (non-error) messages in the log. If the queries work you should get devices created for the zones and programs configured in the RM.

                    I'm not sure yet if I'll need to create separate queries for each API version or not.
                    --
                    Bob Paauwe
                    ISYInsteon Plug-in
                    http://www.bobsplace.com/ISYInsteon/

                    Comment


                    • #11
                      Getting close, Bob!

                      Code:
                      Jan-16 7:21:57 PM	 	RainMachine	Failed to get responst to authentication request: The remote server returned an error: (417) Expectation Failed.
                      Jan-16 7:21:57 PM	 	RainMachine	RainMachine HW version: 3 SW version: 4.0.921 API: 4.5.0
                      Jan-16 7:21:12 PM	 	Plug-In	Finished initializing plug-in RainMachine
                      Jan-16 7:21:12 PM	 	Info	Plugin RainMachine has connected. IP:127.0.0.1:50272
                      Jan-16 7:21:12 PM	 	RainMachine	I have connected to HomeSeer.

                      Comment


                      • #12
                        It took some digging but I think I know what's wrong. The problem I'm having is that I can't reproduce it so I've added a couple of solutions into the code that should resolve it.

                        The problem is that the c# webclient code sees auth and/or login in the URL and adds a special expect-100 header. It seems like the server in the RM does't like that and throws the 417 error response. Neither the older firmware in my RM or even the simulated RM that's available for testing cares and both handle it fine.

                        So I've tried a couple of solutions that are supposed to prevent the webclient code from adding the expect-100 header, but without actually sniffing my network traffic I can't really tell if it worked. Anyway, try version 3.0.0.3 and let me know.
                        --
                        Bob Paauwe
                        ISYInsteon Plug-in
                        http://www.bobsplace.com/ISYInsteon/

                        Comment


                        • #13
                          More progress:

                          Code:
                          Jan-17 4:13:19 PM	 	RainMachine	UpdateProgramInfo: The remote server returned an error: (401) Unauthorized.
                          Jan-17 4:13:19 PM	 	RainMachine	UpdateZoneInfo: The remote server returned an error: (401) Unauthorized.
                          Jan-17 4:12:19 PM	 	RainMachine	UpdateProgramInfo: The remote server returned an error: (401) Unauthorized.
                          Jan-17 4:12:19 PM	 	RainMachine	UpdateZoneInfo: The remote server returned an error: (401) Unauthorized.
                          Jan-17 4:11:19 PM	 	RainMachine	UpdateProgramInfo: The remote server returned an error: (401) Unauthorized.
                          Jan-17 4:11:19 PM	 	RainMachine	UpdateZoneInfo: The remote server returned an error: (401) Unauthorized.
                          Jan-17 4:10:19 PM	 	RainMachine	ISYInsteon Plug-in initialization complete.
                          Jan-17 4:10:19 PM	 	RainMachine	Device record verification complete.
                          Jan-17 4:10:19 PM	 	RainMachine	Verifying HomeSeer device records.
                          Jan-17 4:10:19 PM	 	RainMachine	UpdateProgramInfo: The remote server returned an error: (401) Unauthorized.
                          Jan-17 4:10:19 PM	 	RainMachine	UpdateZoneInfo: The remote server returned an error: (401) Unauthorized.
                          Jan-17 4:10:19 PM	 	RainMachine	Error The remote server returned an error: (401) Unauthorized. while reading https://192.168.1.26:8080/api/4/program?acess_token=XXXX
                          Jan-17 4:10:19 PM	 	RainMachine	Error The remote server returned an error: (401) Unauthorized. while reading https://192.168.1.26:8080/api/4/zone?acess_token=XXXX
                          Jan-17 4:10:19 PM	 	RainMachine	Got response: {"access_token": "XXXX", "checksum": "XXXX", "expires_in": 157680000, "expiration": "Mon, 16 Jan 2023 22:10:19 GMT", "statusCode": 0}
                          Jan-17 4:10:19 PM	 	RainMachine	Attempting to authenticate with https://192.168.1.26:8080/api/4/auth/login
                          Jan-17 4:10:19 PM	 	RainMachine	RainMachine HW version: 3 SW version: 4.0.921 API: 4.5.0
                          Jan-17 4:09:48 PM	 	Warning	Using updater override file: updtater_override.txt for updates!
                          Jan-17 4:09:48 PM	 	Plug-In	Finished initializing plug-in RainMachine
                          Jan-17 4:09:48 PM	 	Info	Plugin RainMachine has connected. IP:127.0.0.1:54559
                          Jan-17 4:09:48 PM	 	RainMachine	I have connected to HomeSeer.
                          I masked the token. Also, when disabling the plugin, the EXE crashes in Windows. It enables fine, afterward.

                          Again, very appreciative for your time, especially with having to have me test.

                          - Kevin

                          Comment


                          • #14
                            It's good that it finally authenticated. But I wasn't really expecting to see all the 401 errors. I'm still not sure that parsing the responses from your RM is going to work but that should generate different errors.

                            Too bad there's not a face palm smiley here. While staring at your log output I noticed that "access_token" was spelled wrong. Not everywhere in the code but most of them were wrong. However, even with the wrong spelling my RM was accepting it. I guess the older API has some bugs.

                            Anyway, I fixed the spelling and I'm expecting that to fix the 401 errors, but at this point, who knows
                            --
                            Bob Paauwe
                            ISYInsteon Plug-in
                            http://www.bobsplace.com/ISYInsteon/

                            Comment


                            • #15
                              Success! It created the Zones and Programs!

                              The Status refresh is a little wonky, as when I click Stop, it does not seem to refresh the status. It does stop in the Android app I was monitoring.

                              Do have this error:

                              Code:
                              Jan-17 6:40:36 PM	 	RainMachine	Error The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. while reading https://192.168.1.26:8080/api/4/zone/1/stop?access_token=XXXX
                              But hey, this is a great start. I can provide feedback on UI and other operations, whenever/if ever you want to. Not sure how in depth you want to get with this. What else can I try? Just let me know.

                              Thanks so much, Bob.

                              Comment

                              Working...
                              X