8000 Adds port/SSL config options for RainMachine by bachya · Pull Request #8986 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adds port/SSL config options for RainMachine #8986

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

Merged
merged 6 commits into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions homeassistant/components/switch/rainmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@

import homeassistant.helpers.config_validation as cv
from homeassistant.components.switch import SwitchDevice
from homeassistant.const import (ATTR_ATTRIBUTION, ATTR_DEVICE_CLASS,
CONF_EMAIL, CONF_IP_ADDRESS, CONF_PASSWORD,
CONF_PLATFORM, CONF_SCAN_INTERVAL)
from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_DEVICE_CLASS, CONF_EMAIL, CONF_IP_ADDRESS,
CONF_PASSWORD, CONF_PLATFORM, CONF_PORT, CONF_SCAN_INTERVAL, CONF_SSL)
from homeassistant.util import Throttle

_LOGGER = getLogger(__name__)
REQUIREMENTS = ['regenmaschine==0.3.2']
REQUIREMENTS = ['regenmaschine==0.4.1']

ATTR_CYCLES = 'cycles'
ATTR_TOTAL_DURATION = 'total_duration'

CONF_HIDE_DISABLED_ENTITIES = 'hide_disabled_entities'
CONF_ZONE_RUN_TIME = 'zone_run_time'

DEFAULT_PORT = 8080
DEFAULT_SSL = True
DEFAULT_ZONE_RUN_SECONDS = 60 * 10

MIN_SCAN_TIME_LOCAL = timedelta(seconds=1)
Expand All @@ -42,10 +43,12 @@
vol.Email(), # pylint: disable=no-value-for-parameter
vol.Required(CONF_PASSWORD):
cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT):
cv.port,
vol.Optional(CONF_SSL, default=DEFAULT_SSL):
cv.boolean,
vol.Optional(CONF_ZONE_RUN_TIME, default=DEFAULT_ZONE_RUN_SECONDS):
cv.positive_int,
vol.Optional(CONF_HIDE_DISABLED_ENTITIES, default=True):
cv.boolean
cv.positive_int
}),
extra=vol.ALLOW_EXTRA)

Expand All @@ -64,28 +67,34 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
password = config.get(CONF_PASSWORD)
_LOGGER.debug('Password: %s', password)

hide_disabled_entities = config.get(CONF_HIDE_DISABLED_ENTITIES)
_LOGGER.debug('Show disabled entities: %s', hide_disabled_entities)

zone_run_time = config.get(CONF_ZONE_RUN_TIME)
_LOGGER.debug('Zone run time: %s', zone_run_time)

try:
if ip_address:
_LOGGER.debug('Configuring local API...')
auth = rm.Authenticator.create_local(ip_address, password)
port = config.get(CONF_PORT)
_LOGGER.debug('Port: %s', port)

ssl = config.get(CONF_SSL)
_LOGGER.debug('SSL: %s', ssl)

_LOGGER.debug('Configuring local API')
auth = rm.Authenticator.create_local(
ip_address, password, port=port, https=ssl)
elif email_address:
_LOGGER.debug('Configuring remote API...')
_LOGGER.debug('Configuring remote API')
auth = rm.Authenticator.create_remote(email_address, password)

_LOGGER.debug('Instantiating RainMachine client...')
_LOGGER.debug('Querying against: %s', auth.url)

_LOGGER.debug('Instantiating RainMachine client')
client = rm.Client(auth)

rainmachine_device_name = client.provision.device_name().get('name')

entities = []
for program in client.programs.all().get('programs'):
if hide_disabled_entities and program.get('active') is False:
if not program.get('active'):
continue

_LOGGER.debug('Adding program: %s', program)
Expand All @@ -94,7 +103,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
client, program, device_name=rainmachine_device_name))

for zone in client.zones.all().get('zones'):
if hide_disabled_entities and zone.get('active') is False:
if not zone.get('active'):
continue

_LOGGER.debug('Adding zone: %s', zone)
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ radiotherm==1.3
# raspihats==2.2.1

# homeassistant.components.switch.rainmachine
regenmaschine==0.3.2
regenmaschine==0.4.1

# homeassistant.components.python_script
restrictedpython==4.0a3
Expand Down
0