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

Climate 1.0 #23899

Merged
merged 92 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
fa0fa7b
Climate 1.0 / part 1/2/3
pvizeli May 14, 2019
f7ddeeb
fix flake
pvizeli Jul 2, 2019
3cf4152
Lint
balloob Jul 2, 2019
b528df5
Update Google Assistant
balloob Jul 2, 2019
6f258ea
ambiclimate to climate 1.0 (#24911)
Danielhiversen Jul 2, 2019
4039f63
Fix Alexa
balloob Jul 2, 2019
2f4302f
Lint
balloob Jul 2, 2019
93ef963
Migrate zhong_hong
balloob Jul 2, 2019
83a2ae1
Migrate tuya
balloob Jul 2, 2019
fe34f0d
Migrate honeywell to new climate schema (#24257)
zxdavb Jul 2, 2019
5c5bae7
Migrate radiotherm
balloob Jul 2, 2019
8e3635d
Convert touchline
balloob Jul 2, 2019
c190d09
Migrate flexit
balloob Jul 2, 2019
320c871
Migrate nuheat
balloob Jul 2, 2019
c8e5498
Migrate maxcube
balloob Jul 2, 2019
e9bbb83
Fix names maxcube const
balloob Jul 2, 2019
d2e9b63
Migrate proliphix
balloob Jul 2, 2019
c60a242
Migrate heatmiser
balloob Jul 2, 2019
bcc1d2d
Migrate fritzbox
balloob Jul 2, 2019
287608c
Migrate opentherm_gw
balloob Jul 3, 2019
73b7a9d
Migrate venstar
balloob Jul 3, 2019
d0e457a
Migrate daikin
Swamp-Ig Jul 3, 2019
7a0eb74
Migrate modbus
balloob Jul 3, 2019
4ebd613
Fix elif
balloob Jul 3, 2019
34fff85
Migrate Homematic IP Cloud to climate-1.0 (#24913)
SukramJ Jul 3, 2019
4900729
Migrate generic_thermostat
pvizeli Jul 3, 2019
1aa54b6
Merge branch 'climate-1.0' of https://github.com/home-assistant/home-…
pvizeli Jul 3, 2019
cea306b
Migrate incomfort to new climate schema (#24915)
zxdavb Jul 3, 2019
752dee1
Migrate eq3btsmart
pvizeli Jul 3, 2019
953c2ac
Merge branch 'climate-1.0' of https://github.com/home-assistant/home-…
pvizeli Jul 3, 2019
a536cc3
Lint
balloob Jul 3, 2019
31fe4a9
cleanup PRESET_MANUAL
pvizeli Jul 3, 2019
bfd3794
Migrate ecobee
balloob Jul 3, 2019
52910c9
No conditional features
balloob Jul 3, 2019
ce3dc7a
KNX: Migrate climate component to new climate platform (#24931)
marvin-w Jul 3, 2019
f01887b
Lint
balloob Jul 3, 2019
2f3072b
fix tests
pvizeli Jul 4, 2019
5a8580a
Fix value
pvizeli Jul 4, 2019
8f22c9c
Migrate geniushub to new climate schema (#24191)
zxdavb Jul 4, 2019
23d3ce1
WIP: Fixes for honeywell migration to climate-1.0 (#24938)
zxdavb Jul 4, 2019
da94554
Fixes for incomfort migration to climate-1.0 (#24936)
zxdavb Jul 5, 2019
f8ca4cc
Fix homekit_controller on climate-1.0 (#24948)
Jc2k Jul 5, 2019
80f4276
lint
balloob Jul 5, 2019
be93844
Fix imports
balloob Jul 5, 2019
4faf1d1
Migrate stibel_eltron
pvizeli Jul 5, 2019
99db0b8
Merge branch 'climate-1.0' of https://github.com/home-assistant/home-…
pvizeli Jul 5, 2019
705aa83
Fix lint
pvizeli Jul 5, 2019
42d3d12
Migrate coolmaster to climate 1.0 (#24967)
OnFreund Jul 5, 2019
c81215b
Fix demo to work with UI
balloob Jul 5, 2019
c5e4469
Migrate spider
pvizeli Jul 5, 2019
e6e39bc
Demo update
balloob Jul 5, 2019
d61e244
Updated frontend to 20190705.0
balloob Jul 5, 2019
6bdee22
Merge remote-tracking branch 'origin/dev' into climate-1.0
balloob Jul 5, 2019
99ecc65
Fix boost mode (#24980)
SukramJ Jul 6, 2019
0d34dc9
Prepare Netatmo for climate 1.0 (#24973)
cgtobi Jul 6, 2019
51f0469
Migrate ephember
balloob Jul 6, 2019
d6ed6e8
Migrate Sensibo
balloob Jul 6, 2019
f13072b
Implemented review comments (#24942)
Jul 6, 2019
b2a470d
Migrate ESPHome
balloob Jul 6, 2019
644e440
Migrate MQTT
balloob Jul 6, 2019
363c883
Migrate Nest
balloob Jul 6, 2019
39232b8
Migrate melissa
balloob Jul 6, 2019
cc8340e
Initial/partial migration of ST
andrewsayre Jul 6, 2019
79e7dad
Merge branch 'climate-1.0' of https://github.com/home-assistant/home-…
andrewsayre Jul 6, 2019
3ac81e0
Migrate ST
andrewsayre Jul 6, 2019
69578da
Remove Away mode (#24995)
SukramJ Jul 7, 2019
63bbb85
Migrate evohome, cache access tokens (#24491)
zxdavb Jul 7, 2019
873f953
Migrate homekit
pvizeli Jul 7, 2019
a5f8f65
Cleanup away mode
pvizeli Jul 7, 2019
0d82f07
Fix tests
pvizeli Jul 7, 2019
7fd7092
add helpers
pvizeli Jul 7, 2019
f094d37
fix tests melissa
pvizeli Jul 7, 2019
de17b1b
Fix nehueat
pvizeli Jul 7, 2019
6d9d31e
fix zwave
pvizeli Jul 7, 2019
3bf8029
add more tests
pvizeli Jul 7, 2019
1dca06c
fix deconz
pvizeli Jul 7, 2019
686e145
Fix climate test emulate_hue
pvizeli Jul 7, 2019
a078b04
fix tests
pvizeli Jul 7, 2019
94dd612
fix dyson tests
pvizeli Jul 7, 2019
7a4b18e
fix demo with new layout
pvizeli Jul 7, 2019
d2bbffc
fix honeywell
pvizeli Jul 7, 2019
d289258
Switch homekit_controller to use HVAC_MODE_HEAT_COOL instead of HVAC_…
Jc2k Jul 7, 2019
a233b77
Lint
balloob Jul 7, 2019
aa4c645
PyLint
balloob Jul 7, 2019
60bb29f
Pylint
balloob Jul 7, 2019
4253617
fix fritzbox tests
pvizeli Jul 8, 2019
3345f10
Fix google
pvizeli Jul 8, 2019
7c0e954
Fix all tests
pvizeli Jul 8, 2019
fcd9033
Fix lint
pvizeli Jul 8, 2019
0212e2c
Fix auto for homekit like controler
pvizeli Jul 8, 2019
d28b44d
Fix lint
pvizeli Jul 8, 2019
c716ee2
fix lint
pvizeli Jul 8, 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
37 changes: 22 additions & 15 deletions homeassistant/components/alexa/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .const import (
API_TEMP_UNITS,
API_THERMOSTAT_MODES,
API_THERMOSTAT_PRESETS,
DATE_FORMAT,
PERCENTAGE_FAN_MAP,
)
Expand Down Expand Up @@ -180,9 +181,13 @@ def get_property(self, name):
if name != 'powerState':
raise UnsupportedProperty(name)

if self.entity.state == STATE_OFF:
return 'OFF'
return 'ON'
if self.entity.domain == climate.DOMAIN:
is_on = self.entity.state != climate.HVAC_MODE_OFF

else:
is_on = self.entity.state != STATE_OFF

return 'ON' if is_on else 'OFF'


class AlexaLockController(AlexaCapibility):
Expand Down Expand Up @@ -546,16 +551,13 @@ def name(self):

def properties_supported(self):
"""Return what properties this entity supports."""
properties = []
properties = [{'name': 'thermostatMode'}]
supported = self.entity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
if supported & climate.SUPPORT_TARGET_TEMPERATURE:
properties.append({'name': 'targetSetpoint'})
if supported & climate.SUPPORT_TARGET_TEMPERATURE_LOW:
if supported & climate.SUPPORT_TARGET_TEMPERATURE_RANGE:
properties.append({'name': 'lowerSetpoint'})
if supported & climate.SUPPORT_TARGET_TEMPERATURE_HIGH:
properties.append({'name': 'upperSetpoint'})
if supported & climate.SUPPORT_OPERATION_MODE:
properties.append({'name': 'thermostatMode'})
return properties

def properties_proactively_reported(self):
Expand All @@ -569,13 +571,18 @@ def properties_retrievable(self):
def get_property(self, name):
"""Read and return a property."""
if name == 'thermostatMode':
ha_mode = self.entity.attributes.get(climate.ATTR_OPERATION_MODE)
mode = API_THERMOSTAT_MODES.get(ha_mode)
if mode is None:
_LOGGER.error("%s (%s) has unsupported %s value '%s'",
self.entity.entity_id, type(self.entity),
climate.ATTR_OPERATION_MODE, ha_mode)
raise UnsupportedProperty(name)
preset = self.entity.attributes.get(climate.ATTR_PRESET_MODE)

if preset in API_THERMOSTAT_PRESETS:
mode = API_THERMOSTAT_PRESETS[preset]
else:
mode = API_THERMOSTAT_MODES.get(self.entity.state)
if mode is None:
_LOGGER.error(
"%s (%s) has unsupported state value '%s'",
self.entity.entity_id, type(self.entity),
self.entity.state)
raise UnsupportedProperty(name)
return mode

unit = self.hass.config.units.temperature_unit
Expand Down
20 changes: 10 additions & 10 deletions homeassistant/components/alexa/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from collections import OrderedDict

from homeassistant.const import (
STATE_OFF,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
)
Expand Down Expand Up @@ -57,16 +56,17 @@
# reverse mapping of this dict and we want to map the first occurrance of OFF
# back to HA state.
API_THERMOSTAT_MODES = OrderedDict([
(climate.STATE_HEAT, 'HEAT'),
(climate.STATE_COOL, 'COOL'),
(climate.STATE_AUTO, 'AUTO'),
(climate.STATE_ECO, 'ECO'),
(climate.STATE_MANUAL, 'AUTO'),
(STATE_OFF, 'OFF'),
(climate.STATE_IDLE, 'OFF'),
(climate.STATE_FAN_ONLY, 'OFF'),
(climate.STATE_DRY, 'OFF'),
(climate.HVAC_MODE_HEAT, 'HEAT'),
(climate.HVAC_MODE_COOL, 'COOL'),
(climate.HVAC_MODE_HEAT_COOL, 'AUTO'),
(climate.HVAC_MODE_AUTO, 'AUTO'),
(climate.HVAC_MODE_OFF, 'OFF'),
(climate.HVAC_MODE_FAN_ONLY, 'OFF'),
(climate.HVAC_MODE_DRY, 'OFF'),
])
API_THERMOSTAT_PRESETS = {
climate.PRESET_ECO: 'ECO'
}

PERCENTAGE_FAN_MAP = {
fan.SPEED_LOW: 33,
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/alexa/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ def default_display_categories(self):

def interfaces(self):
"""Yield the supported interfaces."""
supported = self.entity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
if supported & climate.SUPPORT_ON_OFF:
# If we support two modes, one being off, we allow turning on too.
if len([v for v in self.entity.attributes[climate.ATTR_HVAC_MODES]
if v != climate.HVAC_MODE_OFF]) == 1:
yield AlexaPowerController(self.entity)

yield AlexaThermostatController(self.hass, self.entity)
yield AlexaTemperatureSensor(self.hass, self.entity)
yield AlexaEndpointHealth(self.hass, self.entity)
Expand Down
45 changes: 34 additions & 11 deletions homeassistant/components/alexa/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .const import (
API_TEMP_UNITS,
API_THERMOSTAT_MODES,
API_THERMOSTAT_PRESETS,
Cause,
)
from .entities import async_get_entities
Expand Down Expand Up @@ -686,23 +687,45 @@ async def async_api_set_thermostat_mode(hass, config, directive, context):
mode = directive.payload['thermostatMode']
mode = mode if isinstance(mode, str) else mode['value']

operation_list = entity.attributes.get(climate.ATTR_OPERATION_LIST)
ha_mode = next(
(k for k, v in API_THERMOSTAT_MODES.items() if v == mode),
None
)
if ha_mode not in operation_list:
msg = 'The requested thermostat mode {} is not supported'.format(mode)
raise AlexaUnsupportedThermostatModeError(msg)

data = {
ATTR_ENTITY_ID: entity.entity_id,
climate.ATTR_OPERATION_MODE: ha_mode,
}

ha_preset = next(
(k for k, v in API_THERMOSTAT_PRESETS.items() if v == mode),
None
)

if ha_preset:
presets = entity.attributes.get(climate.ATTR_PRESET_MODES, [])

if ha_preset not in presets:
msg = 'The requested thermostat mode {} is not supported'.format(
ha_preset
)
raise AlexaUnsupportedThermostatModeError(msg)

service = climate.SERVICE_SET_PRESET_MODE
data[climate.ATTR_PRESET_MODE] = climate.PRESET_ECO

else:
operation_list = entity.attributes.get(climate.ATTR_HVAC_MODES)
ha_mode = next(
(k for k, v in API_THERMOSTAT_MODES.items() if v == mode),
None
)
if ha_mode not in operation_list:
msg = 'The requested thermostat mode {} is not supported'.format(
mode
)
raise AlexaUnsupportedThermostatModeError(msg)

service = climate.SERVICE_SET_HVAC_MODE
data[climate.ATTR_HVAC_MODE] = ha_mode

response = directive.response()
await hass.services.async_call(
entity.domain, climate.SERVICE_SET_OPERATION_MODE, data,
climate.DOMAIN, service, data,
blocking=False, context=context)
response.add_context_property({
'name': 'thermostatMode',
Expand Down
36 changes: 15 additions & 21 deletions homeassistant/components/ambiclimate/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@

from homeassistant.components.climate import ClimateDevice
from homeassistant.components.climate.const import (
SUPPORT_TARGET_TEMPERATURE,
SUPPORT_ON_OFF, STATE_HEAT)
from homeassistant.const import ATTR_NAME
from homeassistant.const import (ATTR_TEMPERATURE,
STATE_OFF, TEMP_CELSIUS)
SUPPORT_TARGET_TEMPERATURE, HVAC_MODE_OFF, HVAC_MODE_HEAT)
from homeassistant.const import ATTR_NAME, ATTR_TEMPERATURE, TEMP_CELSIUS
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import (ATTR_VALUE, CONF_CLIENT_ID, CONF_CLIENT_SECRET,
Expand All @@ -20,8 +17,7 @@

_LOGGER = logging.getLogger(__name__)

SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE |
SUPPORT_ON_OFF)
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE

SEND_COMFORT_FEEDBACK_SCHEMA = vol.Schema({
vol.Required(ATTR_NAME): cv.string,
Expand Down Expand Up @@ -177,11 +173,6 @@ def current_humidity(self):
"""Return the current humidity."""
return self._data.get('humidity')

@property
def is_on(self):
"""Return true if heater is on."""
return self._data.get('power', '').lower() == 'on'

@property
def min_temp(self):
"""Return the minimum temperature."""
Expand All @@ -198,9 +189,12 @@ def supported_features(self):
return SUPPORT_FLAGS

@property
def current_operation(self):
def hvac_mode(self):
"""Return current operation."""
return STATE_HEAT if self.is_on else STATE_OFF
if self._data.get('power', '').lower() == 'on':
return HVAC_MODE_HEAT

return HVAC_MODE_OFF

async def async_set_temperature(self, **kwargs):
"""Set new target temperature."""
Expand All @@ -209,13 +203,13 @@ async def async_set_temperature(self, **kwargs):
return
await self._heater.set_target_temperature(temperature)

async def async_turn_on(self):
"""Turn device on."""
await self._heater.turn_on()

async def async_turn_off(self):
"""Turn device off."""
await self._heater.turn_off()
async def async_set_hvac_mode(self, hvac_mode):
"""Set new target hvac mode."""
if hvac_mode == HVAC_MODE_HEAT:
await self._heater.turn_on()
return
if hvac_mode == HVAC_MODE_OFF:
await self._heater.turn_off()

async def async_update(self):
"""Retrieve latest state."""
Expand Down
Loading