Refactor hive entity (#72311)

* Add hive category entity changes

* Updates based on PR feedback

* Revert libary bump

* Update after PR feedback

* Update Binary device class for smoke sensor

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Remove entity category

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Updates after PR review

* Remove unused import

* Update light based on PR feedback

* Update light code from PR review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Khole 2022-05-29 11:08:50 +01:00 committed by GitHub
parent e7e48cd9f6
commit d59ecc4c96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 152 additions and 402 deletions

View file

@ -12,7 +12,6 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_OFF, STATE_ON, TEMP_CELSIUS
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import HiveEntity, refresh_system
@ -75,48 +74,8 @@ class HiveWaterHeater(HiveEntity, WaterHeaterEntity):
"""Hive Water Heater Device."""
_attr_supported_features = WaterHeaterEntityFeature.OPERATION_MODE
@property
def unique_id(self):
"""Return unique ID of entity."""
return self._unique_id
@property
def device_info(self) -> DeviceInfo:
"""Return device information."""
return DeviceInfo(
identifiers={(DOMAIN, self.device["device_id"])},
manufacturer=self.device["deviceData"]["manufacturer"],
model=self.device["deviceData"]["model"],
name=self.device["device_name"],
sw_version=self.device["deviceData"]["version"],
via_device=(DOMAIN, self.device["parentDevice"]),
)
@property
def name(self):
"""Return the name of the water heater."""
return HOTWATER_NAME
@property
def available(self):
"""Return if the device is available."""
return self.device["deviceData"]["online"]
@property
def temperature_unit(self):
"""Return the unit of measurement."""
return TEMP_CELSIUS
@property
def current_operation(self):
"""Return current operation."""
return HIVE_TO_HASS_STATE[self.device["status"]["current_operation"]]
@property
def operation_list(self):
"""List of available operation modes."""
return SUPPORT_WATER_HEATER
_attr_temperature_unit = TEMP_CELSIUS
_attr_operation_list = SUPPORT_WATER_HEATER
@refresh_system
async def async_turn_on(self, **kwargs):
@ -146,3 +105,8 @@ class HiveWaterHeater(HiveEntity, WaterHeaterEntity):
"""Update all Node data from Hive."""
await self.hive.session.updateData(self.device)
self.device = await self.hive.hotwater.getWaterHeater(self.device)
self._attr_available = self.device["deviceData"].get("online")
if self._attr_available:
self._attr_current_operation = HIVE_TO_HASS_STATE[
self.device["status"]["current_operation"]
]