-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move RainMachine to component/hub model #14085
Conversation
from datetime import timedelta | ||
|
||
import voluptuous as vol | ||
from requests.exceptions import HTTPError, ConnectTimeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'requests.exceptions.HTTPError' imported but unused
'requests.exceptions.ConnectTimeout' imported but unused
_LOGGER.debug('Adding program: %s', program) | ||
entities.append( | ||
RainMachineProgram( | ||
client, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the existing formatting, by having as many parameters on one line as possible.
from regenmaschine import Authenticator, Client | ||
from regenmaschine.exceptions import HTTPError | ||
|
||
_LOGGER.debug('Config data: %s', config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will log the whole config. Please remove.
_LOGGER.debug('Config data: %s', config) | ||
|
||
conf = config[DOMAIN] | ||
ip_address = conf.get(CONF_IP_ADDRESS, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None
is the default value returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean by this; all other components I've looked at return True
or False
. Are you saying that I should be returning None
, or that I shouldn't and I somehow am?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dict.get(key)
by default returns None
if the key is missing in the dict. So please just write conf.get(CONF_IP_ADDRESS)
.
Sorry about not being clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! Will update.
port = conf[CONF_PORT] | ||
ssl = conf[CONF_SSL] | ||
auth = Authenticator.create_local( | ||
ip_address, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep as many arguments as possible on one line.
password, | ||
port=port, | ||
https=ssl) | ||
_LOGGER.debug('Configuring local API: %s', auth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this log credentials? If so remove.
_LOGGER.debug('Configuring local API: %s', auth) | ||
elif email_address: | ||
auth = Authenticator.create_remote(email_address, password) | ||
_LOGGER.debug('Configuring remote API: %s', auth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
|
||
conf = config[DOMAIN] | ||
ip_address = conf.get(CONF_IP_ADDRESS) | ||
email_address = conf.get(CONF_EMAIL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed anymore with the new config schema.
_decorator = decorator | ||
else: | ||
|
||
@Throttle(MIN_SCAN_TIME_REMOTE, MIN_SCAN_TIME_FORCED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be removed.
auth = Authenticator.create_local( | ||
ip_address, password, port=port, https=ssl) | ||
_LOGGER.debug('Configuring local API: %s', ip_address) | ||
elif email_address: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
from regenmaschine.exceptions import HTTPError | ||
|
||
conf = config[DOMAIN] | ||
ip_address = conf.get(CONF_IP_ADDRESS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new schema this should be:
ip_address = conf[CONF_IP_ADDRESS]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Can be merged when build passes.
Description:
This is the first of several PRs designed to add more functionality to the RainMachine integration. The first is this, which moves the integration from existing fully in a switch platform to being a combo component + switch platform (a la Arlo, et. al.). No functionality changes, per se, in this PR.
This will be the master PR; fine to merge once it passes tests and review, but others will be held back until this is merged.
BREAKING CHANGE 1: with the migration to the component/hub model, existing configuration files will break. The new format (below) should be used.
BREAKING CHANGE 2: after intense amounts of fiddling, it's clear to me that the RainMachine remote API is broken, clunky, etc. After some investigation, I haven't found a single user who's using it, so using this PR as a time to remove it and references to it.
Related issue (if applicable): N/A
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5251
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.