Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #143 from oischinger/pyvicare-2_28-1
Browse files Browse the repository at this point in the history
Update PyViCare to 2.28.1
  • Loading branch information
oischinger authored Aug 12, 2023
2 parents 491c82a + 9de694e commit 7f68ab9
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 33 deletions.
15 changes: 11 additions & 4 deletions custom_components/vicare/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@

from . import ViCareRequiredKeysMixin
from .const import DOMAIN, VICARE_DEVICE_CONFIG, VICARE_NAME
from .helpers import get_device_name, get_unique_device_id, get_unique_id
from .helpers import (
get_burners,
get_circuits,
get_compressors,
get_device_name,
get_unique_device_id,
get_unique_id,
)

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -172,7 +179,7 @@ def create_all_entities(hass: HomeAssistant, config_entry: ConfigEntry):
name,
entities,
CIRCUIT_SENSORS,
api.circuits,
get_circuits(api),
config_entry,
device,
)
Expand All @@ -181,7 +188,7 @@ def create_all_entities(hass: HomeAssistant, config_entry: ConfigEntry):

try:
_entities_from_descriptions(
hass, name, entities, BURNER_SENSORS, api.burners, config_entry, device
hass, name, entities, BURNER_SENSORS, get_burners(api), config_entry, device
)
except PyViCareNotSupportedFeatureError:
_LOGGER.info("No burners found")
Expand All @@ -192,7 +199,7 @@ def create_all_entities(hass: HomeAssistant, config_entry: ConfigEntry):
name,
entities,
COMPRESSOR_SENSORS,
api.compressors,
get_compressors(api),
config_entry,
device,
)
Expand Down
21 changes: 9 additions & 12 deletions custom_components/vicare/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN, VICARE_DEVICE_CONFIG, VICARE_NAME
from .helpers import get_device_name, get_unique_device_id, get_unique_id
from .helpers import (
get_burners,
get_circuits,
get_device_name,
get_unique_device_id,
get_unique_id,
)

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -101,15 +107,6 @@
}


def _get_circuits(vicare_api):
"""Return the list of circuits."""
try:
return vicare_api.circuits
except PyViCareNotSupportedFeatureError:
_LOGGER.info("No circuits found")
return []


async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
Expand All @@ -122,7 +119,7 @@ async def async_setup_entry(
for device in hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG]:
api = device.asAutoDetectDevice()

circuits = await hass.async_add_executor_job(_get_circuits, api)
circuits = await hass.async_add_executor_job(get_circuits, api)
for circuit in circuits:
suffix = ""
if len(circuits) > 1:
Expand Down Expand Up @@ -261,7 +258,7 @@ def update(self) -> None:
self._current_action = False
# Update the specific device attributes
with suppress(PyViCareNotSupportedFeatureError):
for burner in self._api.burners:
for burner in get_burners(self._api):
self._current_action = self._current_action or burner.getActive()

with suppress(PyViCareNotSupportedFeatureError):
Expand Down
29 changes: 29 additions & 0 deletions custom_components/vicare/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Helpers for ViCare."""
from PyViCare.PyViCareHeatingDevice import HeatingDevice
from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError


def get_unique_id(api, device_config, entity_id) -> str:
Expand All @@ -17,3 +19,30 @@ def get_unique_device_id(device_config) -> str:
def get_device_name(device_config) -> str:
"""Return name for this device."""
return f"{device_config.getModel()}-{device_config.getConfig().id}-{device_config.getConfig().device_id}"

def get_circuits(vicare_api):
"""Return the list of circuits."""
if not isinstance(vicare_api, HeatingDevice):
return []
try:
return vicare_api.circuits
except PyViCareNotSupportedFeatureError:
return []

def get_burners(vicare_api):
"""Return the list of burners."""
if not isinstance(vicare_api, HeatingDevice):
return []
try:
return vicare_api.burners
except PyViCareNotSupportedFeatureError:
return []

def get_compressors(vicare_api):
"""Return the list of compressors."""
if not isinstance(vicare_api, HeatingDevice):
return []
try:
return vicare_api.compressors
except PyViCareNotSupportedFeatureError:
return []
2 changes: 1 addition & 1 deletion custom_components/vicare/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"documentation": "https://www.home-assistant.io/integrations/vicare",
"iot_class": "cloud_polling",
"loggers": ["PyViCare"],
"requirements": ["PyViCare==2.25.0"],
"requirements": ["PyViCare==2.28.1"],
"version": "2.0.0"
}
15 changes: 11 additions & 4 deletions custom_components/vicare/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@
VICARE_NAME,
VICARE_UNIT_TO_UNIT_OF_MEASUREMENT,
)
from .helpers import get_device_name, get_unique_device_id, get_unique_id
from .helpers import (
get_burners,
get_circuits,
get_compressors,
get_device_name,
get_unique_device_id,
get_unique_id,
)

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -666,7 +673,7 @@ def create_all_entities(hass: HomeAssistant, config_entry: ConfigEntry):
name,
entities,
CIRCUIT_SENSORS,
api.circuits,
get_circuits(api),
config_entry,
device,
)
Expand All @@ -675,7 +682,7 @@ def create_all_entities(hass: HomeAssistant, config_entry: ConfigEntry):

try:
_entities_from_descriptions(
hass, name, entities, BURNER_SENSORS, api.burners, config_entry, device
hass, name, entities, BURNER_SENSORS, get_burners(api), config_entry, device
)
except PyViCareNotSupportedFeatureError:
_LOGGER.info("No burners found")
Expand All @@ -686,7 +693,7 @@ def create_all_entities(hass: HomeAssistant, config_entry: ConfigEntry):
name,
entities,
COMPRESSOR_SENSORS,
api.compressors,
get_compressors(api),
config_entry,
device,
)
Expand Down
13 changes: 2 additions & 11 deletions custom_components/vicare/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN, VICARE_DEVICE_CONFIG, VICARE_NAME
from .helpers import get_device_name, get_unique_device_id, get_unique_id
from .helpers import get_circuits, get_device_name, get_unique_device_id, get_unique_id

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -60,15 +60,6 @@
}


def _get_circuits(vicare_api):
"""Return the list of circuits."""
try:
return vicare_api.circuits
except PyViCareNotSupportedFeatureError:
_LOGGER.info("No circuits found")
return []


async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
Expand All @@ -81,7 +72,7 @@ async def async_setup_entry(
for device in hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG]:
api = device.asAutoDetectDevice()

circuits = await hass.async_add_executor_job(_get_circuits, api)
circuits = await hass.async_add_executor_job(get_circuits, api)
for circuit in circuits:
suffix = ""
if len(circuits) > 1:
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PyViCare == 2.25.0
PyViCare >= 2.28.1
homeassistant >= 2023.4.1

1 comment on commit 7f68ab9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.