bdwilson / raincloudy-flask

Python Flask API version of Melnor Raincloud Access

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raincloudy Flask API

This flask API uses the raincloudy python library.

I am not a Python programmer; this is really bad code. Please fix it. There is no authentication because the expectation is that you're running this on your internal, trusted home network. You've been warned.

WARNING: I only have 1 controller & 1 faucet, so while this should work for multiples of each, it has not been tested.

Installation (manual)

  1. Install raincloudy, flask, flask-jsonpify, json
# pip3 install raincloudy
# pip3 install flask
# pip3 install flask-jsonpify
# pip3 install json
  1. Change the EMAIL/PASSWORD/PORT variables in the raincloudy_flask.py. My port in the example is 5059.
  2. Change directory in the .service file to match where your raincloudy_flask.py file is.
  3. Copy service file to /lib/systemd/system/ then enable it.
# systemctl daemon-reload
# systemctl enable raincloudy.service
# systemctl start raincloudy.service 

Installation (Docker)

  1. Grab the Dockerfile via wget and put it in a directory on your Docker server. Then run the commands below from that directory
  2. # docker build -t raincloudy-flask --build-arg EMAIL='your@email.address' --build-arg PASSWORD='your_password' . CTRL-C out of it when it's complete. PORT is optional and will default to 5059
  3. Run your newly created image: # docker run --restart unless-stopped -p 5059:5059 -e CURL_CA_BUNDLE="" --name raincloudy-flask -t raincloudy-flask (if you changed the port when you built your image, you should also change it here)
  4. That's it. If you need to troubleshoot your docker image, you can get into it via: # docker exec -it raincloudy-flask /bin/bash or # docker run -it raincloudy-flask /bin/bash and then poke around.

Usage

# curl -s http://yourip:5059/api/status 
# curl -s http://yourip:5059/api/[controllerid|status]/[faucetid]/[open|close|auto|rain/[zone#]/[time in mins/0/1]

Hubitat

See here.

Troubleshooting

  1. Your controller id and faucets should be listed when you start the image/script:
Controller: d88039xxxxx  Status: Online
> Faucet: xxxx  Status: Online
 * Serving Flask app "raincloudy_flask" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:5059/ (Press CTRL+C to quit)
  1. Test this inside, not hooked up before running in production. You can easily hear the valves open and close.

Bugs/Contact Info

Bug me on Twitter at @brianwilson or email me here.

About

Python Flask API version of Melnor Raincloud Access


Languages

Language:Python 88.1%Language:Dockerfile 11.9%