mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Ignore gateway devices in ViCare integration (#106477)
* filter unsupported devices * Update __init__.py * use debug * remove dead code
This commit is contained in:
parent
3f7d2da35c
commit
bb8d742423
@ -10,6 +10,7 @@ from typing import Any
|
||||
|
||||
from PyViCare.PyViCare import PyViCare
|
||||
from PyViCare.PyViCareDevice import Device
|
||||
from PyViCare.PyViCareDeviceConfig import PyViCareDeviceConfig
|
||||
from PyViCare.PyViCareUtils import (
|
||||
PyViCareInvalidConfigurationError,
|
||||
PyViCareInvalidCredentialsError,
|
||||
@ -85,15 +86,16 @@ def setup_vicare_api(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
"""Set up PyVicare API."""
|
||||
vicare_api = vicare_login(hass, entry.data)
|
||||
|
||||
for device in vicare_api.devices:
|
||||
_LOGGER.info(
|
||||
device_config_list = get_supported_devices(vicare_api.devices)
|
||||
|
||||
for device in device_config_list:
|
||||
_LOGGER.debug(
|
||||
"Found device: %s (online: %s)", device.getModel(), str(device.isOnline())
|
||||
)
|
||||
|
||||
# Currently we only support a single device
|
||||
device_list = vicare_api.devices
|
||||
device = device_list[0]
|
||||
hass.data[DOMAIN][entry.entry_id][VICARE_DEVICE_CONFIG_LIST] = device_list
|
||||
device = device_config_list[0]
|
||||
hass.data[DOMAIN][entry.entry_id][VICARE_DEVICE_CONFIG_LIST] = device_config_list
|
||||
hass.data[DOMAIN][entry.entry_id][VICARE_DEVICE_CONFIG] = device
|
||||
hass.data[DOMAIN][entry.entry_id][VICARE_API] = getattr(
|
||||
device,
|
||||
@ -113,3 +115,14 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
)
|
||||
|
||||
return unload_ok
|
||||
|
||||
|
||||
def get_supported_devices(
|
||||
devices: list[PyViCareDeviceConfig],
|
||||
) -> list[PyViCareDeviceConfig]:
|
||||
"""Remove unsupported devices from the list."""
|
||||
return [
|
||||
device_config
|
||||
for device_config in devices
|
||||
if device_config.getModel() not in ["Heatbox1", "Heatbox2_SRC"]
|
||||
]
|
||||
|
@ -118,7 +118,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
"""Invoke when a Viessmann MAC address is discovered on the network."""
|
||||
formatted_mac = format_mac(discovery_info.macaddress)
|
||||
_LOGGER.info("Found device with mac %s", formatted_mac)
|
||||
_LOGGER.debug("Found device with mac %s", formatted_mac)
|
||||
|
||||
await self.async_set_unique_id(formatted_mac)
|
||||
self._abort_if_unique_id_configured()
|
||||
|
@ -692,41 +692,6 @@ COMPRESSOR_SENSORS: tuple[ViCareSensorEntityDescription, ...] = (
|
||||
)
|
||||
|
||||
|
||||
def _build_entity(
|
||||
vicare_api,
|
||||
device_config: PyViCareDeviceConfig,
|
||||
entity_description: ViCareSensorEntityDescription,
|
||||
):
|
||||
"""Create a ViCare sensor entity."""
|
||||
if is_supported(entity_description.key, entity_description, vicare_api):
|
||||
return ViCareSensor(
|
||||
vicare_api,
|
||||
device_config,
|
||||
entity_description,
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
async def _entities_from_descriptions(
|
||||
hass: HomeAssistant,
|
||||
entities: list[ViCareSensor],
|
||||
sensor_descriptions: tuple[ViCareSensorEntityDescription, ...],
|
||||
iterables,
|
||||
config_entry: ConfigEntry,
|
||||
) -> None:
|
||||
"""Create entities from descriptions and list of burners/circuits."""
|
||||
for description in sensor_descriptions:
|
||||
for current in iterables:
|
||||
entity = await hass.async_add_executor_job(
|
||||
_build_entity,
|
||||
current,
|
||||
hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG],
|
||||
description,
|
||||
)
|
||||
if entity:
|
||||
entities.append(entity)
|
||||
|
||||
|
||||
def _build_entities(
|
||||
device: PyViCareDevice,
|
||||
device_config: PyViCareDeviceConfig,
|
||||
|
Loading…
x
Reference in New Issue
Block a user