Support systems w/o circuits (#64779)
This commit is contained in:
parent
201229d20c
commit
8d6880ab85
6 changed files with 45 additions and 69 deletions
|
@ -25,7 +25,6 @@ from .const import (
|
||||||
HEATING_TYPE_TO_CREATOR_METHOD,
|
HEATING_TYPE_TO_CREATOR_METHOD,
|
||||||
PLATFORMS,
|
PLATFORMS,
|
||||||
VICARE_API,
|
VICARE_API,
|
||||||
VICARE_CIRCUITS,
|
|
||||||
VICARE_DEVICE_CONFIG,
|
VICARE_DEVICE_CONFIG,
|
||||||
HeatingType,
|
HeatingType,
|
||||||
)
|
)
|
||||||
|
@ -127,9 +126,6 @@ def setup_vicare_api(hass, entry):
|
||||||
device,
|
device,
|
||||||
HEATING_TYPE_TO_CREATOR_METHOD[HeatingType(entry.data[CONF_HEATING_TYPE])],
|
HEATING_TYPE_TO_CREATOR_METHOD[HeatingType(entry.data[CONF_HEATING_TYPE])],
|
||||||
)()
|
)()
|
||||||
hass.data[DOMAIN][entry.entry_id][VICARE_CIRCUITS] = hass.data[DOMAIN][
|
|
||||||
entry.entry_id
|
|
||||||
][VICARE_API].circuits
|
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|
|
@ -22,13 +22,7 @@ from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import ViCareRequiredKeysMixin
|
from . import ViCareRequiredKeysMixin
|
||||||
from .const import (
|
from .const import DOMAIN, VICARE_API, VICARE_DEVICE_CONFIG, VICARE_NAME
|
||||||
DOMAIN,
|
|
||||||
VICARE_API,
|
|
||||||
VICARE_CIRCUITS,
|
|
||||||
VICARE_DEVICE_CONFIG,
|
|
||||||
VICARE_NAME,
|
|
||||||
)
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -163,20 +157,12 @@ async def async_setup_entry(
|
||||||
if entity is not None:
|
if entity is not None:
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
|
|
||||||
for description in CIRCUIT_SENSORS:
|
try:
|
||||||
for circuit in hass.data[DOMAIN][config_entry.entry_id][VICARE_CIRCUITS]:
|
await _entities_from_descriptions(
|
||||||
suffix = ""
|
hass, name, entities, CIRCUIT_SENSORS, api.circuits, config_entry
|
||||||
if len(hass.data[DOMAIN][config_entry.entry_id][VICARE_CIRCUITS]) > 1:
|
)
|
||||||
suffix = f" {circuit.id}"
|
except PyViCareNotSupportedFeatureError:
|
||||||
entity = await hass.async_add_executor_job(
|
_LOGGER.info("No circuits found")
|
||||||
_build_entity,
|
|
||||||
f"{name} {description.name}{suffix}",
|
|
||||||
circuit,
|
|
||||||
hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG],
|
|
||||||
description,
|
|
||||||
)
|
|
||||||
if entity is not None:
|
|
||||||
entities.append(entity)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await _entities_from_descriptions(
|
await _entities_from_descriptions(
|
||||||
|
|
|
@ -33,7 +33,6 @@ from .const import (
|
||||||
CONF_HEATING_TYPE,
|
CONF_HEATING_TYPE,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
VICARE_API,
|
VICARE_API,
|
||||||
VICARE_CIRCUITS,
|
|
||||||
VICARE_DEVICE_CONFIG,
|
VICARE_DEVICE_CONFIG,
|
||||||
VICARE_NAME,
|
VICARE_NAME,
|
||||||
)
|
)
|
||||||
|
@ -112,19 +111,22 @@ async def async_setup_entry(
|
||||||
|
|
||||||
entities = []
|
entities = []
|
||||||
|
|
||||||
for circuit in hass.data[DOMAIN][config_entry.entry_id][VICARE_CIRCUITS]:
|
try:
|
||||||
suffix = ""
|
for circuit in hass.data[DOMAIN][config_entry.entry_id][VICARE_API].circuits:
|
||||||
if len(hass.data[DOMAIN][config_entry.entry_id][VICARE_CIRCUITS]) > 1:
|
suffix = ""
|
||||||
suffix = f" {circuit.id}"
|
if len(hass.data[DOMAIN][config_entry.entry_id][VICARE_API].circuits) > 1:
|
||||||
entity = _build_entity(
|
suffix = f" {circuit.id}"
|
||||||
f"{name} Heating{suffix}",
|
entity = _build_entity(
|
||||||
hass.data[DOMAIN][config_entry.entry_id][VICARE_API],
|
f"{name} Heating{suffix}",
|
||||||
hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG],
|
hass.data[DOMAIN][config_entry.entry_id][VICARE_API],
|
||||||
circuit,
|
hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG],
|
||||||
config_entry.data[CONF_HEATING_TYPE],
|
circuit,
|
||||||
)
|
config_entry.data[CONF_HEATING_TYPE],
|
||||||
if entity is not None:
|
)
|
||||||
entities.append(entity)
|
if entity is not None:
|
||||||
|
entities.append(entity)
|
||||||
|
except PyViCareNotSupportedFeatureError:
|
||||||
|
_LOGGER.info("No circuits found")
|
||||||
|
|
||||||
platform = entity_platform.async_get_current_platform()
|
platform = entity_platform.async_get_current_platform()
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ PLATFORMS = [
|
||||||
|
|
||||||
VICARE_DEVICE_CONFIG = "device_conf"
|
VICARE_DEVICE_CONFIG = "device_conf"
|
||||||
VICARE_API = "api"
|
VICARE_API = "api"
|
||||||
VICARE_CIRCUITS = "circuits"
|
|
||||||
VICARE_NAME = "ViCare"
|
VICARE_NAME = "ViCare"
|
||||||
|
|
||||||
CONF_CIRCUIT = "circuit"
|
CONF_CIRCUIT = "circuit"
|
||||||
|
|
|
@ -35,7 +35,6 @@ from . import ViCareRequiredKeysMixin
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
VICARE_API,
|
VICARE_API,
|
||||||
VICARE_CIRCUITS,
|
|
||||||
VICARE_DEVICE_CONFIG,
|
VICARE_DEVICE_CONFIG,
|
||||||
VICARE_NAME,
|
VICARE_NAME,
|
||||||
VICARE_UNIT_TO_DEVICE_CLASS,
|
VICARE_UNIT_TO_DEVICE_CLASS,
|
||||||
|
@ -380,20 +379,12 @@ async def async_setup_entry(
|
||||||
if entity is not None:
|
if entity is not None:
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
|
|
||||||
for description in CIRCUIT_SENSORS:
|
try:
|
||||||
for circuit in hass.data[DOMAIN][config_entry.entry_id][VICARE_CIRCUITS]:
|
await _entities_from_descriptions(
|
||||||
suffix = ""
|
hass, name, entities, CIRCUIT_SENSORS, api.circuits, config_entry
|
||||||
if len(hass.data[DOMAIN][config_entry.entry_id][VICARE_CIRCUITS]) > 1:
|
)
|
||||||
suffix = f" {circuit.id}"
|
except PyViCareNotSupportedFeatureError:
|
||||||
entity = await hass.async_add_executor_job(
|
_LOGGER.info("No circuits found")
|
||||||
_build_entity,
|
|
||||||
f"{name} {description.name}{suffix}",
|
|
||||||
circuit,
|
|
||||||
hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG],
|
|
||||||
description,
|
|
||||||
)
|
|
||||||
if entity is not None:
|
|
||||||
entities.append(entity)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await _entities_from_descriptions(
|
await _entities_from_descriptions(
|
||||||
|
|
|
@ -22,7 +22,6 @@ from .const import (
|
||||||
CONF_HEATING_TYPE,
|
CONF_HEATING_TYPE,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
VICARE_API,
|
VICARE_API,
|
||||||
VICARE_CIRCUITS,
|
|
||||||
VICARE_DEVICE_CONFIG,
|
VICARE_DEVICE_CONFIG,
|
||||||
VICARE_NAME,
|
VICARE_NAME,
|
||||||
)
|
)
|
||||||
|
@ -78,19 +77,22 @@ async def async_setup_entry(
|
||||||
name = VICARE_NAME
|
name = VICARE_NAME
|
||||||
|
|
||||||
entities = []
|
entities = []
|
||||||
for circuit in hass.data[DOMAIN][config_entry.entry_id][VICARE_CIRCUITS]:
|
try:
|
||||||
suffix = ""
|
for circuit in hass.data[DOMAIN][config_entry.entry_id][VICARE_API].circuits:
|
||||||
if len(hass.data[DOMAIN][config_entry.entry_id][VICARE_CIRCUITS]) > 1:
|
suffix = ""
|
||||||
suffix = f" {circuit.id}"
|
if len(hass.data[DOMAIN][config_entry.entry_id][VICARE_API].circuits) > 1:
|
||||||
entity = _build_entity(
|
suffix = f" {circuit.id}"
|
||||||
f"{name} Water{suffix}",
|
entity = _build_entity(
|
||||||
hass.data[DOMAIN][config_entry.entry_id][VICARE_API],
|
f"{name} Water{suffix}",
|
||||||
circuit,
|
hass.data[DOMAIN][config_entry.entry_id][VICARE_API],
|
||||||
hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG],
|
circuit,
|
||||||
config_entry.data[CONF_HEATING_TYPE],
|
hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG],
|
||||||
)
|
config_entry.data[CONF_HEATING_TYPE],
|
||||||
if entity is not None:
|
)
|
||||||
entities.append(entity)
|
if entity is not None:
|
||||||
|
entities.append(entity)
|
||||||
|
except PyViCareNotSupportedFeatureError:
|
||||||
|
_LOGGER.info("No circuits found")
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue