Skip to content
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

Add Intergas InComfort Lan2RF gateway #23736

Merged
merged 40 commits into from May 7, 2019
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d98ef86
fixed __init__.py
zxdavb Apr 29, 2019
21bacd9
add sensors
zxdavb Apr 30, 2019
efb697f
switch to parent-child architecture
zxdavb Apr 30, 2019
1f5ceec
make binary_sensor the parent
zxdavb May 1, 2019
acf823a
revert parent - to water_heater
zxdavb May 1, 2019
9ee6a78
first working version
zxdavb May 1, 2019
8f33f91
working, delinted (except TODO)
zxdavb May 1, 2019
045cd30
update to latest client library
zxdavb May 1, 2019
590c53f
remove debug code
zxdavb May 1, 2019
5f68d26
delint
zxdavb May 1, 2019
b22a8a3
Merge remote-tracking branch 'upstream/dev' into add_intergas_intouch
zxdavb May 1, 2019
521f0f2
tweak device_state_attributes
zxdavb May 1, 2019
c0adc37
tweak device_state_attrbutes
zxdavb May 1, 2019
97fc989
minor tweaks
zxdavb May 1, 2019
40a1cef
bump client library for bugfix
zxdavb May 1, 2019
dc6de80
improve state attributes for pumping
zxdavb May 1, 2019
6304809
update .coverage
zxdavb May 1, 2019
d1845a1
bugfix - binary sensors not updating
zxdavb May 1, 2019
cfc2827
rename to incomfort from intouch
zxdavb May 2, 2019
691a4f5
fix coveragerc regression
zxdavb May 6, 2019
deaf2b0
Merge remote-tracking branch 'upstream/dev' into add_intergas_intouch
zxdavb May 6, 2019
c21f080
Merge remote-tracking branch 'upstream/dev' into add_intergas_intouch
zxdavb May 6, 2019
72c0532
bump client (bugfix for /protected URL)
zxdavb May 6, 2019
228dc67
bump client (bugfix for /protected URL) 2
zxdavb May 7, 2019
ac1e428
bump client
zxdavb May 7, 2019
2fac73e
remove debug code
zxdavb May 7, 2019
5a380a2
ready for PR
zxdavb May 7, 2019
afcd0de
fix regression
zxdavb May 7, 2019
3dd5391
use xx._boiler instead of xx._objref
zxdavb May 7, 2019
e9eefc2
improve current_temperature and delint
zxdavb May 7, 2019
5978615
use current_operation instead of state
zxdavb May 7, 2019
f7ab847
refactor vol.Schema
zxdavb May 7, 2019
59ef9f4
remove unneeded instance attribute
zxdavb May 7, 2019
ec43141
remove unneeded instance attribute 2
zxdavb May 7, 2019
3e4d6ab
refactor device_state_attributes
zxdavb May 7, 2019
97786c3
change 'boiler' to 'heater'
zxdavb May 7, 2019
79212f5
change 'boiler' to 'heater' 2
zxdavb May 7, 2019
7607be9
correct a typo
zxdavb May 7, 2019
05388b7
bugfix: add missing comma
zxdavb May 7, 2019
895ddd3
small tidy-up
zxdavb May 7, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

add sensors

  • Loading branch information...
zxdavb committed Apr 30, 2019
commit 21bacd9408b00299a3794e3246ca7327a40e9321
@@ -2,21 +2,33 @@
import logging

import voluptuous as vol
from intouchclient import InComfortClient
from intouchclient import InTouchGateway

from homeassistant.const import CONF_HOST
from homeassistant.const import (
CONF_HOST, CONF_PASSWORD, CONF_USERNAME, EVENT_HOMEASSISTANT_START)
from homeassistant.core import callback
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
from homeassistant.helpers.dispatcher import async_dispatcher_send

_LOGGER = logging.getLogger(__name__)

DOMAIN = 'intouch'

_V1_SCHEMA = vol.Schema({
vol.Required(CONF_HOST): cv.string,
})
_V2_SCHEMA = vol.Schema({
vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
})
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.All({
vol.Required(CONF_HOST): cv.string
})
DOMAIN: vol.Any(
_V1_SCHEMA,
_V2_SCHEMA,
)
}, extra=vol.ALLOW_EXTRA)


@@ -25,14 +37,16 @@

intouch_data = hass.data[DOMAIN] = {}

hostname = hass_config[DOMAIN][CONF_HOST]
kwargs = dict(hass_config[DOMAIN])
hostname = kwargs.pop(CONF_HOST)

try:
client = intouch_data['client'] = InComfortClient(
hostname, session=async_get_clientsession(hass)
client = intouch_data['client'] = InTouchGateway(
hostname, **kwargs, session=async_get_clientsession(hass)
)

await client.gateway.update()
heaters = await client.heaters
await heaters[0].update()

except AssertionError: # assert response.status == HTTP_OK
_LOGGER.warning(
@@ -41,6 +55,23 @@
return False

hass.async_create_task(async_load_platform(
hass, 'climate', DOMAIN, {}, hass_config))
hass, 'water_heater', DOMAIN, {}, hass_config))

hass.async_create_task(async_load_platform(
hass, 'sensor', DOMAIN, {}, hass_config))

hass.async_create_task(async_load_platform(
hass, 'binary_sensor', DOMAIN, {}, hass_config))

if len(heaters[0].rooms) > -1: # TODO: should be > 0
hass.async_create_task(async_load_platform(
hass, 'climate', DOMAIN, {}, hass_config))

