ha_gehome/custom_components/ge_home/climate.py

48 lines
1.8 KiB
Python
Raw Normal View History

2021-08-01 08:54:21 -06:00
"""GE Home Climate Entities"""
import logging
from typing import Callable
from homeassistant.components.climate import ClimateEntity
from homeassistant.config_entries import ConfigEntry
2022-10-16 08:44:14 -06:00
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers import entity_registry as er
2021-08-01 08:54:21 -06:00
from .entities import GeClimate
from .const import DOMAIN
2022-10-16 08:44:14 -06:00
from .devices import ApplianceApi
2021-08-01 08:54:21 -06:00
from .update_coordinator import GeHomeUpdateCoordinator
_LOGGER = logging.getLogger(__name__)
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable):
2022-10-16 08:44:14 -06:00
"""GE Climate Devices."""
2021-08-01 08:54:21 -06:00
_LOGGER.debug('Adding GE Climate Entities')
coordinator: GeHomeUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
2022-10-16 08:44:14 -06:00
registry = er.async_get(hass)
2021-08-01 08:54:21 -06:00
2022-10-16 08:44:14 -06:00
@callback
def async_devices_discovered(apis: list[ApplianceApi]):
_LOGGER.debug(f'Found {len(apis):d} appliance APIs')
2021-08-01 08:54:21 -06:00
2022-10-16 08:44:14 -06:00
entities = [
entity
for api in apis
for entity in api.entities
if isinstance(entity, GeClimate)
if not registry.async_is_registered(entity.entity_id)
]
_LOGGER.debug(f'Found {len(entities):d} unregistered climate entities')
async_add_entities(entities)
Dev -> Main v0.6.9 (#226) * - updated water heater naming * - initial support for built-in AC units * Add support for Built-In AC Unit Built-In AC unit operation and function is similar to a WAC. `gehomesdk` version bumped from 0.4.25 to 0.4.27 to include latest ErdApplianceType enum. * Update README.md Update README.md to include Built-In AC as supported device * - updated zero serial number detection (resolves #89) * - updated version - updated changelog * - hopefully fixed recursion bug with numbers * - added cooktop support * - fixed circular reference * Add support for fridges with reduced support for ERD codes (no turbo mode, no current temperature reporting, no temperature setpoint limit reporting, no door status reporting). This change has been tested on a Fisher & Paykel RF610AA. * - added dual dishwasher support - updated documentation - version bumps * - added water heater support * - added basic espresso maker device * - bugfixes * - rewrote initialization (resolves #99) * - added logic to prevent double registration of entities * - added correct min/max temps for water heaters * Fix CoffeeMaker after the NumberEntity refactoring * - added fix for CGY366P2TS1 (#116) to try to get the cooktop status, but fail more gracefully if it isn't supported * - fixed region setting in update coordinator * - version bump - doc update - string fixes * - updated the temperature conversion to use non-deprecated HASS methods * - updated documentation (@gleepwurp) * - more documentation updates * - updated dishwasher for new functionality - updated documentation * updated uom for liquid volume per HA specifications * - fixed typo in oven (#149) * - updated change log - fixed oven light control (#144) * - fixed issues with dishwasher (#155) - added oim descaling sensor (#154) - version bump * - updated change log * updated dual dishwasher for changes to gehomesdk (#161) Co-authored-by: na4ma4 <na4ma4@users.noreply.github.com> * await disconnect when unloading (#169) Fixes simbaja#164. * Check for upper oven light when there is a lower oven (#174) Resolves issue #121 * - added oven warming drawers - simplified oven entity logic * - fixed issues with the new oven initialization logic * - fixed bad type import for warming drawer * -added iot class (#181) * - updated the gehomesdk version requirement * - gehomesdk version bump * - added dehumidifier (#114) * - dehumidifier appliance type fix * - added oven state sensors (#175) * - updated change logs - updated sdk version requirement * - removed target select - added dehumidifier entity - sdk version bump * - updated dehumidifier icon * - added humidifier platform * - fixed typos in humidifier class * - fixed copy/paste error * - sdk version requirement bump * - sdk version bump * - updated dehumidifier to handle target precision - updated dehumidifier sensor value conversion * - missed a commit * - SDK version bump * Set device class on day flow for water softeners (#207) This should allow sensor to be added to the energy dashboard. * - removed references to _hass in update coordinator - removed hass attribute in ge_entity - version bump * bumped gehomesdk version requirement * - added fridge/freezer controls * - documentation updates * - fixed error when reloading integration * - added additional update error handling * - fixed coordinator bug * - added additional logic to handle non-standard ready conditions * Set device class on day flow for water filters (#209) * - bumped sdk version requirement * added new style cooktop status support (#159) * Update deprecated constants or remove unused ones (#219) * - updated documentation --------- Co-authored-by: Rob Schmidt <rwschmidt26@gmail.com> Co-authored-by: Federico Sevilla <federico@sevilla.id.au> Co-authored-by: alexanv1 <44785744+alexanv1@users.noreply.github.com> Co-authored-by: na4ma4 <25967676+na4ma4@users.noreply.github.com> Co-authored-by: na4ma4 <na4ma4@users.noreply.github.com> Co-authored-by: Alex Peters <alex@peters.net> Co-authored-by: Chris Petersen <154074+ex-nerd@users.noreply.github.com> Co-authored-by: Nathan Fiscus <nathanfiscus@users.noreply.github.com> Co-authored-by: Jason Foley <JTF195@hotmail.com> Co-authored-by: myztillx <33730898+myztillx@users.noreply.github.com>
2024-01-28 08:07:52 -07:00
#if we're already initialized at this point, call device
#discovery directly, otherwise add a callback based on the
#ready signal
if coordinator.initialized:
async_devices_discovered(coordinator.appliance_apis.values())
else:
# add the ready signal and register the remove callback
coordinator.add_signal_remove_callback(
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered))