27 lines
744 B
Python
27 lines
744 B
Python
"""ViCare helpers functions."""
|
|
import logging
|
|
|
|
from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError
|
|
|
|
from . import ViCareRequiredKeysMixin
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
def is_supported(
|
|
name: str,
|
|
entity_description: ViCareRequiredKeysMixin,
|
|
vicare_device,
|
|
) -> bool:
|
|
"""Check if the PyViCare device supports the requested sensor."""
|
|
try:
|
|
entity_description.value_getter(vicare_device)
|
|
_LOGGER.debug("Found entity %s", name)
|
|
except PyViCareNotSupportedFeatureError:
|
|
_LOGGER.info("Feature not supported %s", name)
|
|
return False
|
|
except AttributeError as error:
|
|
_LOGGER.debug("Attribute Error %s: %s", name, error)
|
|
return False
|
|
return True
|