Rachio in 0.46.0

Anyone able to get this working so far? I retrieve all my zones after entering the Rachio API key and they show up as switches. However, when I turn on the switches, they immediately turn back off and this shows up in the error logs. Is this working for anyone else currently?

2017-06-04 12:42:44 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
result = coro.throw(exc)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1015, in _event_to_service_call
yield from service_handler.func(service_call)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/switch/__init__.py", line 104, in async_handle_switch_service
yield from switch.async_turn_on()
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self  # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/switch/rachio.py", line 227, in turn_on
self.rachio.zone.start(self.zone_id, seconds)
File "/home/homeassistant/.homeassistant/deps/rachiopy/zone.py", line 14, in start
return self.rachio.put(path, payload)
File "/home/homeassistant/.homeassistant/deps/rachiopy/__init__.py", line 53, in put
return self._request(path, 'PUT', body)
File "/home/homeassistant/.homeassistant/deps/rachiopy/__init__.py", line 34, in _request
headers=self._headers, body=body)
File "/home/homeassistant/.homeassistant/deps/httplib2/__init__.py", line 1322, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/home/homeassistant/.homeassistant/deps/httplib2/__init__.py", line 1072, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/home/homeassistant/.homeassistant/deps/httplib2/__init__.py", line 1025, in _conn_request
response = conn.getresponse()
File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
response.begin()
File "/usr/lib/python3.4/http/client.py", line 351, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.4/socket.py", line 371, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.4/ssl.py", line 745, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.4/ssl.py", line 617, in read
v = self._sslobj.read(len, buffer)
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1769)

Code in my configuration.yaml

  - platform: rachio
    access_token: !secret rachio_access_token


outside_devices:
  name: Irrigation
  entities:
    - switch.front_yard_left
    - switch.front_yard_right
    - switch.flowerbeds_
    - switch.backyard

I am unable to get as far as you - I get an “error while setting up platform rachio”:

2017-06-04 17:38:17 ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform rachio
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_component.py", line 160, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/switch/rachio.py", line 66, in setup_platform
    "using " + hass.data[DATA_RACHIO].device_id)
  File "/usr/src/app/homeassistant/components/switch/rachio.py", line 106, in device_id
    return self._device['id']
TypeError: 'NoneType' object is not subscriptable

That’s interesting. Looks like you’re running python 3.6. I’m at 3.4 currently. I thought maybe I could fix the error in ssl.py by upgrading python. But I am using the all in one installer and I have no idea how to accomplish that. How did you upgrade?

I’m getting the same issues. Here is my log:

2017-06-04 20:01:08 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1015, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/switch/__init__.py", line 104, in async_handle_switch_service
    yield from switch.async_turn_on()
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/switch/rachio.py", line 224, in turn_on
    self.turn_off()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/switch/rachio.py", line 232, in turn_off
    self.rachio.device.stopWater(self._device.device_id)
  File "/home/homeassistant/.homeassistant/deps/rachiopy/device.py", line 44, in stopWater
    return self.rachio.put(path, payload)
  File "/home/homeassistant/.homeassistant/deps/rachiopy/__init__.py", line 53, in put
    return self._request(path, 'PUT', body)
  File "/home/homeassistant/.homeassistant/deps/rachiopy/__init__.py", line 34, in _request
    headers=self._headers, body=body)
  File "/home/homeassistant/.homeassistant/deps/httplib2/__init__.py", line 1322, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/home/homeassistant/.homeassistant/deps/httplib2/__init__.py", line 1072, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/home/homeassistant/.homeassistant/deps/httplib2/__init__.py", line 1025, in _conn_request
    response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.4/ssl.py", line 745, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.4/ssl.py", line 617, in read
    v = self._sslobj.read(len, buffer)
ssl.SSLError: [SSL: BLOCK_CIPHER_PAD_IS_WRONG] block cipher pad is wrong (_ssl.c:1769)

Might be an issue with this release then if we’re both seeing it. Maybe the person that added the integration will see this and respond

I’m getting the same results:

Switches show up, turn them on and they turn back off, and the sprinklers don’t turn on.

The only difference is that I am not seeing the additional error messages.

I only added this to my configuration:

- platform: rachio
    access_token: !secret rachio_access_token

I am the developer who added this integration.

The reason the switches turn off immediately is because I’m not sure how to ask the Rachio API if a zone is running manually, only if it is running as scheduled. (Suggestions welcome here :slight_smile:). However, in my testing, the zone would still turn on for the specified amount of time. When a schedule is running, the switches do show in the “on” state.

As for the SSL errors: I have no idea how to fix these because I haven’t seen them personally. Maybe someone who has more experience with HTTP in Python (or Python at all, this was my first Python code) can help.

So basically switches are only to show if a zone is running ?

Definitely not seeing the zones startup for me. Which version of Python were you using during your testing?

@heathpitts

  • Python 3.6.1 on Windows 10
  • Python 3.4.2 on Raspbian 8

@carlostico Currently, yes. I’d like to figure out how to check the status of a manual run, but I have not had time to play with it yet.

@heathpitts, the reason your not seeing the zones start up is because in 0.46.0 there was an error in the code that caused the runtime to be double multiplied, which exceeds the max runtime for the API. It has been fixed in dev. Although if your still getting the SSL error that might unrelated…

@Klikini, I’ve been able to get the zones to show on correctly during manual runs by tweaking the throttle parameters, but as I’m not sure exactly how throttle works I don’t know if that’s causing excessive API calls. Looking at the logs it appears that the state is saying it’s updated every 30 seconds or so, but as the code is written it doesn’t actually update the state. Changing the update interval as shown below still only shows an API call every 30 seconds in the logs, and at that point the correct state is updated on the switch, both for manual and scheduled runs. Let me know if this is any help or if I should change it back…

MIN_UPDATE_INTERVAL = timedelta(seconds=5)
MIN_FORCED_UPDATE_INTERVAL = timedelta(seconds=1)
1 Like

@brg468 That works for manual runs, confirmed here. I can’t find anything in the Rachio API documentation (at least, the little they have) about rate limiting, so we’ll see if this causes any problems.

Seems like it would be less confusing if these were implemented as sensors rather than switches. Unless I am reading this all wrong.

I’ll try it again when the dev version is released. Will this be in the 0.46.1 release?

They are switches because you can turn them on to water each zone, rather than just checking the current state like a binary sensor.

Eventually, I’d like to support sensors as well, but for rain delays, watering times, etc.

I guess I was wrong, the version in dev is still the old one.

@Klikini do you need to open another PR to get the commits merged? I’m not familiar with how that works exactly.

I’m not sure…I guess I will, because it should work, even if it’s not the best/only way.

Update: https://github.com/home-assistant/home-assistant/pull/7922

Any progress on this? I still can’t get this to work for some reason. I see the following in the logs but nothing ever happens

2017-06-20 15:40:33 INFO (Thread-5) [homeassistant.components.switch.rachio] Stopping watering of all zones
2017-06-20 15:40:34 INFO (Thread-5) [homeassistant.components.switch.rachio] Watering Backyard for 36000 sec

I don’t think the PR has gone through yet. In the meantime you can make a quick change to the rachio.py file and that should get it working till its fixed. You just need to remove the double multiplication.

Change:

def turn_on(self):
    """Start the zone."""
    # Convert minutes to seconds
    seconds = self._manual_run_secs * 60

To:

def turn_on(self):
    """Start the zone."""
    # Convert minutes to seconds
    seconds = self._manual_run_secs