@callback
def _first_update(event):
"""When HA has started, tell the hub to retrieve it's first update."""
async_dispatcher_send(hass, DOMAIN, {'signal': 'update'})

# hass.bus.listen(EVENT_HOMEASSISTANT_START, _first_update)

return True
@@ -0,0 +1,113 @@
"""Support for the Sensors of an Intouch Lan2RF gateway."""
import asyncio
import logging

from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect

from . import DOMAIN

_LOGGER = logging.getLogger(__name__)


async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Set up an Intouch sensor entity."""
client = hass.data[DOMAIN]['client']

water_heaters = await client.heaters
await water_heaters[0].update()

async_add_entities([
IntouchBurning(client, water_heaters[0]),
IntouchPumping(client, water_heaters[0]),
IntouchTapping(client, water_heaters[0]),
IntouchFailed(client, water_heaters[0])
])


class IntouchBinarySensor(BinarySensorDevice):
"""Representation of an InTouch binary sensor."""

async def async_added_to_hass(self):
"""Set up a listener when this entity is added to HA."""
async_dispatcher_connect(self.hass, DOMAIN, self._connect)

@callback
def _connect(self, packet):
if packet['signal'] == 'refresh':
self.async_schedule_update_ha_state(force_refresh=True)

def __init__(self, client, boiler):
"""Initialize the binary sensor."""
self._client = client
self._objref = boiler

@property
def name(self):
"""Return the name of the sensor."""
return self._name

@property
def is_on(self):
"""Return the status of the sensor."""
return self._is_on

@property
def should_poll(self) -> bool:
"""Return True as this device should never be polled."""
return False

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("Update for %s failed, message: %s",
self._id, err)


class IntouchBurning(IntouchBinarySensor):
"""Representation of an InTouch Burning sensor."""

def __init__(self, client, boiler):
"""Initialize the binary sensor."""
super().__init__(client, boiler)

self._name = 'Burning'
self._is_on = self._objref.is_burning


class IntouchFailed(IntouchBinarySensor):
"""Representation of an InTouch Failed sensor."""

def __init__(self, client, boiler):
"""Initialize the binary sensor."""
super().__init__(client, boiler)

self._name = 'Failed'
self._is_on = self._objref.is_failed


class IntouchPumping(IntouchBinarySensor):
"""Representation of an InTouch Pumping sensor."""

def __init__(self, client, boiler):
"""Initialize the binary sensor."""
super().__init__(client, boiler)

self._name = 'Pumping'
self._is_on = self._objref.is_pumping


class IntouchTapping(IntouchBinarySensor):
"""Representation of an InTouch Tapping sensor."""

def __init__(self, client, boiler):
"""Initialize the binary sensor."""
super().__init__(client, boiler)

self._name = 'Tapping'
self._is_on = self._objref.is_tapping
@@ -0,0 +1,110 @@
"""Support for a Room thermostat attached to an Intouch Lan2RF gateway."""
import asyncio
import logging

from homeassistant.components.climate import ClimateDevice
from homeassistant.components.climate.const import SUPPORT_TARGET_TEMPERATURE
from homeassistant.const import (ATTR_TEMPERATURE, TEMP_CELSIUS)
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect

from . import DOMAIN

_LOGGER = logging.getLogger(__name__)

INTOUCH_SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE

INTOUCH_MAX_TEMP = 28.0
INTOUCH_MIN_TEMP = 4.0


async def async_setup_platform(hass, hass_config, async_add_entities,
discovery_info=None):
"""Set up an Intouch climate entity."""
client = hass.data[DOMAIN]['client']

water_heaters = await client.heaters
await water_heaters[0].update()
water_heater = water_heaters[0]

async_add_entities(
[InTouchClimate(client, water_heater.rooms[0])
])


class InTouchClimate(ClimateDevice):
"""Representation of an InTouch climate device."""

def __init__(self, client, room):
"""Initialize the climate device."""
self._client = client
self._objref = room
self._name = 'Room'

async def async_added_to_hass(self):
"""Set up a listener when this entity is added to HA."""
async_dispatcher_connect(self.hass, DOMAIN, self._connect)

@callback
def _connect(self, packet):
if packet['signal'] == 'refresh':
self.async_schedule_update_ha_state(force_refresh=True)

@property
def name(self):
"""Return the name of the climate device."""
return self._name

@property
def device_state_attributes(self):
"""Return the device state attributes."""
return {'status': self._objref.status}

@property
def current_temperature(self):
"""Return the current temperature."""
return self._objref.room_temp

@property
def target_temperature(self):
"""Return the temperature we try to reach."""
return self._objref.override # self._objref.setpoint

@property
def min_temp(self):
"""Return max valid temperature that can be set."""
return INTOUCH_MIN_TEMP

@property
def max_temp(self):
"""Return max valid temperature that can be set."""
return INTOUCH_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 INTOUCH_SUPPORT_FLAGS

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)

@property
def should_poll(self) -> bool:
"""Return True as this device should never be polled."""
return False

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("Update for %s failed, message: %s",
# self._name, err)
@@ -3,7 +3,7 @@
"name": "Intergas Intouch Lan2RF gateway",
"documentation": "https://www.home-assistant.io/components/intouch",
"requirements": [
"intouch-client==0.1.0"
"intouch-client==0.2.2"
],
"dependencies": [],
"codeowners": [
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.