diff --git a/homeassistant/components/rainmachine/__init__.py b/homeassistant/components/rainmachine/__init__.py index 52de2e1c61a..756dc9b958d 100644 --- a/homeassistant/components/rainmachine/__init__.py +++ b/homeassistant/components/rainmachine/__init__.py @@ -9,7 +9,7 @@ from typing import Any from regenmaschine import Client from regenmaschine.controller import Controller -from regenmaschine.errors import RainMachineError +from regenmaschine.errors import RainMachineError, UnknownAPICallError import voluptuous as vol from homeassistant.config_entries import ConfigEntry, ConfigEntryState @@ -190,7 +190,9 @@ async def async_update_programs_and_zones( ) -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: +async def async_setup_entry( # noqa: C901 + hass: HomeAssistant, entry: ConfigEntry +) -> bool: """Set up RainMachine as config entry.""" websession = aiohttp_client.async_get_clientsession(hass) client = Client(session=websession) @@ -244,6 +246,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: data = await controller.restrictions.universal() else: data = await controller.zones.all(details=True, include_inactive=True) + except UnknownAPICallError: + LOGGER.info( + "Skipping unsupported API call for controller %s: %s", + controller.name, + api_category, + ) except RainMachineError as err: raise UpdateFailed(err) from err diff --git a/homeassistant/components/rainmachine/binary_sensor.py b/homeassistant/components/rainmachine/binary_sensor.py index 3db64240788..48f11f598c9 100644 --- a/homeassistant/components/rainmachine/binary_sensor.py +++ b/homeassistant/components/rainmachine/binary_sensor.py @@ -175,7 +175,9 @@ class ProvisionSettingsBinarySensor(RainMachineEntity, BinarySensorEntity): def update_from_latest_data(self) -> None: """Update the state.""" if self.entity_description.key == TYPE_FLOW_SENSOR: - self._attr_is_on = self.coordinator.data["system"].get("useFlowSensor") + self._attr_is_on = self.coordinator.data.get("system", {}).get( + "useFlowSensor" + ) class UniversalRestrictionsBinarySensor(RainMachineEntity, BinarySensorEntity): diff --git a/homeassistant/components/rainmachine/manifest.json b/homeassistant/components/rainmachine/manifest.json index b183fc1b24f..a6cc86e5055 100644 --- a/homeassistant/components/rainmachine/manifest.json +++ b/homeassistant/components/rainmachine/manifest.json @@ -3,7 +3,7 @@ "name": "RainMachine", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/rainmachine", - "requirements": ["regenmaschine==2022.08.0"], + "requirements": ["regenmaschine==2022.09.0"], "codeowners": ["@bachya"], "iot_class": "local_polling", "homekit": { diff --git a/homeassistant/components/rainmachine/sensor.py b/homeassistant/components/rainmachine/sensor.py index e2e602b945b..32364e08199 100644 --- a/homeassistant/components/rainmachine/sensor.py +++ b/homeassistant/components/rainmachine/sensor.py @@ -273,12 +273,14 @@ class ProvisionSettingsSensor(RainMachineEntity, SensorEntity): def update_from_latest_data(self) -> None: """Update the state.""" if self.entity_description.key == TYPE_FLOW_SENSOR_CLICK_M3: - self._attr_native_value = self.coordinator.data["system"].get( + self._attr_native_value = self.coordinator.data.get("system", {}).get( "flowSensorClicksPerCubicMeter" ) elif self.entity_description.key == TYPE_FLOW_SENSOR_CONSUMED_LITERS: - clicks = self.coordinator.data["system"].get("flowSensorWateringClicks") - clicks_per_m3 = self.coordinator.data["system"].get( + clicks = self.coordinator.data.get("system", {}).get( + "flowSensorWateringClicks" + ) + clicks_per_m3 = self.coordinator.data.get("system", {}).get( "flowSensorClicksPerCubicMeter" ) @@ -287,11 +289,11 @@ class ProvisionSettingsSensor(RainMachineEntity, SensorEntity): else: self._attr_native_value = None elif self.entity_description.key == TYPE_FLOW_SENSOR_START_INDEX: - self._attr_native_value = self.coordinator.data["system"].get( + self._attr_native_value = self.coordinator.data.get("system", {}).get( "flowSensorStartIndex" ) elif self.entity_description.key == TYPE_FLOW_SENSOR_WATERING_CLICKS: - self._attr_native_value = self.coordinator.data["system"].get( + self._attr_native_value = self.coordinator.data.get("system", {}).get( "flowSensorWateringClicks" ) diff --git a/requirements_all.txt b/requirements_all.txt index 2947ea72798..3e8ebabbdcd 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2121,7 +2121,7 @@ raincloudy==0.0.7 raspyrfm-client==1.2.8 # homeassistant.components.rainmachine -regenmaschine==2022.08.0 +regenmaschine==2022.09.0 # homeassistant.components.renault renault-api==0.1.11 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index f08a496dc5c..d476445a4d6 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1454,7 +1454,7 @@ radios==0.1.1 radiotherm==2.1.0 # homeassistant.components.rainmachine -regenmaschine==2022.08.0 +regenmaschine==2022.09.0 # homeassistant.components.renault renault-api==0.1.11