mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 13:00:11 +00:00
Add hive boost to climate and water_heater (#26789)
* Start the Boost work * Add services.yaml * Added Services #2 * Start the Boost work * Add services.yaml * Added Services #2 * Working Services * pyhiveapi to 0.2.19 * Update Libary to 0.2.19 * Update Water_heater boost * Added Async hass add function * Update Services * Reviewed Changes * Fixed Refresh System * Review 2 * Moved device iteration to the platform * update * Updates #2 * Review#3 New Base Class * Review #5 * Update homeassistant/components/hive/__init__.py Co-Authored-By: Martin Hjelmare <marhje52@kth.se> * Update homeassistant/components/hive/__init__.py Co-Authored-By: Martin Hjelmare <marhje52@kth.se> * Update homeassistant/components/hive/__init__.py Co-Authored-By: Martin Hjelmare <marhje52@kth.se> * Review 6 * Review 7 * Removed Child classes to inhertit from the parent
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""Support for the Hive binary sensors."""
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
|
||||
from . import DATA_HIVE, DOMAIN
|
||||
from . import DOMAIN, DATA_HIVE, HiveEntity
|
||||
|
||||
DEVICETYPE_DEVICE_CLASS = {"motionsensor": "motion", "contactsensor": "opening"}
|
||||
|
||||
@@ -10,26 +10,17 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up Hive sensor devices."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
|
||||
session = hass.data.get(DATA_HIVE)
|
||||
|
||||
add_entities([HiveBinarySensorEntity(session, discovery_info)])
|
||||
devs = []
|
||||
for dev in discovery_info:
|
||||
devs.append(HiveBinarySensorEntity(session, dev))
|
||||
add_entities(devs)
|
||||
|
||||
|
||||
class HiveBinarySensorEntity(BinarySensorDevice):
|
||||
class HiveBinarySensorEntity(HiveEntity, BinarySensorDevice):
|
||||
"""Representation of a Hive binary sensor."""
|
||||
|
||||
def __init__(self, hivesession, hivedevice):
|
||||
"""Initialize the hive sensor."""
|
||||
self.node_id = hivedevice["Hive_NodeID"]
|
||||
self.node_name = hivedevice["Hive_NodeName"]
|
||||
self.device_type = hivedevice["HA_DeviceType"]
|
||||
self.node_device_type = hivedevice["Hive_DeviceType"]
|
||||
self.session = hivesession
|
||||
self.attributes = {}
|
||||
self.data_updatesource = f"{self.device_type}.{self.node_id}"
|
||||
self._unique_id = f"{self.node_id}-{self.device_type}"
|
||||
self.session.entities.append(self)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return unique ID of entity."""
|
||||
@@ -40,11 +31,6 @@ class HiveBinarySensorEntity(BinarySensorDevice):
|
||||
"""Return device information."""
|
||||
return {"identifiers": {(DOMAIN, self.unique_id)}, "name": self.name}
|
||||
|
||||
def handle_update(self, updatesource):
|
||||
"""Handle the new update request."""
|
||||
if f"{self.device_type}.{self.node_id}" not in updatesource:
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of this sensor."""
|
||||
|
||||
Reference in New Issue
Block a user