Giter Site home page Giter Site logo

vanstinator / raincloudy Goto Github PK

View Code? Open in Web Editor NEW
24.0 9.0 7.0 138 KB

RainCloudy is a library written in Python 3.x that manages the Melnor RainCloud Smart Garden Watering Irrigation Timer.

License: Apache License 2.0

Python 100.00%
home-automation watering watering-plants raincloud melnor sprinkler-controller irrigation irrigation-controller

raincloudy's Introduction

RainCloudy

https://travis-ci.org/vanstinator/raincloudy.svg?branch=master https://coveralls.io/repos/github/vanstinator/raincloudy/badge.svg?branch=master

RainCloudy is a library written in Python 3.x that manages the Melnor RainCloud Smart Garden Watering Irrigation Timer.

Currently Melnor WifiAquaTimer not provide an official API. The results of this project are merely from reverse engineering. This project does not have any official relationship or support by Melnor.com. Use it at your own risk.

Melnor RainCloud official page: http://www.melnor.com/16043-raincloud-smart-water-timer

Source code documentation: http://raincloudy.readthedocs.io/

Usage

from raincloudy.core import RainCloudy
raincloudy = RainCloudy('username@domain', 'secret')

# list controllers linked with account
raincloudy.controllers
[<RainCloudyController: control_unit:abdcd1234 valve_unit:a123>]

# show valve unit battery status
raincloudy.controller.faucet_battery
99%

# show status
raincloudy.controller.status
'Online'

raincloudy.controller.name
'MelnorC001'

raincloudy.controller.faucet.name
'Backyard'

raincloudy.controller.faucet.status
'Online'

# 4 zones controlled per faucet
len(raincloudy.controller.faucet.zones)
4

# show details from zone1
raincloudy.controller.faucet.zone1
{
 'auto_watering': True,
 'manual_watering': False
 'next_cycle': 'Delayed',
 'rain_delay': 1,
 'watering_time': 0
 }

 # update attributes and show all zones
 raincloudy.controller.update()
 raincloudy.controller.faucet.zones
 {
    'zone1': {
        'auto_watering': True,
        'droplet': 'https://wifiaquatimer.com/static/images/blank.gif',
        'is_watering': False,
        'next_cycle': 'Delayed',
        'name': 'Backyard Flowers',
        'rain_delay': 1,
        'watering_time': 0
    },
    'zone2': {
        'auto_watering': True,
        'droplet': 'https://wifiaquatimer.com/static/images/blank.gif',
        'is_watering': False,
        'next_cycle': 'Delayed',
        'name': 'Tree Patio',
        'rain_delay': 2,
        'watering_time': 0
    },
    'zone3': {
        'auto_watering': True,
        'droplet': 'https://wifiaquatimer.com/static/images/blank.gif',
        'is_watering': False,
        'next_cycle': '3:17 AM',
        'name': 'Grass Backyard',
        'rain_delay': 0,
        'watering_time': 0
    },
    'zone4': {
        'auto_watering': True,
        'droplet': 'https://wifiaquatimer.com/static/images/blank.gif',
        'is_watering': False,
        'next_cycle': '4:00 AM',
        'name': 'Grass Front yard',
        'rain_delay': 0,
        'watering_time': 0
    }
}


# set faucet name
raincloudy.controller.faucet.name = 'Outside Left'
raincloudy.controller.faucet.name
'Outside Left'

# enable automatic program for zone1
raincloudy.controller.faucet.zone1.auto_watering = True

# run water for 15 minutes on zone3
raincloudy.controller.faucet.zone3.manual_watering = 15

# set rain delay for 2 days on zone2
raincloudy.controller.faucet.zone2.rain_delay = 2

Current Limitations

  • Only 1 (one) controller is supported.
  • Only 1 (one) valve unit is supported.

raincloudy's People

Contributors

eavanvalkenburg avatar fabaff avatar renovate[bot] avatar tchellomello avatar vanstinator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raincloudy's Issues

New error: raincloudy.exceptions.RainCloudyException

Apparently melnor made a change which appears to have broken the code. I now get an exception, with the exact date when the error first occurred:

Exception occured: <class 'requests.exceptions.ConnectionError'> at Mon May 21 02:33:21 GMT 2019

Accessing objects if we only have a single controller/valve

Hi, I'm trying to use this code with a single device and having issues. This used to work:

raincloudy = RainCloudy(config['email'], config['password'])
controller = raincloudy.controller.status
battery=raincloudy.controller.faucet.battery

I get this:
AttributeError: 'RainCloudy' object has no attribute 'controller'

