Add aircleaner and humidify service to nexia climate (#33078)
* Add aircleaner and humidify service to nexia climate * These were removed from the original merge to reduce review scope * Additional tests for binary_sensor, sensor, and climate states * Switch to signals for services Get rid of everywhere we call device and change to zone or thermostat as it was too confusing Renames to make it clear that zone and thermostat are tightly coupled * Make scene activation responsive * no need to use update for only one key/value * stray comma * use async_call_later * its async, need ()s * cleaner * merge entity platform services testing branch
This commit is contained in:
1 parent
0e3dc7976c
commit
b8fdebd05c
13 files changed
+575
-291
No files matched your search
@@ -1,23 +1,15 @@
|
||||
"""Support for Nexia / Trane XL Thermostats."""
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.const import ATTR_ATTRIBUTION
|
||||
|
||||
from .const import (
|
||||
ATTRIBUTION,
|
||||
DATA_NEXIA,
|
||||
DOMAIN,
|
||||
MANUFACTURER,
|
||||
NEXIA_DEVICE,
|
||||
UPDATE_COORDINATOR,
|
||||
)
|
||||
from .entity import NexiaEntity
|
||||
from .const import DOMAIN, NEXIA_DEVICE, UPDATE_COORDINATOR
|
||||
from .entity import NexiaThermostatEntity
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up sensors for a Nexia device."""
|
||||
|
||||
nexia_data = hass.data[DOMAIN][config_entry.entry_id][DATA_NEXIA]
|
||||
nexia_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||
nexia_home = nexia_data[NEXIA_DEVICE]
|
||||
coordinator = nexia_data[UPDATE_COORDINATOR]
|
||||
|
||||
@@ -42,48 +34,21 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
class NexiaBinarySensor(NexiaEntity, BinarySensorDevice):
|
||||
class NexiaBinarySensor(NexiaThermostatEntity, BinarySensorDevice):
|
||||
"""Provices Nexia BinarySensor support."""
|
||||
|
||||
def __init__(self, coordinator, device, sensor_call, sensor_name):
|
||||
def __init__(self, coordinator, thermostat, sensor_call, sensor_name):
|
||||
"""Initialize the nexia sensor."""
|
||||
super().__init__(coordinator)
|
||||
self._coordinator = coordinator
|
||||
self._device = device
|
||||
self._name = f"{self._device.get_name()} {sensor_name}"
|
||||
super().__init__(
|
||||
coordinator,
|
||||
thermostat,
|
||||
name=f"{thermostat.get_name()} {sensor_name}",
|
||||
unique_id=f"{thermostat.thermostat_id}_{sensor_call}",
|
||||
)
|
||||
self._call = sensor_call
|
||||
self._unique_id = f"{self._device.thermostat_id}_{sensor_call}"
|
||||
self._state = None
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique id of the binary sensor."""
|
||||
return self._unique_id
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return the device_info of the device."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._device.thermostat_id)},
|
||||
"name": self._device.get_name(),
|
||||
"model": self._device.get_model(),
|
||||
"sw_version": self._device.get_firmware(),
|
||||
"manufacturer": MANUFACTURER,
|
||||
}
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the device specific state attributes."""
|
||||
return {
|
||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
||||
}
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return the status of the sensor."""
|
||||
return getattr(self._device, self._call)()
|
||||
return getattr(self._thermostat, self._call)()
|
||||
Reference in new issue
Block a user