forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse function to check feature support on ViCare devices (home-assis…
…tant#102211) * check feature support in utils function * rename parameters * restore severity * reorder parameters * Update .coveragerc
- Loading branch information
Showing
6 changed files
with
70 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""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 |