If I need to be addressing these objects differently for a single device/faucet, let me know - perhaps the docs could be updated to show how to address multiple vs. single controllers/faucets.

Thank you for picking this code back up!

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

This repository currently has no open or pending branches.


  • Check this box to trigger a request for Renovate to run again on this repository

Homebridge support

I've been following this since i got my raincloud earlier this year. I was wondering if there's any effort going on to move to support homebridge and iOS. I believe that would require re-writing in JS though so it could be a fair amount of effort.

breaking down the reverse-eng, for http requests

Hey @tchellomello, this is really great work with the reverse engineering.

I've never developed with Python, or groovy, or Java, so I'm totally out of luck for trying to use your library.

I see that you're using http for the communication to the controller. I'm wondering if there's any way to break it down even further so that the valves could be opened and closed with a simple HTTP request?

I'm thinking that could be a way to use that with homebridge to create a water controller device type or, at the very least, a switch.

raincloud in hass has stopped working

any ideas on this? still works with the android app and from the web site. just can't get it to work in hass.

Thu Jul 12 2018 20:08:31 GMT-0400 (Eastern Daylight Time)

Error during setup of component raincloud
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/raincloudy/helpers.py", line 33, in serial_finder
    text=re.compile('controller_serial'))[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 146, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/raincloud.py", line 101, in setup
    raincloud = RainCloudy(username=username, password=password)
  File "/srv/homeassistant/lib/python3.5/site-packages/raincloudy/core.py", line 59, in __init__
    self.login()
  File "/srv/homeassistant/lib/python3.5/site-packages/raincloudy/core.py", line 68, in login
    self._authenticate()
  File "/srv/homeassistant/lib/python3.5/site-packages/raincloudy/core.py", line 99, in _authenticate
    parsed_controller = serial_finder(self.html['home'])
  File "/srv/homeassistant/lib/python3.5/site-packages/raincloudy/helpers.py", line 48, in serial_finder
    'Could not find any valid controller or faucet')
raincloudy.exceptions.RainCloudyException: Could not find any valid controller or faucet

Control Unit offline more frequently

Hey all,

I'm trying to pin this down.

Since I installed this new Repo and re-added my second valve to the controller, the controller is frequently going offline, and I have to pull the plug to re-connect it.

I can't see anything in any logs that points to this plugin, but the correlation can't just be a coincidence.

Is anyone else seeing this with theirs?

Certificate error

I got this error in login:

SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

Then I manually added wifiaquatimer_com_chain.cer to a file, ca-bundle.crt, my CA store in Windows and its path to pip.ini. Still same error. Thank you for the help!

Raincloud errors: Error doing job: Future exception was never retrieved.

Hello,
Recently my log file gets flooded with following error although raincloud sensors and switches seem to be working fine on hassio's dashboard.
Is there anything I can do to fix this?
Thanks a lot!

Log Details (ERROR)
Sun Jun 03 2018 18:26:25 GMT-0400 (Eastern Daylight Time)

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/python3.6/site-packages/homeassistant/components/raincloud.py", line 118, in hub_refresh
hass.data[DATA_RAINCLOUD].data.update()
File "/usr/lib/python3.6/site-packages/raincloudy/core.py", line 119, in update
self.controller.update()
File "/usr/lib/python3.6/site-packages/raincloudy/controller.py", line 126, in update
self._get_cu_and_fu_status()
File "/usr/lib/python3.6/site-packages/raincloudy/controller.py", line 104, in _get_cu_and_fu_status
req.raise_for_status()
File "/usr/lib/python3.6/site-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: OK for url: https://wifiaquatimer.com/dajaxice/webserver.get_cu_and_fu_status/

Examples in Usage Not Working

The examples at the bottom of the usage portion of readme are not working. The syntax used in the examples has an underscore rather than a dot after the zone identifier:
raincloudy.controller.faucet.zone2_watering_time = 5
when it should be:
raincloudy.controller.faucet.zone2.watering_time = 5

Turning off manual watering that was triggered from device doesn't work

If you toggle a manual watering session from the hose adapter itself you can't actually turn it off from this library. I think it's technically a Melnor quirk with the web platform. If you load the web UI the dropdown box for the active watering zone is off. The only way to use the UI to turn this state back off is to pick an arbitrary time from the selector and then turn the zone back off. We can probably mimic this behavior ourselves to make the API handle this transparently.

Support second valve and second controller

The integration with Home Assistant and a single valve controller is working great, but I'd love to have my second valve controller be integrated as well. I need more than four zones, so I picked up an extra valve controller.

I see there was a request made over in the Home Assistant community forum. I'd be happy to help beta test as well if needed.

Thanks!

