Remove previously-deprecated RainMachine sensors (#81053)

This commit is contained in:
Aaron Bach 2022-10-27 02:25:07 -06:00 committed by GitHub
parent 4e8e53f357
commit d72b8a025f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 76 deletions

View file

@ -12,12 +12,7 @@ from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import RainMachineData, RainMachineEntity
from .const import (
DATA_PROVISION_SETTINGS,
DATA_RESTRICTIONS_CURRENT,
DATA_RESTRICTIONS_UNIVERSAL,
DOMAIN,
)
from .const import DATA_PROVISION_SETTINGS, DATA_RESTRICTIONS_CURRENT, DOMAIN
from .model import (
RainMachineEntityDescription,
RainMachineEntityDescriptionMixinDataKey,
@ -30,8 +25,6 @@ from .util import (
TYPE_FLOW_SENSOR = "flow_sensor"
TYPE_FREEZE = "freeze"
TYPE_FREEZE_PROTECTION = "freeze_protection"
TYPE_HOT_DAYS = "extra_water_on_hot_days"
TYPE_HOURLY = "hourly"
TYPE_MONTH = "month"
TYPE_RAINDELAY = "raindelay"
@ -64,22 +57,6 @@ BINARY_SENSOR_DESCRIPTIONS = (
api_category=DATA_RESTRICTIONS_CURRENT,
data_key="freeze",
),
RainMachineBinarySensorDescription(
key=TYPE_FREEZE_PROTECTION,
name="Freeze protection",
icon="mdi:weather-snowy",
entity_category=EntityCategory.DIAGNOSTIC,
api_category=DATA_RESTRICTIONS_UNIVERSAL,
data_key="freezeProtectEnabled",
),
RainMachineBinarySensorDescription(
key=TYPE_HOT_DAYS,
name="Extra water on hot days",
icon="mdi:thermometer-lines",
entity_category=EntityCategory.DIAGNOSTIC,
api_category=DATA_RESTRICTIONS_UNIVERSAL,
data_key="hotDaysExtraWatering",
),
RainMachineBinarySensorDescription(
key=TYPE_HOURLY,
name="Hourly restrictions",
@ -139,14 +116,14 @@ async def async_setup_entry(
f"{data.controller.mac}_freeze_protection",
f"switch.{data.controller.name.lower()}_freeze_protect_enabled",
breaks_in_ha_version="2022.12.0",
remove_old_entity=False,
remove_old_entity=True,
),
EntityDomainReplacementStrategy(
BINARY_SENSOR_DOMAIN,
f"{data.controller.mac}_extra_water_on_hot_days",
f"switch.{data.controller.name.lower()}_hot_days_extra_watering",
breaks_in_ha_version="2022.12.0",
remove_old_entity=False,
remove_old_entity=True,
),
),
)
@ -154,7 +131,6 @@ async def async_setup_entry(
api_category_sensor_map = {
DATA_PROVISION_SETTINGS: ProvisionSettingsBinarySensor,
DATA_RESTRICTIONS_CURRENT: CurrentRestrictionsBinarySensor,
DATA_RESTRICTIONS_UNIVERSAL: UniversalRestrictionsBinarySensor,
}
async_add_entities(
@ -204,17 +180,3 @@ class ProvisionSettingsBinarySensor(RainMachineEntity, BinarySensorEntity):
self._attr_is_on = self.coordinator.data.get("system", {}).get(
"useFlowSensor"
)
class UniversalRestrictionsBinarySensor(RainMachineEntity, BinarySensorEntity):
"""Define a binary sensor that handles universal restrictions data."""
entity_description: RainMachineBinarySensorDescription
@callback
def update_from_latest_data(self) -> None:
"""Update the state."""
if self.entity_description.key == TYPE_FREEZE_PROTECTION:
self._attr_is_on = self.coordinator.data.get("freezeProtectEnabled")
elif self.entity_description.key == TYPE_HOT_DAYS:
self._attr_is_on = self.coordinator.data.get("hotDaysExtraWatering")