mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Added new econet states (#21420)
This commit is contained in:
parent
42e691c194
commit
9cff1dd4ba
@ -13,7 +13,7 @@ from homeassistant.const import (
|
|||||||
TEMP_FAHRENHEIT)
|
TEMP_FAHRENHEIT)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['pyeconet==0.0.6']
|
REQUIREMENTS = ['pyeconet==0.0.8']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -43,18 +43,18 @@ DELETE_VACATION_SCHEMA = vol.Schema({
|
|||||||
|
|
||||||
ECONET_DATA = 'econet'
|
ECONET_DATA = 'econet'
|
||||||
|
|
||||||
HA_STATE_TO_ECONET = {
|
ECONET_STATE_TO_HA = {
|
||||||
STATE_ECO: 'Energy Saver',
|
'Energy Saver': STATE_ECO,
|
||||||
STATE_ELECTRIC: 'Electric',
|
'gas': STATE_GAS,
|
||||||
STATE_HEAT_PUMP: 'Heat Pump',
|
'High Demand': STATE_HIGH_DEMAND,
|
||||||
STATE_GAS: 'gas',
|
'Off': STATE_OFF,
|
||||||
STATE_HIGH_DEMAND: 'High Demand',
|
'Performance': STATE_PERFORMANCE,
|
||||||
STATE_OFF: 'Off',
|
'Heat Pump Only': STATE_HEAT_PUMP,
|
||||||
STATE_PERFORMANCE: 'Performance'
|
'Electric-Only': STATE_ELECTRIC,
|
||||||
|
'Electric': STATE_ELECTRIC,
|
||||||
|
'Heat Pump': STATE_HEAT_PUMP
|
||||||
}
|
}
|
||||||
|
|
||||||
ECONET_STATE_TO_HA = {value: key for key, value in HA_STATE_TO_ECONET.items()}
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_USERNAME): cv.string,
|
vol.Required(CONF_USERNAME): cv.string,
|
||||||
vol.Required(CONF_PASSWORD): cv.string,
|
vol.Required(CONF_PASSWORD): cv.string,
|
||||||
@ -110,6 +110,18 @@ class EcoNetWaterHeater(WaterHeaterDevice):
|
|||||||
def __init__(self, water_heater):
|
def __init__(self, water_heater):
|
||||||
"""Initialize the water heater."""
|
"""Initialize the water heater."""
|
||||||
self.water_heater = water_heater
|
self.water_heater = water_heater
|
||||||
|
self.supported_modes = self.water_heater.supported_modes
|
||||||
|
self.econet_state_to_ha = {}
|
||||||
|
for mode in ECONET_STATE_TO_HA.keys():
|
||||||
|
if mode in self.supported_modes:
|
||||||
|
self.econet_state_to_ha[mode] = ECONET_STATE_TO_HA.get(mode)
|
||||||
|
for key, value in self.econet_state_to_ha.itmes():
|
||||||
|
self.ha_state_to_econet[value] = key
|
||||||
|
for mode in self.supported_modes:
|
||||||
|
if mode not in ECONET_STATE_TO_HA:
|
||||||
|
error = "Invalid operation mode mapping. " + mode + \
|
||||||
|
" doesn't map. Please report this."
|
||||||
|
_LOGGER.error(error)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -149,22 +161,17 @@ class EcoNetWaterHeater(WaterHeaterDevice):
|
|||||||
|
|
||||||
["eco", "heat_pump", "high_demand", "electric_only"]
|
["eco", "heat_pump", "high_demand", "electric_only"]
|
||||||
"""
|
"""
|
||||||
current_op = ECONET_STATE_TO_HA.get(self.water_heater.mode)
|
current_op = self.econet_state_to_ha.get(self.water_heater.mode)
|
||||||
return current_op
|
return current_op
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def operation_list(self):
|
def operation_list(self):
|
||||||
"""List of available operation modes."""
|
"""List of available operation modes."""
|
||||||
op_list = []
|
op_list = []
|
||||||
modes = self.water_heater.supported_modes
|
for mode in self.supported_modes:
|
||||||
for mode in modes:
|
ha_mode = self.econet_state_to_ha.get(mode)
|
||||||
ha_mode = ECONET_STATE_TO_HA.get(mode)
|
|
||||||
if ha_mode is not None:
|
if ha_mode is not None:
|
||||||
op_list.append(ha_mode)
|
op_list.append(ha_mode)
|
||||||
else:
|
|
||||||
error = "Invalid operation mode mapping. " + mode + \
|
|
||||||
" doesn't map. Please report this."
|
|
||||||
_LOGGER.error(error)
|
|
||||||
return op_list
|
return op_list
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -182,7 +189,7 @@ class EcoNetWaterHeater(WaterHeaterDevice):
|
|||||||
|
|
||||||
def set_operation_mode(self, operation_mode):
|
def set_operation_mode(self, operation_mode):
|
||||||
"""Set operation mode."""
|
"""Set operation mode."""
|
||||||
op_mode_to_set = HA_STATE_TO_ECONET.get(operation_mode)
|
op_mode_to_set = self.ha_state_to_econet.get(operation_mode)
|
||||||
if op_mode_to_set is not None:
|
if op_mode_to_set is not None:
|
||||||
self.water_heater.set_mode(op_mode_to_set)
|
self.water_heater.set_mode(op_mode_to_set)
|
||||||
else:
|
else:
|
||||||
|
@ -1003,7 +1003,7 @@ pydukeenergy==0.0.6
|
|||||||
pyebox==1.1.4
|
pyebox==1.1.4
|
||||||
|
|
||||||
# homeassistant.components.water_heater.econet
|
# homeassistant.components.water_heater.econet
|
||||||
pyeconet==0.0.6
|
pyeconet==0.0.8
|
||||||
|
|
||||||
# homeassistant.components.switch.edimax
|
# homeassistant.components.switch.edimax
|
||||||
pyedimax==0.1
|
pyedimax==0.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user