core: Hydrawise: Error during setup

The problem

The hydrawise integration started throwing errors (see below) and doesn’t seem to be able to connect to their API anymore.

Environment

  • Home Assistant release with the issue: 0.105.5
  • Last working Home Assistant release (if known): 0.105.4
  • Operating environment (Hass.io/Docker/Windows/etc.): Docker
  • Integration causing this issue: hydrawise
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/hydrawise/

Problem-relevant configuration.yaml

hydrawise:
  access_token: !secret hydrawise_api

Traceback/Error logs

Error during setup of component hydrawise
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 174, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/hydrawise/__init__.py", line 77, in setup
    hydrawise = Hydrawiser(user_token=access_token)
  File "/usr/local/lib/python3.7/site-packages/hydrawiser/core.py", line 42, in __init__
    self.update_controller_info()
  File "/usr/local/lib/python3.7/site-packages/hydrawiser/core.py", line 65, in update_controller_info
    self.user_id = self.controller_status['user_id']
KeyError: 'user_id'

Additional information

I noticed the problem started on Mon, Feb 17th. This may not be connected to my upgrade to 0.105.5 from 0.105.4.

I also noticed another user having the same issue in https://github.com/home-assistant/home-assistant/issues/26918

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 51 (17 by maintainers)

Most upvoted comments

@txwindsurfer, @sarge31, you’re on the right track to fixing the issue. There were significant changes between API v1.3 & v1.4 that broke the Hydrawise component for HA.

I’ve already pushed a new Python library (Hydrawiser v0.2) that works again to the v1.4 API. However, to get the HA component fixed will take more effort. A lot has changed in the HA architecture and component integration since I published the component almost 2 years ago. I’m having to refresh myself with HA to get the Hydrawise component integration fixed and and a new pull request issued.

I do plan to fix the Hydrawise component, but it will take me some time.

All, I am still working on fixing this integration. I’m close to issuing a pull request. I have posted a full update on what to expect here. Expect the pull request within a week.

Bump this issue that for some reason is not getting integrated into the releases of HA.

Hello @PeterPriceE, I think what you want to look at is how to add your own custom component. The documentation here should help you with that. As for fixing the integration I am still working on it. I’ve been pretty busy with other unexpected activities, but I am making progress, however. I am also trying to work with Hydrawise on either using the new v2 API or fixing the v1 API to restore some features that were lost in the new version.

@SeraphimSerapis same problem here. Restoring last snapshot with 0.105.4 does not fix the problem.

@PeterPriceE I updated my earlier post to correct the zip file. Sorry for the mix up.

I found the new files on the GitHub. Everything is working just fine. Thanks a lot for the support.

@ptcryan Thank you so much for all the work on this component and improving the code.

The new component is working great for me on a RPi 4 running HA Core 0.110.4 and OS 4.9 (note: I am using your changed hydrawise code from last Friday not the recent revisions you are making and I will wait on those until the PR is merged into HA Core)

As I read @CarpeDiemRo, he incorrectly copied the hydrawiser code into the custom component directory not the hydrawise code. The hydrawise code that should be copied to custom_components is located here: https://github.com/home-assistant/core/pull/34448/files

The manifest.json file should get the required 0.2 hydrawiser library when HA is rebooted . If it doesn’t these files will need to be manually copied into site-packages/hydrawiser.

Thanks again for all you work revising this component.

I made some changes to get rid of the errors but some of the sensors may not be setup correctly due to the changes in the API response. Including the changes I made for in case others want to fix or if it helps one of the developers attack the issue. As I mentioned above, the hydrawiser package, core.py, was updated and removed the self.user_id and self.watering_time attributes. self.name was fixed to pull from the correct value in the json response. All good however when the sensors are being setup for the controller, they are expecting the name in the status attributes. I added:

  `self.controller_status['name'] = self.name` 

I run hassio so making these changes in the container just gets overwritten when restarted. As a workaround, I put the hydawiser package into the config folder (/config/hydrawiser) with the modified core.py. So had to modify the hydrawise component file as well so put the changes into custom_components under config. sensor.py from `

else:  # _sensor_type == 'next_cycle'
    for relay in mydata.relays:
         if relay["relay"] == self.data["relay"]:
              if relay["nicetime"] == "Not scheduled":
                   self._state = "not_scheduled"
              else:
                  self._state = (
                      relay["nicetime"].split(",")[0]
                      + " "
                      + relay["nicetime"].split(" ")[3]
                  )

to:

    else:  # _sensor_type == 'next_cycle'
        for relay in mydata.relays:
            if relay["relay"] == self.data["relay"]:
                if relay["time"] == 1576800000:
                    self._state = "not_scheduled"
                else:
                    self._state = (
                        relay["timestr"]
                    )

` The nicetime attribute no longer exists in the new API response so there is no nicely formated time for the next cycle. I’ve used the timestr attribute but it does not include the date.

Hope this is helpful to others.