mirror of https://github.com/home-assistant/core
[Climate] Hive Add water heater Component post the refresh of the climate component. (#25148)
* climate_water_heater * updated names * Update water_heater * Update requirements * Updated reqirements * Version update * updated Versiojn * Update device list * Removed unused Attributes
This commit is contained in:
parent
0a8b68fd4d
commit
bcf85a0df1
|
@ -16,6 +16,7 @@ DATA_HIVE = 'data_hive'
|
|||
DEVICETYPES = {
|
||||
'binary_sensor': 'device_list_binary_sensor',
|
||||
'climate': 'device_list_climate',
|
||||
'water_heater': 'device_list_water_heater',
|
||||
'light': 'device_list_light',
|
||||
'switch': 'device_list_plug',
|
||||
'sensor': 'device_list_sensor',
|
||||
|
|
|
@ -45,11 +45,14 @@ class HiveClimateEntity(ClimateDevice):
|
|||
"""Initialize the Climate device."""
|
||||
self.node_id = hivedevice["Hive_NodeID"]
|
||||
self.node_name = hivedevice["Hive_NodeName"]
|
||||
self.device_type = hivedevice["HA_DeviceType"]
|
||||
self.thermostat_node_id = hivedevice["Thermostat_NodeID"]
|
||||
self.session = hivesession
|
||||
self.attributes = {}
|
||||
self.data_updatesource = 'Heating.{}'.format(self.node_id)
|
||||
self._unique_id = '{}-Heating'.format(self.node_id)
|
||||
self.data_updatesource = '{}.{}'.format(
|
||||
self.device_type, self.node_id)
|
||||
self._unique_id = '{}-{}'.format(self.node_id, self.device_type)
|
||||
self.session.entities.append(self)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
@ -73,7 +76,7 @@ class HiveClimateEntity(ClimateDevice):
|
|||
|
||||
def handle_update(self, updatesource):
|
||||
"""Handle the new update request."""
|
||||
if 'Heating.{}'.format(self.node_id) not in updatesource:
|
||||
if '{}.{}'.format(self.device_type, self.node_id) not in updatesource:
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
@property
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
"name": "Hive",
|
||||
"documentation": "https://www.home-assistant.io/components/hive",
|
||||
"requirements": [
|
||||
"pyhiveapi==0.2.17"
|
||||
"pyhiveapi==0.2.18.1"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": [
|
||||
"@Rendili",
|
||||
"@KJonline"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
"""Support for hive water heaters."""
|
||||
from homeassistant.const import TEMP_CELSIUS
|
||||
|
||||
from homeassistant.components.water_heater import (
|
||||
STATE_ECO, STATE_ON, STATE_OFF, SUPPORT_OPERATION_MODE, WaterHeaterDevice)
|
||||
|
||||
from . import DATA_HIVE, DOMAIN
|
||||
|
||||
SUPPORT_FLAGS_HEATER = (SUPPORT_OPERATION_MODE)
|
||||
|
||||
HIVE_TO_HASS_STATE = {
|
||||
'SCHEDULE': STATE_ECO,
|
||||
'ON': STATE_ON,
|
||||
'OFF': STATE_OFF,
|
||||
}
|
||||
|
||||
HASS_TO_HIVE_STATE = {
|
||||
STATE_ECO: 'SCHEDULE',
|
||||
STATE_ON: 'ON',
|
||||
STATE_OFF: 'OFF',
|
||||
}
|
||||
|
||||
SUPPORT_WATER_HEATER = [STATE_ECO, STATE_ON, STATE_OFF]
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Wink water heater devices."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
if discovery_info["HA_DeviceType"] != "HotWater":
|
||||
return
|
||||
|
||||
session = hass.data.get(DATA_HIVE)
|
||||
water_heater = HiveWaterHeater(session, discovery_info)
|
||||
|
||||
add_entities([water_heater])
|
||||
session.entities.append(water_heater)
|
||||
|
||||
|
||||
class HiveWaterHeater(WaterHeaterDevice):
|
||||
"""Hive Water Heater Device."""
|
||||
|
||||
def __init__(self, hivesession, hivedevice):
|
||||
"""Initialize the Water Heater device."""
|
||||
self.node_id = hivedevice["Hive_NodeID"]
|
||||
self.node_name = hivedevice["Hive_NodeName"]
|
||||
self.device_type = hivedevice["HA_DeviceType"]
|
||||
self.session = hivesession
|
||||
self.data_updatesource = '{}.{}'.format(
|
||||
self.device_type, self.node_id)
|
||||
self._unique_id = '{}-{}'.format(self.node_id, self.device_type)
|
||||
self._unit_of_measurement = TEMP_CELSIUS
|
||||
self.session.entities.append(self)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return unique ID of entity."""
|
||||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return device information."""
|
||||
return {
|
||||
'identifiers': {
|
||||
(DOMAIN, self.unique_id)
|
||||
},
|
||||
'name': self.name
|
||||
}
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_FLAGS_HEATER
|
||||
|
||||
def handle_update(self, updatesource):
|
||||
"""Handle the new update request."""
|
||||
if '{}.{}'.format(self.device_type, self.node_id) not in updatesource:
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the water heater """
|
||||
if self.node_name is None:
|
||||
self.node_name = "Hot Water"
|
||||
return self.node_name
|
||||
|
||||
@property
|
||||
def temperature_unit(self):
|
||||
"""Return the unit of measurement."""
|
||||
return self._unit_of_measurement
|
||||
|
||||
@property
|
||||
def current_operation(self):
|
||||
""" Return current operation. """
|
||||
return HIVE_TO_HASS_STATE[self.session.hotwater.get_mode(self.node_id)]
|
||||
|
||||
@property
|
||||
def operation_list(self):
|
||||
"""List of available operation modes."""
|
||||
return SUPPORT_WATER_HEATER
|
||||
|
||||
def set_operation_mode(self, operation_mode):
|
||||
"""Set operation mode."""
|
||||
new_mode = HASS_TO_HIVE_STATE[operation_mode]
|
||||
self.session.hotwater.set_mode(self.node_id, new_mode)
|
||||
|
||||
for entity in self.session.entities:
|
||||
entity.handle_update(self.data_updatesource)
|
||||
|
||||
def update(self):
|
||||
"""Update all Node data from Hive."""
|
||||
self.session.core.update_data(self.node_id)
|
|
@ -1169,7 +1169,7 @@ pyheos==0.5.2
|
|||
pyhik==0.2.3
|
||||
|
||||
# homeassistant.components.hive
|
||||
pyhiveapi==0.2.17
|
||||
pyhiveapi==0.2.18.1
|
||||
|
||||
# homeassistant.components.homematic
|
||||
pyhomematic==0.1.59
|
||||
|
|
Loading…
Reference in New Issue