Add Nexia thermostat support (Trane / American Standard) (#32826)
* Merge nexia * Restore original work * Merge cleanups * config flow * Add config flow * Add missing files * Fix import of old yaml config * More cleanups from self review * Additional self review * Update homeassistant/components/nexia/services.yaml Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * fix io in event loop * Update homeassistant/components/nexia/climate.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * avoid using ternary statements if they span multiple * Cleanup strings and remove unneeded attributes * more cleanup * more cleanup of yaml * remove coordinator boiler plate * nuke services for now for the inital pr, add back later * remove copy pasta * this can be reduced more * Update homeassistant/components/nexia/config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/nexia/config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/nexia/__init__.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/nexia/__init__.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/nexia/__init__.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/nexia/__init__.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * review * comments * Update homeassistant/components/nexia/climate.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/nexia/climate.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/nexia/climate.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * more review adjustments * nuke unused constants * Update homeassistant/components/nexia/config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * map states * add update * zone id is unique * Fix humidfy check * target_humidity should be a property instead of in attributes * remove aux heat as its already there Co-authored-by: Ryan Nazaretian <ryannazaretian@gmail.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
16 files changed
+1158
No files matched your search
@@ -0,0 +1,89 @@
|
||||
"""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
|
||||
|
||||
|
||||
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_home = nexia_data[NEXIA_DEVICE]
|
||||
coordinator = nexia_data[UPDATE_COORDINATOR]
|
||||
|
||||
entities = []
|
||||
for thermostat_id in nexia_home.get_thermostat_ids():
|
||||
thermostat = nexia_home.get_thermostat_by_id(thermostat_id)
|
||||
entities.append(
|
||||
NexiaBinarySensor(
|
||||
coordinator, thermostat, "is_blower_active", "Blower Active"
|
||||
)
|
||||
)
|
||||
if thermostat.has_emergency_heat():
|
||||
entities.append(
|
||||
NexiaBinarySensor(
|
||||
coordinator,
|
||||
thermostat,
|
||||
"is_emergency_heat_active",
|
||||
"Emergency Heat Active",
|
||||
)
|
||||
)
|
||||
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
class NexiaBinarySensor(NexiaEntity, BinarySensorDevice):
|
||||
"""Provices Nexia BinarySensor support."""
|
||||
|
||||
def __init__(self, coordinator, device, 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}"
|
||||
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)()
|
||||
Reference in new issue
Block a user