mirror of https://github.com/simbaja/ha_gehome.git
- added humidifier platform
This commit is contained in:
parent
2160b28085
commit
294a111479
|
@ -0,0 +1,36 @@
|
|||
"""GE Home Humidifier Entities"""
|
||||
import logging
|
||||
from typing import Callable
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .entities import GeHumidifier
|
||||
from .const import DOMAIN
|
||||
from .devices import ApplianceApi
|
||||
from .update_coordinator import GeHomeUpdateCoordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable):
|
||||
"""GE Home Water Heaters."""
|
||||
_LOGGER.debug('Adding GE "Humidifiers"')
|
||||
coordinator: GeHomeUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
registry = er.async_get(hass)
|
||||
|
||||
@callback
|
||||
def async_devices_discovered(apis: list[ApplianceApi]):
|
||||
_LOGGER.debug(f'Found {len(apis):d} appliance APIs')
|
||||
entities = [
|
||||
entity
|
||||
for api in apis
|
||||
for entity in api.entities
|
||||
if isinstance(entity, GeHumidifier)
|
||||
if not registry.async_is_registered(entity.entity_id)
|
||||
]
|
||||
_LOGGER.debug(f'Found {len(entities):d} unregistered humidifiers')
|
||||
async_add_entities(entities)
|
||||
|
||||
async_dispatcher_connect(hass, coordinator.signal_ready, async_devices_discovered)
|
|
@ -35,7 +35,18 @@ from .const import (
|
|||
)
|
||||
from .devices import ApplianceApi, get_appliance_api_type
|
||||
|
||||
PLATFORMS = ["binary_sensor", "sensor", "switch", "water_heater", "select", "climate", "light", "button", "number"]
|
||||
PLATFORMS = [
|
||||
"binary_sensor",
|
||||
"sensor",
|
||||
"switch",
|
||||
"water_heater",
|
||||
"select",
|
||||
"climate",
|
||||
"light",
|
||||
"button",
|
||||
"number",
|
||||
"humidifier"
|
||||
]
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue