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 support for IntesisHome controllable air conditioners #8316
Conversation
@property | ||
def is_away_mode_on(self): | ||
"""Return if away mode is on.""" | ||
return 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.
no newline at end of file
def update_callback(self): | ||
"""Called when data is received by pyIntesishome""" | ||
_LOGGER.debug("IntesisHome sent a status update.") | ||
self.hass.async_add_job(self.update_ha_state,True) |
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.
missing whitespace after ','
intesishome.poll_status(shouldCallback) | ||
|
||
|
||
@property |
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.
too many blank lines (2)
self._swing = STATE_UNKNOWN | ||
|
||
|
||
@Throttle(MIN_TIME_BETWEEN_UPDATES) |
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.
too many blank lines (2)
self._current_operation = STATE_UNKNOWN | ||
|
||
# Target temperature | ||
if self._current_operation in [STATE_OFF,STATE_FAN]: |
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.
missing whitespace after ','
self._fan_speed = STATE_UNKNOWN | ||
self._current_operation = STATE_UNKNOWN | ||
|
||
self._operation_list = [STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_DRY, STATE_FAN, STATE_OFF] |
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.
line too long (100 > 79 characters)
class IntesisAC(ClimateDevice): | ||
def __init__(self, deviceid, device): | ||
"""Initialize the thermostat""" | ||
_LOGGER.debug('Added climate device with state: %s',repr(device)) |
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.
missing whitespace after ','
for deviceid, device in intesishome.get_devices().items()]) | ||
return True | ||
|
||
class IntesisAC(ClimateDevice): |
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.
expected 2 blank lines, found 1
add_devices([IntesisAC(deviceid, device) | ||
for deviceid, device in intesishome.get_devices().items()]) | ||
return True | ||
|
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.
blank line contains whitespace
intesishome.connect() | ||
|
||
if intesishome.error_message: | ||
persistent_notification.create(hass, intesishome.error_message, "IntesisHome Error", 'intesishome') |
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.
line too long (107 > 79 characters)
self._operation_list = [STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_DRY, | ||
STATE_FAN, STATE_OFF] | ||
self._fan_list = [STATE_AUTO, STATE_QUIET, STATE_LOW, STATE_MEDIUM, | ||
STATE_HIGH] |
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.
continuation line under-indented for visual indent
self._current_operation = STATE_UNKNOWN | ||
|
||
self._operation_list = [STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_DRY, | ||
STATE_FAN, STATE_OFF] |
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.
continuation line under-indented for visual indent
|
||
if intesishome.error_message: | ||
persistent_notification.create(hass, intesishome.error_message, | ||
"IntesisHome Error", 'intesishome') |
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.
continuation line under-indented for visual indent
_pass = config.get(CONF_PASSWORD) | ||
|
||
if intesishome is None: | ||
intesishome = IntesisHome(_user,_pass, hass.loop) |
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.
missing whitespace after ','
|
||
_user = config.get(CONF_USERNAME) | ||
_pass = config.get(CONF_PASSWORD) | ||
|
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.
blank line contains whitespace
}) | ||
|
||
# Return cached results if last scan time was less than this value. | ||
# If a persistent connection is established for the controller, changes to values are in realtime. |
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.
line too long (98 > 79 characters)
from homeassistant.components.climate import ( ClimateDevice, | ||
PLATFORM_SCHEMA, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, | ||
ATTR_TEMPERATURE, ATTR_OPERATION_MODE) | ||
from homeassistant.const import (TEMP_CELSIUS, CONF_SCAN_INTERVAL, STATE_UNKNOWN) |
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.
'homeassistant.const.CONF_SCAN_INTERVAL' imported but unused
line too long (81 > 79 characters)
from homeassistant.components import persistent_notification | ||
from homeassistant.components.climate import ( ClimateDevice, | ||
PLATFORM_SCHEMA, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, | ||
ATTR_TEMPERATURE, ATTR_OPERATION_MODE) |
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.
continuation line under-indented for visual indent
from homeassistant.util import Throttle | ||
from homeassistant.components import persistent_notification | ||
from homeassistant.components.climate import ( ClimateDevice, | ||
PLATFORM_SCHEMA, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, |
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.
continuation line under-indented for visual indent
from homeassistant.const import (CONF_PASSWORD, CONF_USERNAME, CONF_STRUCTURE) | ||
from homeassistant.util import Throttle | ||
from homeassistant.components import persistent_notification | ||
from homeassistant.components.climate import ( ClimateDevice, |
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.
'homeassistant.components.climate.ATTR_TARGET_TEMP_HIGH' imported but unused
'homeassistant.components.climate.ATTR_TARGET_TEMP_LOW' imported but unused
whitespace after '('
}) | ||
|
||
# Return cached results if last scan time was less than this value. | ||
# If a persistent connection is established for the controller, |
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.
trailing whitespace
def is_away_mode_on(self): | ||
"""Return if away mode is on.""" | ||
return 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.
blank line at end of file
This reverts commit 02baeb9.
|
||
class IntesisAC(ClimateDevice): | ||
"""Representation of an IntesisHome thermostat.""" | ||
|
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.
blank line contains whitespace
This reverts commit 85ebbe6.
I'm not sure how to resolve the following issues from Travis - is someone able to kindly advise? C: 55, 0: Invalid constant name "intesishome" (invalid-name) |
Suggest you update the description file to include your .io PR. |
def setup_platform(hass, config, add_devices, discovery_info=None): | ||
"""Set up the IntesisHome interface.""" | ||
from pyintesishome import IntesisHome | ||
global INTESISHOME |
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 use hass.data
.
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.
Thanks for your review Fabian, I've now switched the platform over to using hass.data
.coveragerc
Outdated
@@ -228,6 +228,7 @@ omit = | |||
homeassistant/components/climate/proliphix.py | |||
homeassistant/components/climate/radiotherm.py | |||
homeassistant/components/climate/sensibo.py | |||
homeassistant/components/climate/intesishome.py |
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 list alphabetically ordered.
Replaced with hass.data['climate_intesishome']
Migrated to using hass.data[‘climate_intesishome’]
self._intesishome.set_mode_dry(self._deviceid) | ||
|
||
if self._target_temp: | ||
self._intesishome.set_temperature(self._deviceid, self._target_temp) |
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.
line too long (84 > 79 characters)
self._intesishome.set_mode_dry(self._deviceid) | ||
|
||
if self._target_temp: | ||
self._intesishome.set_temperature(self._deviceid, |
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.
trailing whitespace
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.
Use the common climate states already defined in the climate component for representing the operation_mode state in home assistant. Implement conversion logic to go between home assistant states and device specific states.
|
||
import logging | ||
from datetime import timedelta | ||
import voluptuous as vol |
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.
Add a blank line between standard library, third party and homeassistant imports.
https://www.python.org/dev/peps/pep-0008/#imports
from datetime import timedelta
import voluptuous as vol
from datetime import timedelta | ||
import voluptuous as vol | ||
import homeassistant.helpers.config_validation as cv | ||
from homeassistant.const import (CONF_PASSWORD, CONF_USERNAME, CONF_STRUCTURE) |
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.
Sort the import lines alphabetically within each bigger group, standard, 3rd party and homeassistant, and also sort each imported object alphabetially on the same line.
_LOGGER = logging.getLogger(__name__) | ||
|
||
DEFAULT_NAME = 'IntesisHome' | ||
REQUIREMENTS = ['pyintesishome==0.4'] |
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.
Place this right after imports.
https://home-assistant.io/developers/development_guidelines/#requirements
STATE_LOW = 'Low' | ||
STATE_MEDIUM = 'Medium' | ||
STATE_HIGH = 'High' | ||
STATE_OFF = 'Off' |
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.
Home assistant should use its own state names for the climate platforms in the GUI and automation API and convert to device specific states before interacting with a climate device.
Implement two conversion dicts that converts the device specific states to home assistant states and vice versa. Rename the constants you've defined here so that it's clear that they are device specific, and then import the home assistant states from climate base component and const.py.
# Python 3.4.3 and ealier has this as async | ||
# pylint: disable=unused-import | ||
from asyncio import async | ||
ensure_future = async |
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.
ensure_future
is not used.
fan_speed = self._intesishome.get_fan_speed(self._deviceid) | ||
if fan_speed: | ||
# Capitalize fan speed from pyintesishome | ||
self._fan_speed = fan_speed[:1].upper() + fan_speed[1:] |
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.
return self._target_temp | ||
|
||
@property | ||
def target_temperature_low(self): |
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.
Remove if not overwritten.
return None | ||
|
||
@property | ||
def target_temperature_high(self): |
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.
Remove if not overwritten.
return None | ||
|
||
@property | ||
def is_away_mode_on(self): |
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.
Remove if not overwritten.
if 42 in device.get('widgets'): | ||
self._has_swing_control = True | ||
|
||
self._intesishome.add_update_callback(self.update_callback) |
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.
Move this to a async_added_to_hass
method.
@jnimmo any updates on this PR? |
def update_callback(self): | ||
"""Called when data is received by pyIntesishome.""" | ||
_LOGGER.debug("IntesisHome sent a status update.") | ||
self.hass.async_add_job(self.update_ha_state, True) |
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.
Hi there,
I have a lot of deprecation warning assuming caused by this line.
WARNING (Thread-5) [homeassistant.helpers.entity] 'update_ha_state' is deprecated. Use 'schedule_update_ha_state' instead.
Waiting on this PR as well. @jnimmo Just put in a comment in intesishome.py line 277, lots of deprecation warning |
Can be reopen if all comments are addressed |
Description:
Added support for IntesisHome controlled air conditioners.
Work in progress, first time submitting a component so please let me know if anything needs changing.
This platform has been in use by a number of testers on https://community.home-assistant.io/t/add-support-for-intesishome-wifi-ac-control/5172 - initially was added as an IntesisHome platform and climate component however combined it into the one climate component.
Pull request in home-assistant.github.io with documentation: home-assistant/home-assistant.io#2925
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass