[OBSOLETE] RainMachine

I finally sat down and figured out why this integration was only working like 10% of the time for me. There seems to be a bug in the code where it’s resetting the access_token even when no token is returned in the login response. The API’s response if you login when your token is still good is to simply return “Success” with no token in the body. When this happens, the smartapp grabs that null token and uses it for future calls, obviously without success.

Normally, the app should only try and grab a new token once the old one has expired, but if anything happens where that timing gets off, it ends up trying to grab one before the API will hand one out. I’ve fixed it on my end with a simple check to make sure a token exists before clearing out whatever is stored and will get it pushed to my repo probably sometime tomorrow (for anyone else who actually still cares about this one :smile: ) I’m just glad I can rely on SmartThings now to act as my history for when my programs actually run!

3 Likes

@brbeaird. I still care :slight_smile: would love to give it a try

I think there was a bug with the “state” as well, I actually started to rewrite this a while ago, but then I got really busy. So this got abandoned. Glad that you’re keeping this alive and working :smile:

@dfairbro1 - here ya go! Link to my fixed version:

Glad I can help! Eventually I may try to write it as a LAN-connected app. Seems like a fun exercise. I’m probably stuck with this thing for awhile, so I might as well make the most of it.

In the future, I’m planning on maintaining this in the brbeaird_dev branch of my forked copy of the SmartThingsPublic repo:

SmartApp: https://github.com/brbeaird/SmartThingsPublic/tree/brbeaird_dev/smartapps/copy-ninja/rainmachine.src

DeviceType: https://github.com/brbeaird/SmartThingsPublic/tree/brbeaird_dev/devicetypes/copy-ninja/rainmachine.src

This is fantastic. I have it working, however is there a way to modify the device type so it’s also a switch? Not just a valve? I’m trying to maybe have a motion sensor activate a zone. Also trying to get Alexa to run the watering program. Apps don’t seem to see valves… Maybe I’m doing something wrong?

Yeah I’ve noticed that, too. It’s on my list to take a shot at getting them also recognized as switches as the SmartThings “valve” capability it a bit more limited. A switch would definitely open up a lot more possibilities. I’ll let you know if I have any success.

Well I hacked together an app that will allow a swith to control a valve. This works great with a virtual switch and Alexa or a motion sensor… Only problem is when the valve times out (watering done) the virtual swith is still on… I was trying to hack together an app that would turn a switch off when the valve turned off. I’m no programmer and just can’t figure that part out. If the device type could be switches instead of valves it would be much cleaner. I hope you have success :slight_smile:

Ok hacked an app to turn switch back off when valve turns off. This is now working great. Just finished making this work with Amazon Echo.

“Alexa, tell the house to switch zone 5 on.”

Never thought why i would want smartthings to control my sprinkler system since rainmachine does a great job by itself. But ill admit turning on your sprinklers using voice is kind of cool.

1 Like

Hey Jason,

Thank you again for the excellent App/device. I saw this in my log recently - and its coming off the RainMachine. Have you seen this?

8a3a93b1-6d51-4725-8eba-87603f9b2fcf 8:33:03 AM: error groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.lang.Long#plus.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[class java.lang.Character]
[class java.lang.String]
[class java.lang.Number] @ line 195

It looks like it’s the response from your RainMachine device.

state.auth.expires_in = now() + response.data.expires_in

Just replace the response.data.expires_in with some random number. Last I checked, I don’t think the token provided by RainMachine ever expires.

Yeah, I think @copyninja is right. I’ve gotten that in the past. I think the token may expire eventually, but more often than not you end up just reusing the session for a long time.

I made some slight changes that seem to have fixed it for me. Link to the code is below:

1 Like

Thanks for the contribution. For those with the 2013 model, if you ask sales at RainMachine, they may give you a $100 coupon off a HD12 if you give them a order number for your 2013 model as proof of purchase.

I was about to go with Rachio, but I really like having the touchscreen. I emailed them asking if I could get any sort of “trade-up” discount, and they obliged with a $100 coupon.

I don’t think it’s an official program or anything, but if you just ask nicely, sometimes you get what you’re looking for :smile:

I’ve not been able to get this app installed on my V2 hub.

groovy.lang.MissingMethodException: No signature of method: script1443456870790195093110.parse() is applicable for argument types: (java.lang.String) values: [updated]
Possible solutions: pages(), pause(java.lang.Object), page(), pages(groovy.lang.Closure), page(java.util.Map), page(java.lang.String, java.lang.String)

It’s blowing up on this line (around 145)
addChildDevice(“copy-ninja”, “RainMachine”, dni, null, childDeviceAttrib)

If I comment that out, it finishes the installation. Not sure what’s going on with it. I thought it might be an issue with sending null for hub ID, but I’ve tried putting in the actual hub id, and that doesn’t change anything. The MyQ app installed without issue, though, and it uses the same method. Very confused here.

I’m now receiving this error

CDT: error groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.lang.Long#plus.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[class java.lang.Character]
[class java.lang.String]
[class java.lang.Number] @ line 207
801f5404-3969-4017-b513-5a07ca3883ae 7:55:04 AM

Any thoughts as to what’s causing this ?

Check out copyninja’s and my posts a few entries above. It’s likely an issue with the authentication response. You can either try copyninja’s suggestion to switch out the “response.data.expires_in” text or else use the code I linked for a slightly different way to fix it.

I’ve been using your code for a month. Just started throwing this error.

Boo. Well, mine has also been throwing an error since I moved to V2. I just haven’t been motivated enough to debug it. I’ll see what I can do.

Thanks for taking a look at this !!!

Did some more looking today…no luck so far in figuring out what is actually happening. I know it’s still connecting and pulling the programs and zones correctly. But when it tries to actually add them as devices in SmartThings, it blows up with that generic error message. I’ll keep at it.

1 Like

Thank you for looking at this