Rachio (Sprinklers)#7600
Conversation
| headers = self.r.device.stopWater(self._device.device_id)[0] | ||
| self.update(no_throttle=True) | ||
| return headers | ||
|
|
|
|
balloob
left a comment
There was a problem hiding this comment.
You've checked the boxes in your PR that you added the file to .coveragerc and ran script/gen_requirements_all.py. Both those changes should be part of this PR too.
| # Set up the component | ||
| # noinspection PyUnusedLocal | ||
| def setup_platform(hass, config, add_devices, discovery_info=None): | ||
| global _IRO |
There was a problem hiding this comment.
Don't use global, use hass.data[DATA_RACHIO ] instead, which is a dict for this purpose.
| from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA | ||
| from homeassistant.const import CONF_ACCESS_TOKEN | ||
|
|
||
| REQUIREMENTS = ['https://github.com/Klikini/rachiopy' |
There was a problem hiding this comment.
Can you push your dependency to PyPi?
There was a problem hiding this comment.
It's not mine, it's a fork of https://github.com/rfverbruggen/rachiopy/.
There was a problem hiding this comment.
If this fork is intended to stay as a permanent code, could you push it to pypi?
| _LOGGER.debug("Configuring Rachio API...") | ||
| from rachiopy import Rachio | ||
| r = Rachio(access_token) | ||
| person = _get_person(r) |
There was a problem hiding this comment.
Will you be able to verify that the given API token is valid?
|
|
||
|
|
||
| # Represents one Rachio Iro | ||
| class RachioIro(object): |
There was a problem hiding this comment.
I would have expected this class to live in RachioPy
There was a problem hiding this comment.
RachioPy is not my own creation, and in fact includes these classes, however, they only contain static methods and are otherwise useless. I'll add these methods to my fork of the library.
| return False | ||
|
|
||
| # Pull updated zone info from the Rachio API | ||
| @util.Throttle(MIN_UPDATE_INTERVAL, MIN_FORCED_UPDATE_INTERVAL) |
There was a problem hiding this comment.
Why would you throttle this? The device property that fetches the data is already throttled.
There was a problem hiding this comment.
Oh, okay. I didn't know how it works. This file contains every existing line of Python that I've written in my life.
👍
|
|
||
| _LOGGER.info("Watering {} for {} sec".format(self.name, seconds)) | ||
| headers = self.r.zone.start(self.zone_id, seconds)[0] | ||
| self.update(no_throttle=True) |
There was a problem hiding this comment.
Home Assistant will automatically call update on your entity after calling turn_on or turn_off
| def is_on(self): | ||
| self._device.update(propagate=False) | ||
| schedule = self._device.current_schedule | ||
| if 'zoneId' in schedule: |
There was a problem hiding this comment.
get returns the value of a dictionary or None if not found. So you can replace this if…else with return self.zone_id == schedule.get('zoneId')
| global manual_run_mins | ||
|
|
||
| # Get options | ||
| manual_run_mins = config.get(CONF_manual_run_mins) or manual_run_mins |
There was a problem hiding this comment.
This config parameter is not referenced in PLATFORM_SCHEMA
| CONF_manual_run_mins = 'manual_run_mins' | ||
| manual_run_mins = 60 | ||
|
|
||
| STATUS_ONLINE = 'ONLINE' |
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| DOMAIN = 'switch' |
|
Also, your documentation PR should be a PR against our documentation repository at https://github.com/home-assistant/home-assistant.github.io |
balloob
left a comment
There was a problem hiding this comment.
Alright, already looking a lot better! Found some more things that need fixing.
| # Set up the component | ||
| # noinspection PyUnusedLocal | ||
| def setup_platform(hass, config, add_devices, discovery_info=None): | ||
| global manual_run_mins |
|
|
||
| # Get options | ||
| manual_run_mins = config.get(CONF_MANUAL_RUN_MINS) or manual_run_mins | ||
| _LOGGER.debug("Rachio run time is " + str(manual_run_mins) + " min") |
There was a problem hiding this comment.
This, among other things, is one of the many lint issues that CI is reporting that need to be fixed: https://travis-ci.org/home-assistant/home-assistant/jobs/233033184#L271
| # Get access token | ||
| _LOGGER.debug("Getting Rachio access token...") | ||
| access_token = config.get(CONF_ACCESS_TOKEN) | ||
| if not access_token: |
There was a problem hiding this comment.
This is impossible, it's marked as required in your PLATFORM_SCHEMA
|
|
||
| @property | ||
| def name(self): | ||
| return self._zone['name'] or "Zone " + self.number |
There was a problem hiding this comment.
If _zone['name'] does not exist, a KeyError will be raised. Use _zone.get('name') instead to get None back.
There was a problem hiding this comment.
👍
Looks like this was unnecessary anyway. The API returns a placeholder name already, so I don't need to make one.
| self._zone = self.r.zone.get(self._zone_id)[1] | ||
|
|
||
| # Possibly update device | ||
| if propagate: |
There was a problem hiding this comment.
Your entity is set to be polled for updates by Home Assistant (because you do not overwrite the should_poll property). Each entity will individually call _device.update(), which is fine because Throttle will take care of it only getting called once.
So you can remove the whole propagation of updates.
| @@ -0,0 +1 @@ | |||
| [] No newline at end of file | |||
| def update(self): | ||
| """Pull updated device info from the Rachio API.""" | ||
| self._device = self.rachio.device.get(self._device_id)[1] | ||
| self._running = self.rachio.device.getCurrentSchedule(self._device_id)[1] |
There was a problem hiding this comment.
line too long (81 > 79 characters)
|
Please remove the polymer submodule from your commits. |
balloob
left a comment
There was a problem hiding this comment.
Ok to merge when polymer change has been removed from pr.
|
|
|
I found an issue with the way manual runs are handled from within HA. Your turn_on method is multiplying manual_run_secs by 60, but that number is already minutes multiplied by 60 during the init, which is causing the manual_run_min to be multiplied by 3600. Putting any number longer than 3 in for manual run wont work because its over the max of 10800 seconds (that's how I discovered the problem). Obviously removing one of those multiplications fixes the problem. |
|
Nice addition to HA. Hope in future we will have rain sensor input as well. |
|
You fixed the double convert, but in doing so you removed the 'seconds' variable, which is still trying to be called by the turn_on method. 😄 |
|
@scadaguru At some point I need to break out the actual device/zone code into a platform, and then replace the switch code with calls to that. Once that's done, it'll be a easier to add sensors with it as well. |
|
@Klikini that will be so nice. I am already enjoying now. Google Home will be watering my landscape now! |
|
@Klikini FYI: https://community.home-assistant.io/t/rachio-in-0-46-0/19185 Looks like there are some pretty serious problems with this component. |


Description:
Pull request inContent for (I don't exactly know how it works) home-assistant.github.io with documentation: https://github.com/Klikini/home-assistant.github.io/issues/2Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#2723
Example entry for
configuration.yaml:Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable.requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.is_on