Skip to content
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
9a191d4
Adding Genius Hub
GeoffAtHome Mar 2, 2019
57fc2d4
Added Genius hub
Mar 2, 2019
2a9c8d5
Correct hound errors
Mar 2, 2019
1077de9
Correct hound errors.
GeoffAtHome Mar 3, 2019
24931b4
Merge
GeoffAtHome Mar 3, 2019
01cfbe0
Correct tox errors.
GeoffAtHome Mar 3, 2019
c361be3
Fix travis errors
GeoffAtHome Mar 3, 2019
77a9cb1
Correct sensor names
GeoffAtHome Mar 3, 2019
6a20776
Correct travis errors
GeoffAtHome Mar 4, 2019
70c6e92
Correct travis errors
GeoffAtHome Mar 4, 2019
98d71c3
Correct hound errors
GeoffAtHome Mar 4, 2019
acb0823
Follow up from code review by Martin Hjelmare
GeoffAtHome Mar 24, 2019
56e74fd
More changes from code review.
GeoffAtHome Mar 25, 2019
f34e345
Attempt to resolve conflicts in requirements_all
GeoffAtHome Mar 25, 2019
dfc2c7c
rebase with latest upstream changes
zxdavb Mar 28, 2019
dc17eb7
de-lint for the houndci-bot
zxdavb Mar 28, 2019
5887e93
better logging message, and small tidy-up
zxdavb Mar 28, 2019
358cd22
minor refactor and de-lint
zxdavb Mar 28, 2019
48818ba
domain name should be the same as the component name
zxdavb Mar 28, 2019
2cd9424
use self where appropriate
zxdavb Mar 28, 2019
efd16a1
minor de-lint
zxdavb Mar 28, 2019
3907737
add entities as a single call
zxdavb Mar 28, 2019
df7e4d0
de-lint
zxdavb Mar 28, 2019
299d8e2
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb Mar 29, 2019
16f306f
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb Apr 3, 2019
9552c5b
latest changes
zxdavb Apr 6, 2019
9d01726
all read-only attrs almost done
zxdavb Apr 6, 2019
6195e6c
refactor - near the end
zxdavb Apr 6, 2019
cc31566
change state/,ode mapping
zxdavb Apr 6, 2019
9b9245a
override temp from curr_temp
zxdavb Apr 7, 2019
1388095
all read-only properties working
zxdavb Apr 12, 2019
96073c5
working now
zxdavb Apr 13, 2019
8324789
ready for PR, but need to remove logging
zxdavb Apr 13, 2019
1228d7f
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb Apr 13, 2019
42110f4
de-lint
zxdavb Apr 13, 2019
532bca9
de-linted, ready for merge
zxdavb Apr 13, 2019
5f1e0ac
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb Apr 13, 2019
6bbc964
de-linted, ready for merge 2
zxdavb Apr 13, 2019
d09dfa0
Merge pull request #1 from GeoffAtHome/use-geniushub-client
zxdavb Apr 13, 2019
d5bf592
up to date
zxdavb Apr 13, 2019
6d40237
fix merge hell
zxdavb Apr 13, 2019
1135c69
didn't like import in climate/__init__
zxdavb Apr 13, 2019
d0a3593
improve footprint logic
zxdavb Apr 13, 2019
13fc061
add manifest.json
zxdavb Apr 13, 2019
6a2d272
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb Apr 13, 2019
17cb347
add manifest.json 2
zxdavb Apr 13, 2019
3800679
correct a regression
zxdavb Apr 13, 2019
e6623c5
fix regression with device.is_on()
zxdavb Apr 13, 2019
e3729d0
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
zxdavb Apr 14, 2019
33084a4
Merge remote-tracking branch 'upstream/dev' into genius-hub
zxdavb Apr 15, 2019
4328fbe
Merge remote-tracking branch 'upstream/dev' into genius-hub
zxdavb Apr 15, 2019
b668f31
use latest client library
zxdavb Apr 15, 2019
8bc1783
Merge remote-tracking branch 'upstream/dev' into genius-hub
zxdavb Apr 16, 2019
c092f3b
update to latest client library, 3.3.6
zxdavb Apr 16, 2019
2e9ef6a
delint and shoudl be OK to go
zxdavb Apr 16, 2019
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
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ omit =
homeassistant/components/futurenow/light.py
homeassistant/components/garadget/cover.py
homeassistant/components/gc100/*
homeassistant/components/geniushub/*
homeassistant/components/gearbest/sensor.py
homeassistant/components/geizhals/sensor.py
homeassistant/components/github/sensor.py
Expand Down
52 changes: 52 additions & 0 deletions homeassistant/components/geniushub/__init__.py
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
159 changes: 159 additions & 0 deletions homeassistant/components/geniushub/climate.py
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 (
Comment thread
MartinHjelmare marked this conversation as resolved.
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)
Comment thread
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.
Comment thread
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)
Comment thread
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 "
Comment thread
zxdavb marked this conversation as resolved.
Outdated
"(maybe just an arbitary failure?), message: %s",
self._id, err)
10 changes: 10 additions & 0 deletions homeassistant/components/geniushub/manifest.json
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": []
}
3 changes: 3 additions & 0 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ gearbest_parser==1.0.7
# homeassistant.components.geizhals
geizhals==0.0.9

# homeassistant.components.geniushub
geniushub-client==0.3.6

# homeassistant.components.geo_json_events
# homeassistant.components.nsw_rural_fire_service_feed
# homeassistant.components.usgs_earthquakes_feed
Expand Down