mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix proliphix (#34397)
* Retrieve the name of the Proliphix thermostat before adding the entities * The proliphix module provides hvac_state, not hvac_mode * Removed update before add_entities. Moved the setting of the name into the update function instead. * Disentangled hvac_mode and hvac_action * Ran black and isort
This commit is contained in:
parent
8c84e47c94
commit
2f31b8576e
@ -4,6 +4,10 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
|
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
|
CURRENT_HVAC_COOL,
|
||||||
|
CURRENT_HVAC_HEAT,
|
||||||
|
CURRENT_HVAC_IDLE,
|
||||||
|
CURRENT_HVAC_OFF,
|
||||||
HVAC_MODE_COOL,
|
HVAC_MODE_COOL,
|
||||||
HVAC_MODE_HEAT,
|
HVAC_MODE_HEAT,
|
||||||
HVAC_MODE_OFF,
|
HVAC_MODE_OFF,
|
||||||
@ -37,6 +41,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
|
|
||||||
pdp = proliphix.PDP(host, username, password)
|
pdp = proliphix.PDP(host, username, password)
|
||||||
|
pdp.update()
|
||||||
|
|
||||||
add_entities([ProliphixThermostat(pdp)], True)
|
add_entities([ProliphixThermostat(pdp)], True)
|
||||||
|
|
||||||
@ -47,7 +52,7 @@ class ProliphixThermostat(ClimateEntity):
|
|||||||
def __init__(self, pdp):
|
def __init__(self, pdp):
|
||||||
"""Initialize the thermostat."""
|
"""Initialize the thermostat."""
|
||||||
self._pdp = pdp
|
self._pdp = pdp
|
||||||
self._name = self._pdp.name
|
self._name = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
@ -62,6 +67,7 @@ class ProliphixThermostat(ClimateEntity):
|
|||||||
def update(self):
|
def update(self):
|
||||||
"""Update the data from the thermostat."""
|
"""Update the data from the thermostat."""
|
||||||
self._pdp.update()
|
self._pdp.update()
|
||||||
|
self._name = self._pdp.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -97,16 +103,26 @@ class ProliphixThermostat(ClimateEntity):
|
|||||||
"""Return the temperature we try to reach."""
|
"""Return the temperature we try to reach."""
|
||||||
return self._pdp.setback
|
return self._pdp.setback
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hvac_action(self):
|
||||||
|
"""Return the current state of the thermostat."""
|
||||||
|
state = self._pdp.hvac_state
|
||||||
|
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
|
@property
|
||||||
def hvac_mode(self):
|
def hvac_mode(self):
|
||||||
"""Return the current state of the thermostat."""
|
"""Return the current state of the thermostat."""
|
||||||
state = self._pdp.hvac_mode
|
if self._pdp.is_heating:
|
||||||
if state in (1, 2):
|
|
||||||
return HVAC_MODE_OFF
|
|
||||||
if state == 3:
|
|
||||||
return HVAC_MODE_HEAT
|
return HVAC_MODE_HEAT
|
||||||
if state == 6:
|
if self._pdp.is_cooling:
|
||||||
return HVAC_MODE_COOL
|
return HVAC_MODE_COOL
|
||||||
|
return HVAC_MODE_OFF
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_modes(self):
|
def hvac_modes(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user