-
-
Notifications
You must be signed in to change notification settings - Fork 38.2k
Genius hub #21598
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
Genius hub #21598
Changes from 54 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
9a191d4
Adding Genius Hub
GeoffAtHome 57fc2d4
Added Genius hub
2a9c8d5
Correct hound errors
1077de9
Correct hound errors.
GeoffAtHome 24931b4
Merge
GeoffAtHome 01cfbe0
Correct tox errors.
GeoffAtHome c361be3
Fix travis errors
GeoffAtHome 77a9cb1
Correct sensor names
GeoffAtHome 6a20776
Correct travis errors
GeoffAtHome 70c6e92
Correct travis errors
GeoffAtHome 98d71c3
Correct hound errors
GeoffAtHome acb0823
Follow up from code review by Martin Hjelmare
GeoffAtHome 56e74fd
More changes from code review.
GeoffAtHome f34e345
Attempt to resolve conflicts in requirements_all
GeoffAtHome dfc2c7c
rebase with latest upstream changes
zxdavb dc17eb7
de-lint for the houndci-bot
zxdavb 5887e93
better logging message, and small tidy-up
zxdavb 358cd22
minor refactor and de-lint
zxdavb 48818ba
domain name should be the same as the component name
zxdavb 2cd9424
use self where appropriate
zxdavb efd16a1
minor de-lint
zxdavb 3907737
add entities as a single call
zxdavb df7e4d0
de-lint
zxdavb 299d8e2
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb 16f306f
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb 9552c5b
latest changes
zxdavb 9d01726
all read-only attrs almost done
zxdavb 6195e6c
refactor - near the end
zxdavb cc31566
change state/,ode mapping
zxdavb 9b9245a
override temp from curr_temp
zxdavb 1388095
all read-only properties working
zxdavb 96073c5
working now
zxdavb 8324789
ready for PR, but need to remove logging
zxdavb 1228d7f
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb 42110f4
de-lint
zxdavb 532bca9
de-linted, ready for merge
zxdavb 5f1e0ac
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb 6bbc964
de-linted, ready for merge 2
zxdavb d09dfa0
Merge pull request #1 from GeoffAtHome/use-geniushub-client
zxdavb d5bf592
up to date
zxdavb 6d40237
fix merge hell
zxdavb 1135c69
didn't like import in climate/__init__
zxdavb d0a3593
improve footprint logic
zxdavb 13fc061
add manifest.json
zxdavb 6a2d272
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb 17cb347
add manifest.json 2
zxdavb 3800679
correct a regression
zxdavb e6623c5
fix regression with device.is_on()
zxdavb e3729d0
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb 33084a4
Merge remote-tracking branch 'upstream/dev' into genius-hub
zxdavb 4328fbe
Merge remote-tracking branch 'upstream/dev' into genius-hub
zxdavb b668f31
use latest client library
zxdavb 8bc1783
Merge remote-tracking branch 'upstream/dev' into genius-hub
zxdavb c092f3b
update to latest client library, 3.3.6
zxdavb 2e9ef6a
delint and shoudl be OK to go
zxdavb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| """This module connects to the Genius hub and shares the data.""" | ||
| import logging | ||
|
|
||
| import voluptuous as vol | ||
|
|
||
| from homeassistant.const import ( | ||
| CONF_HOST, CONF_PASSWORD, CONF_USERNAME) | ||
| from homeassistant.helpers import config_validation as cv | ||
| from homeassistant.helpers.aiohttp_client import async_get_clientsession | ||
| from homeassistant.helpers.discovery import async_load_platform | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| DOMAIN = 'geniushub' | ||
|
|
||
| CONFIG_SCHEMA = vol.Schema({ | ||
| DOMAIN: vol.Schema({ | ||
| vol.Optional(CONF_USERNAME): cv.string, | ||
| vol.Optional(CONF_PASSWORD): cv.string, | ||
| vol.Required(CONF_HOST): cv.string, | ||
| }), | ||
| }, extra=vol.ALLOW_EXTRA) | ||
|
|
||
|
|
||
| async def async_setup(hass, hass_config): | ||
| """Create a Genius Hub system.""" | ||
| from geniushubclient import GeniusHubClient # noqa; pylint: disable=no-name-in-module | ||
|
|
||
| host = hass_config[DOMAIN].get(CONF_HOST) | ||
| username = hass_config[DOMAIN].get(CONF_USERNAME) | ||
| password = hass_config[DOMAIN].get(CONF_PASSWORD) | ||
|
|
||
| geniushub_data = hass.data[DOMAIN] = {} | ||
|
|
||
| try: | ||
| client = geniushub_data['client'] = GeniusHubClient( | ||
| host, username, password, | ||
| session=async_get_clientsession(hass) | ||
| ) | ||
|
|
||
| await client.hub.update() | ||
|
|
||
| except AssertionError: # assert response.status == HTTP_OK | ||
| _LOGGER.warning( | ||
| "setup(): Failed, check your configuration.", | ||
| exc_info=True) | ||
| return False | ||
|
|
||
| hass.async_create_task(async_load_platform( | ||
| hass, 'climate', DOMAIN, {}, hass_config)) | ||
|
|
||
| return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| """Supports Genius hub to provide climate controls.""" | ||
| import asyncio | ||
| import logging | ||
|
|
||
| from homeassistant.components.climate import ClimateDevice | ||
| from homeassistant.components.climate.const import ( | ||
| STATE_AUTO, STATE_ECO, STATE_HEAT, STATE_MANUAL, | ||
| SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE, SUPPORT_ON_OFF) | ||
| from homeassistant.const import ( | ||
| ATTR_TEMPERATURE, TEMP_CELSIUS) | ||
|
|
||
| from . import DOMAIN | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| GENIUSHUB_SUPPORT_FLAGS = \ | ||
| SUPPORT_TARGET_TEMPERATURE | \ | ||
| SUPPORT_ON_OFF | \ | ||
| SUPPORT_OPERATION_MODE | ||
|
|
||
| GENIUSHUB_MAX_TEMP = 28.0 | ||
| GENIUSHUB_MIN_TEMP = 4.0 | ||
|
|
||
| # Genius supports only Off, Override/Boost, Footprint & Timer modes | ||
| HA_OPMODE_TO_GH = { | ||
| STATE_AUTO: 'timer', | ||
| STATE_ECO: 'footprint', | ||
| STATE_MANUAL: 'override', | ||
| } | ||
| GH_OPMODE_OFF = 'off' | ||
| GH_STATE_TO_HA = { | ||
| 'timer': STATE_AUTO, | ||
| 'footprint': STATE_ECO, | ||
| 'away': None, | ||
| 'override': STATE_MANUAL, | ||
| 'early': STATE_HEAT, | ||
| 'test': None, | ||
| 'linked': None, | ||
| 'other': None, | ||
| } # intentionally missing 'off': None | ||
| GH_DEVICE_STATE_ATTRS = ['temperature', 'type', 'occupied', 'override'] | ||
|
|
||
|
|
||
| async def async_setup_platform(hass, hass_config, async_add_entities, | ||
| discovery_info=None): | ||
| """Set up the Genius hub climate devices.""" | ||
| client = hass.data[DOMAIN]['client'] | ||
|
|
||
| zones = [] | ||
| for zone in client.hub.zone_objs: | ||
| if hasattr(zone, 'temperature'): | ||
| zones.append(GeniusClimate(client, zone)) | ||
|
|
||
| async_add_entities(zones, update_before_add=False) | ||
|
zxdavb marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| class GeniusClimate(ClimateDevice): | ||
| """Representation of a Genius Hub climate device.""" | ||
|
|
||
| def __init__(self, client, zone): | ||
| """Initialize the climate device.""" | ||
| self._client = client | ||
| self._objref = zone | ||
| self._id = zone.id | ||
| self._name = zone.name | ||
|
|
||
| # Only some zones have movement detectors, which allows footprint mode | ||
| op_list = list(HA_OPMODE_TO_GH) | ||
| if not hasattr(self._objref, 'occupied'): | ||
| op_list.remove(STATE_ECO) | ||
| self._operation_list = op_list | ||
|
|
||
| @property | ||
| def name(self): | ||
| """Return the name of the climate device.""" | ||
| return self._objref.name | ||
|
|
||
| @property | ||
| def device_state_attributes(self): | ||
| """Return the device state attributes of the evohome Climate device. | ||
|
zxdavb marked this conversation as resolved.
Outdated
|
||
|
|
||
| This is state data that is not available otherwise, due to the | ||
| restrictions placed upon ClimateDevice properties, etc. by HA. | ||
| """ | ||
| tmp = self._objref.__dict__.items() | ||
| state = {k: v for k, v in tmp if k in GH_DEVICE_STATE_ATTRS} | ||
|
|
||
| return {'status': state} | ||
|
|
||
| @property | ||
| def current_temperature(self): | ||
| """Return the current temperature.""" | ||
| return self._objref.temperature | ||
|
|
||
| @property | ||
| def target_temperature(self): | ||
| """Return the temperature we try to reach.""" | ||
| return self._objref.setpoint | ||
|
|
||
| @property | ||
| def min_temp(self): | ||
| """Return max valid temperature that can be set.""" | ||
| return GENIUSHUB_MIN_TEMP | ||
|
|
||
| @property | ||
| def max_temp(self): | ||
| """Return max valid temperature that can be set.""" | ||
| return GENIUSHUB_MAX_TEMP | ||
|
|
||
| @property | ||
| def temperature_unit(self): | ||
| """Return the unit of measurement.""" | ||
| return TEMP_CELSIUS | ||
|
|
||
| @property | ||
| def supported_features(self): | ||
| """Return the list of supported features.""" | ||
| return GENIUSHUB_SUPPORT_FLAGS | ||
|
|
||
| @property | ||
| def operation_list(self): | ||
| """Return the list of available operation modes.""" | ||
| return self._operation_list | ||
|
|
||
| @property | ||
| def current_operation(self): | ||
| """Return the current operation mode.""" | ||
| return GH_STATE_TO_HA.get(self._objref.mode, None) | ||
|
MartinHjelmare marked this conversation as resolved.
Outdated
|
||
|
|
||
| @property | ||
| def is_on(self): | ||
| """Return True if the device is on.""" | ||
| return self._objref.mode in GH_STATE_TO_HA | ||
|
|
||
| async def async_set_operation_mode(self, operation_mode): | ||
| """Set a new operation mode for this zone.""" | ||
| await self._objref.set_mode(HA_OPMODE_TO_GH.get(operation_mode)) | ||
|
|
||
| async def async_set_temperature(self, **kwargs): | ||
| """Set a new target temperature for this zone.""" | ||
| temperature = kwargs.get(ATTR_TEMPERATURE) | ||
| await self._objref.set_override(temperature, 3600) # 1 hour | ||
|
|
||
| async def async_turn_on(self): | ||
| """Turn on this heating zone.""" | ||
| await self._objref.set_mode(HA_OPMODE_TO_GH.get(STATE_AUTO)) | ||
|
|
||
| async def async_turn_off(self): | ||
| """Turn off this heating zone (i.e. to frost protect).""" | ||
| await self._objref.set_mode(GH_OPMODE_OFF) | ||
|
|
||
| async def async_update(self): | ||
| """Get the latest data from the hub.""" | ||
| try: | ||
| await self._objref.update() | ||
| except (AssertionError, asyncio.TimeoutError) as err: | ||
| _LOGGER.warning("self.(%s).update(): Failed " | ||
|
zxdavb marked this conversation as resolved.
Outdated
|
||
| "(maybe just an arbitary failure?), message: %s", | ||
| self._id, err) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "domain": "geniushub", | ||
| "name": "Genius Hub", | ||
| "documentation": "https://www.home-assistant.io/components/geniushub", | ||
| "requirements": [ | ||
| "geniushub-client==0.3.6" | ||
| ], | ||
| "dependencies": [], | ||
| "codeowners": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.