Doesn't build in `python >= 3.12` due to `imp` dependency

============================= test session starts ==============================
platform linux -- Python 3.12.3, pytest-8.1.1, pluggy-1.4.0
rootdir: /build/source
configfile: setup.cfg
testpaths: tests
plugins: asyncio-0.23.6, aiohttp-1.0.5, requests-mock-1.12.1
asyncio: mode=Mode.STRICT
collected 13 items / 9 errors / 3 deselected / 10 selected

==================================== ERRORS ====================================
_____________________ ERROR collecting tests/test_base.py ______________________
ImportError while importing test module '/build/source/tests/test_base.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/nix/store/73fmjgr5khqi62zmpjhjkmggyra0sxmq-python3-3.12.3/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_base.py:3: in <module>
    import imp
E   ModuleNotFoundError: No module named 'imp'
__________________ ERROR collecting tests/test_controller.py ___________________
ImportError while importing test module '/build/source/tests/test_controller.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/nix/store/73fmjgr5khqi62zmpjhjkmggyra0sxmq-python3-3.12.3/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_controller.py:4: in <module>
    from tests.test_base import UnitTestBase
tests/test_base.py:3: in <module>
    import imp
E   ModuleNotFoundError: No module named 'imp'
...

AttributeError

I am setting up a script in a server to notify me the status of the controller. The following is the beginning of the program:

#!/usr/bin/python3

import time
import smtplib, ssl
import os
import sys

from raincloudy.core import RainCloudy
raincloudy = RainCloudy(my_email, my_password)
status = raincloudy.controller.faucet.status
battery = raincloudy.controller.faucet.battery

I first did this in Windows, Python 3.8.3 and it ran without any issue. Then, I tested it in Ubuntu 20.04 LTS on a Raspberry Pi, Python 3.8.2 but got the error:

raincloudy.controllers
[<RainCloudyController: 5*********>]
status=raincloudy.controller.faucet.status
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'RainCloudy' object has no attribute 'controller'
battery=raincloudy.controller.faucet.status
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'RainCloudy' object has no attribute 'controller'

If controller is online, faucet battery return an empty string instead None

Description:
If controller is online, faucet battery return an empty string instead None

Traceback:

2017-10-08 03:27:13 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/opt/srv/homeassistant/.virtualenvs/hass-py36/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/opt/srv/homeassistant/.virtualenvs/hass-py36/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 238, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/opt/srv/homeassistant/.virtualenvs/hass-py36/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 245, in async_update_ha_state
    self._attr_setter('icon', str, ATTR_ICON, attr)
  File "/opt/srv/homeassistant/.virtualenvs/hass-py36/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 317, in _attr_setter
    value = getattr(self, name)
  File "/opt/srv/homeassistant/.virtualenvs/hass-py36/lib/python3.6/site-packages/homeassistant/components/sensor/raincloud.py", line 68, in icon
ValueError: invalid literal for int() with base 10: ''

Let's force this value to return None on those situations

Provide a property to return hashed serials

The raincloud service provides no method to secure your devices. If you have a serial number you can control the device. Because of this we should take care to pass a hash of the serial to external entities to prevent accidental logging of the serial in places like Home Assistant where a user may post a log publicly for help.

Logging state_changed to events table every 30 seconds

Thanks for integrating RainCloud with Home Assistant. The integration has been working great for me so far.

My Home Assistant db was growing quite fast, so I looked in the events table and found that it is logging state_changed events for all of the many raincloud sensors (x4 since there are four zones) every 30 seconds. I've excluded most of the sensors from being recorded (battery, time left, rain delay, etc) since I don't really need to see those in the history. I would like to keep the sensor for each zone_#_watering so I can see when each zone ran.

Would it be possible to only record events when the state actually changes (watering off -> on, etc) rather than polling and recording the values every 30 seconds?

Native Rain Delay workaround?

Has anyone else noticed that Melnor’s rain delay feature doesn’t really work any more?

Would be interested to learn how others are getting around this with integration

Support for setting watering timer during switch.turn_on service call

@tchellomello,
Thanks for developing this wonderful integration with HA. I noticed that the watering time is only possible to be configured in configuration file which is basically set on startup. I tried to set the watering time via switch.turn_on service call but the service data is not accepted. Is it possible possible to add this parameter in the switch component?
Additionally it'll be great if you could consider adding other service calls such as setting rain delays.
The thing is that I use voice commands via my google home as well as automation and it'll be great if I could use these services to turn on the watering for certain time frame or add rain delay by just a voice command or based on weather forecast which triggers a rain delay setting via your newly added service call.
Once again much appreciate adding this component to HA.
Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.