Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 28 additions & 15 deletions homeassistant/components/plugwise/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
HVAC_MODE_AUTO,
HVAC_MODE_HEAT,
HVAC_MODE_HEAT_COOL,
HVAC_MODE_OFF,
SUPPORT_PRESET_MODE,
SUPPORT_TARGET_TEMPERATURE,
)
Expand Down Expand Up @@ -66,7 +67,7 @@


def setup_platform(hass, config, add_entities, discovery_info=None):
"""Add the Plugwise (Anna) Thermostate."""
"""Add the Plugwise (Anna) Thermostat."""
api = haanna.Haanna(
config[CONF_USERNAME],
config[CONF_PASSWORD],
Expand All @@ -88,22 +89,26 @@ def setup_platform(hass, config, add_entities, discovery_info=None):


class ThermostatDevice(ClimateDevice):
"""Representation of an Plugwise thermostat."""
"""Representation of the Plugwise thermostat."""

def __init__(self, api, name, min_temp, max_temp):
"""Set up the Plugwise API."""
self._api = api
self._min_temp = min_temp
self._max_temp = max_temp
self._name = name
self._direct_objects = None
self._domain_objects = None
self._outdoor_temperature = None
self._selected_schema = None
self._last_active_schema = None
self._preset_mode = None
self._presets = None
self._presets_list = None
self._boiler_status = None
self._heating_status = None
self._cooling_status = None
self._dhw_status = None
self._schema_names = None
self._schema_status = None
self._current_temperature = None
Expand All @@ -115,8 +120,8 @@ def __init__(self, api, name, min_temp, max_temp):

@property
def hvac_action(self):
"""Return the current action."""
if self._heating_status:
"""Return the current hvac action."""
if self._heating_status or self._boiler_status or self._dhw_status:
return CURRENT_HVAC_HEAT
if self._cooling_status:
return CURRENT_HVAC_COOL
Expand All @@ -143,8 +148,10 @@ def device_state_attributes(self):
attributes = {}
if self._outdoor_temperature:
attributes["outdoor_temperature"] = self._outdoor_temperature
attributes["available_schemas"] = self._schema_names
attributes["selected_schema"] = self._selected_schema
if self._schema_names:
attributes["available_schemas"] = self._schema_names
if self._selected_schema:
attributes["selected_schema"] = self._selected_schema
if self._boiler_temperature:
attributes["boiler_temperature"] = self._boiler_temperature
if self._water_pressure:
Expand All @@ -162,7 +169,7 @@ def preset_modes(self):
@property
def hvac_modes(self):
"""Return the available hvac modes list."""
if self._heating_status is not None:
if self._heating_status is not None or self._boiler_status is not None:
if self._cooling_status is not None:
return HVAC_MODES_2
return HVAC_MODES_1
Expand All @@ -173,11 +180,11 @@ def hvac_mode(self):
"""Return current active hvac state."""
if self._schema_status:
return HVAC_MODE_AUTO
if self._heating_status:
if self._heating_status or self._boiler_status or self._dhw_status:
if self._cooling_status:
return HVAC_MODE_HEAT_COOL
return HVAC_MODE_HEAT
return None
return HVAC_MODE_OFF

@property
def target_temperature(self):
Expand All @@ -193,9 +200,9 @@ def target_temperature(self):
def preset_mode(self):
"""Return the active selected schedule-name.

Or return the active preset, or return Temporary in case of a manual change
in the set-temperature with a weekschedule active,
or return Manual in case of a manual change and no weekschedule active.
Or, return the active preset, or return Temporary in case of a manual change
in the set-temperature with a weekschedule active.
Or return Manual in case of a manual change and no weekschedule active.
"""
if self._presets:
presets = self._presets
Expand Down Expand Up @@ -248,7 +255,7 @@ def set_hvac_mode(self, hvac_mode):
if hvac_mode == HVAC_MODE_AUTO:
schema_mode = "true"
self._api.set_schema_state(
self._domain_objects, self._selected_schema, schema_mode
self._domain_objects, self._last_active_schema, schema_mode
)

def set_preset_mode(self, preset_mode):
Expand All @@ -259,16 +266,22 @@ def set_preset_mode(self, preset_mode):
def update(self):
"""Update the data from the thermostat."""
_LOGGER.debug("Update called")
self._direct_objects = self._api.get_direct_objects()
self._domain_objects = self._api.get_domain_objects()
self._outdoor_temperature = self._api.get_outdoor_temperature(
self._domain_objects
)
self._selected_schema = self._api.get_active_schema_name(self._domain_objects)
self._last_active_schema = self._api.get_last_active_schema_name(
self._domain_objects
)
self._preset_mode = self._api.get_current_preset(self._domain_objects)
self._presets = self._api.get_presets(self._domain_objects)
self._presets_list = list(self._api.get_presets(self._domain_objects))
self._heating_status = self._api.get_heating_status(self._domain_objects)
self._cooling_status = self._api.get_cooling_status(self._domain_objects)
self._boiler_status = self._api.get_boiler_status(self._direct_objects)
self._heating_status = self._api.get_heating_status(self._direct_objects)
self._cooling_status = self._api.get_cooling_status(self._direct_objects)
self._dhw_status = self._api.get_domestic_hot_water_status(self._direct_objects)
self._schema_names = self._api.get_schema_names(self._domain_objects)
self._schema_status = self._api.get_schema_state(self._domain_objects)
self._current_temperature = self._api.get_current_temperature(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/plugwise/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"documentation": "https://www.home-assistant.io/integrations/plugwise",
"dependencies": [],
"codeowners": ["@laetificat", "@CoMPaTech", "@bouwew"],
"requirements": ["haanna==0.13.5"]
"requirements": ["haanna==0.14.1"]
}
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ ha-ffmpeg==2.0
ha-philipsjs==0.0.8

# homeassistant.components.plugwise
haanna==0.13.5
haanna==0.14.1

# homeassistant.components.habitica
habitipy==0.2.0
Expand Down