diff --git a/custom_components/multimatic/__init__.py b/custom_components/multimatic/__init__.py index 0097760..6a1e249 100644 --- a/custom_components/multimatic/__init__.py +++ b/custom_components/multimatic/__init__.py @@ -51,8 +51,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): update_interval=update_interval, ) hass.data[DOMAIN][entry.unique_id][COORDINATORS][coord[0]] = m_coord - await m_coord.async_config_entry_first_refresh() _LOGGER.debug("Adding %s coordinator", m_coord.name) + await m_coord.async_config_entry_first_refresh() for platform in PLATFORMS: hass.async_create_task( diff --git a/custom_components/multimatic/binary_sensor.py b/custom_components/multimatic/binary_sensor.py index e1d24de..943791b 100644 --- a/custom_components/multimatic/binary_sensor.py +++ b/custom_components/multimatic/binary_sensor.py @@ -193,6 +193,11 @@ def device(self): return device return None + @property + def name(self) -> str | None: + """Return the name of the entity.""" + return f"{self.device.name} {self.device_class}" + class RoomDeviceChildLock(RoomDeviceEntity): """Binary sensor for valve child lock. diff --git a/custom_components/multimatic/coordinator.py b/custom_components/multimatic/coordinator.py index e70e8d7..d6b1e52 100644 --- a/custom_components/multimatic/coordinator.py +++ b/custom_components/multimatic/coordinator.py @@ -329,10 +329,12 @@ async def set_holiday_mode(self, start_date, end_date, temperature): self._holiday_mode = HolidayMode(True, start_date, end_date, temperature) await self._refresh_entities() - async def set_quick_mode(self, mode): + async def set_quick_mode(self, mode, duration): """Set quick mode (remove previous one).""" await self._remove_quick_mode_no_refresh() - qmode = QuickModes.get(mode) + if duration is None and mode == QuickModes.COOLING_FOR_X_DAYS.name: + duration = 1 + qmode = QuickModes.get(mode, duration) await self._manager.set_quick_mode(qmode) self._quick_mode = qmode await self._refresh_entities() @@ -501,9 +503,13 @@ async def _fetch_data_if_needed(self): return await self._fetch_data() async def _first_fetch_data(self): - result = await self._fetch_data() - self.update_method = self._fetch_data_if_needed - return result + try: + result = await self._fetch_data() + self.update_method = self._fetch_data_if_needed + return result + except ApiError as err: + if err.status != 409: + raise async def _safe_logout(self): try: diff --git a/custom_components/multimatic/manifest.json b/custom_components/multimatic/manifest.json index b9efc90..1adb776 100644 --- a/custom_components/multimatic/manifest.json +++ b/custom_components/multimatic/manifest.json @@ -5,7 +5,7 @@ "documentation": "https://github.com/thomasgermain/vaillant-component", "issue_tracker": "https://github.com/thomasgermain/vaillant-component/issues", "requirements": [ - "pymultimatic==0.5.0b0" + "pymultimatic==0.5.0b1" ], "ssdp": [], "zeroconf": [], @@ -14,6 +14,6 @@ "codeowners": [ "@thomasgermain" ], - "version": "1.7.0b2", + "version": "1.7.0b3", "iot_class": "cloud_polling" } diff --git a/custom_components/multimatic/service.py b/custom_components/multimatic/service.py index baf7c40..fe9749e 100644 --- a/custom_components/multimatic/service.py +++ b/custom_components/multimatic/service.py @@ -36,7 +36,12 @@ {vol.Required(ATTR_ENTITY_ID): vol.All(vol.Coerce(str))} ) SERVICE_SET_QUICK_MODE_SCHEMA = vol.Schema( - {vol.Required(ATTR_QUICK_MODE): vol.All(vol.Coerce(str), vol.In(QUICK_MODES_LIST))} + { + vol.Required(ATTR_QUICK_MODE): vol.All( + vol.Coerce(str), vol.In(QUICK_MODES_LIST) + ), + vol.Optional(ATTR_DURATION): vol.All(vol.Coerce(int), vol.Clamp(min=1)), + } ) SERVICE_SET_HOLIDAY_MODE_SCHEMA = vol.Schema( { @@ -120,7 +125,8 @@ async def remove_holiday_mode(self, data): async def set_quick_mode(self, data): """Set quick mode, it may impact the whole system.""" quick_mode = data.get(ATTR_QUICK_MODE, None) - await self.api.set_quick_mode(quick_mode) + duration = data.get(ATTR_DURATION, None) + await self.api.set_quick_mode(quick_mode, duration) async def request_hvac_update(self, data): """Ask multimatic API to get data from the installation.""" diff --git a/custom_components/multimatic/services.yaml b/custom_components/multimatic/services.yaml index e94a00e..1b3c870 100644 --- a/custom_components/multimatic/services.yaml +++ b/custom_components/multimatic/services.yaml @@ -10,6 +10,9 @@ set_quick_mode: quick_mode: description: Name of the quick mode (required) example: QM_HOTWATER_BOOST, QM_VENTILATION_BOOST, QM_ONE_DAY_AWAY, QM_SYSTEM_OFF, QM_ONE_DAY_AT_HOME, QM_PARTY + duration: + description: (int) number of days the quick mode should last + example: 3 set_holiday_mode: description: Set holiday mode