vanstinator / raincloudy

RainCloudy is a library written in Python 3.x that manages the Melnor RainCloud Smart Garden Watering Irrigation Timer.
Apache License 2.0
24 stars 7 forks source link

Fixes for Melnor changes to wifieaquatimer.com #31

Closed vanstinator closed 5 years ago

vanstinator commented 5 years ago

This PR addresses https://github.com/tchellomello/raincloudy/issues/30. I wanted to run it by you to see what you think. As far as I can tell there was a big deploy sometime recently that changed a few key areas of the site that broke this library.

Firstly the ajax scripts changed. So everything in https://github.com/tchellomello/raincloudy/blob/master/raincloudy/helpers.py#L36 is no longer valid. There's no longer serial number information on the home page so I had to hit the setup page to grab the relevant data. As a plus there that page contains all the data we'd need to support multiple controllers and valves. So I'm hoping to add that feature in a future PR.

Secondly the post call to the status update endpoint doesn't appear to exist or work anymore. In its place the official site is polling a new endpoint with a get request every 15 seconds or so. The response object from this endpoint seems to be plain JSON. This broke the lookup_attr functions in the controller and faucet classes. In their place I just accessed the dict directly and removed the dead functions.

All tests have been updated and are currently passing.

@tchellomello this is ready for your review

vanstinator commented 5 years ago

It's also worth noting I haven't tried to actually manipulate the backend yet either. This is currently only fixes for pulling in data. There may be additional bugs or broken functionality given the scope of the backend changes.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.1%) to 96.124% when pulling 674337aeba3c3cf2bf228a43b35bb5beb9ecf70b on vanstinator:fix-backend-changes into 3bef53ff969ed0fd1255b414bdab9b25057cb052 on tchellomello:master.

vanstinator commented 5 years ago

While updating and fixing the unit tests I realized that the original way I was handling grabbing serial numbers was actually grabbing the name for the controller and faucet. I explored a bit more and found the setup page to be adequate for our needs. So I started piping that page to the serial_finder function and updated the tests accordingly. The setup page will make it easy for me to add support for multiple controllers and faucets in a future PR.

tchellomello commented 5 years ago

Awesome work @vanstinator !! Thanks for your contribution!!