Skip to content
Merged
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
28 changes: 22 additions & 6 deletions homeassistant/components/proliphix/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateDevice
from homeassistant.components.climate.const import (
CURRENT_HVAC_COOL,
CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE,
CURRENT_HVAC_OFF,
HVAC_MODE_COOL,
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
Expand Down Expand Up @@ -37,6 +41,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
host = config.get(CONF_HOST)

pdp = proliphix.PDP(host, username, password)
pdp.update()
Comment thread
MartinHjelmare marked this conversation as resolved.

add_entities([ProliphixThermostat(pdp)], True)

Expand All @@ -47,7 +52,7 @@ class ProliphixThermostat(ClimateDevice):
def __init__(self, pdp):
"""Initialize the thermostat."""
self._pdp = pdp
self._name = self._pdp.name
self._name = None

@property
def supported_features(self):
Expand All @@ -62,6 +67,7 @@ def should_poll(self):
def update(self):
"""Update the data from the thermostat."""
self._pdp.update()
self._name = self._pdp.name

@property
def name(self):
Expand Down Expand Up @@ -97,16 +103,26 @@ def target_temperature(self):
"""Return the temperature we try to reach."""
return self._pdp.setback

@property
def hvac_action(self):
"""Return the current state of the thermostat."""
state = self._pdp.hvac_state
Comment thread
MartinHjelmare marked this conversation as resolved.
if state == 1:
return CURRENT_HVAC_OFF
if state in (3, 4, 5):
return CURRENT_HVAC_HEAT
if state in (6, 7):
return CURRENT_HVAC_COOL
return CURRENT_HVAC_IDLE

@property
def hvac_mode(self):
"""Return the current state of the thermostat."""
state = self._pdp.hvac_mode
if state in (1, 2):
return HVAC_MODE_OFF
if state == 3:
if self._pdp.is_heating:
return HVAC_MODE_HEAT
if state == 6:
if self._pdp.is_cooling:
return HVAC_MODE_COOL
return HVAC_MODE_OFF

@property
def hvac_modes(self):
Expand Down