mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Migrate RainMachine to new entity naming style (#74754)
This commit is contained in:
parent
c92936cc7b
commit
a4d5ecb8ec
@ -401,6 +401,8 @@ async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
|||||||
class RainMachineEntity(CoordinatorEntity):
|
class RainMachineEntity(CoordinatorEntity):
|
||||||
"""Define a generic RainMachine entity."""
|
"""Define a generic RainMachine entity."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
entry: ConfigEntry,
|
entry: ConfigEntry,
|
||||||
@ -415,7 +417,7 @@ class RainMachineEntity(CoordinatorEntity):
|
|||||||
identifiers={(DOMAIN, controller.mac)},
|
identifiers={(DOMAIN, controller.mac)},
|
||||||
configuration_url=f"https://{entry.data[CONF_IP_ADDRESS]}:{entry.data[CONF_PORT]}",
|
configuration_url=f"https://{entry.data[CONF_IP_ADDRESS]}:{entry.data[CONF_PORT]}",
|
||||||
connections={(dr.CONNECTION_NETWORK_MAC, controller.mac)},
|
connections={(dr.CONNECTION_NETWORK_MAC, controller.mac)},
|
||||||
name=str(controller.name),
|
name=str(controller.name).capitalize(),
|
||||||
manufacturer="RainMachine",
|
manufacturer="RainMachine",
|
||||||
model=(
|
model=(
|
||||||
f"Version {controller.hardware_version} "
|
f"Version {controller.hardware_version} "
|
||||||
@ -424,7 +426,6 @@ class RainMachineEntity(CoordinatorEntity):
|
|||||||
sw_version=controller.software_version,
|
sw_version=controller.software_version,
|
||||||
)
|
)
|
||||||
self._attr_extra_state_attributes = {}
|
self._attr_extra_state_attributes = {}
|
||||||
self._attr_name = f"{controller.name} {description.name}"
|
|
||||||
self._attr_unique_id = f"{controller.mac}_{description.key}"
|
self._attr_unique_id = f"{controller.mac}_{description.key}"
|
||||||
self._controller = controller
|
self._controller = controller
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
|
@ -43,14 +43,14 @@ class RainMachineBinarySensorDescription(
|
|||||||
BINARY_SENSOR_DESCRIPTIONS = (
|
BINARY_SENSOR_DESCRIPTIONS = (
|
||||||
RainMachineBinarySensorDescription(
|
RainMachineBinarySensorDescription(
|
||||||
key=TYPE_FLOW_SENSOR,
|
key=TYPE_FLOW_SENSOR,
|
||||||
name="Flow Sensor",
|
name="Flow sensor",
|
||||||
icon="mdi:water-pump",
|
icon="mdi:water-pump",
|
||||||
api_category=DATA_PROVISION_SETTINGS,
|
api_category=DATA_PROVISION_SETTINGS,
|
||||||
data_key="useFlowSensor",
|
data_key="useFlowSensor",
|
||||||
),
|
),
|
||||||
RainMachineBinarySensorDescription(
|
RainMachineBinarySensorDescription(
|
||||||
key=TYPE_FREEZE,
|
key=TYPE_FREEZE,
|
||||||
name="Freeze Restrictions",
|
name="Freeze restrictions",
|
||||||
icon="mdi:cancel",
|
icon="mdi:cancel",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
api_category=DATA_RESTRICTIONS_CURRENT,
|
api_category=DATA_RESTRICTIONS_CURRENT,
|
||||||
@ -58,7 +58,7 @@ BINARY_SENSOR_DESCRIPTIONS = (
|
|||||||
),
|
),
|
||||||
RainMachineBinarySensorDescription(
|
RainMachineBinarySensorDescription(
|
||||||
key=TYPE_FREEZE_PROTECTION,
|
key=TYPE_FREEZE_PROTECTION,
|
||||||
name="Freeze Protection",
|
name="Freeze protection",
|
||||||
icon="mdi:weather-snowy",
|
icon="mdi:weather-snowy",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
api_category=DATA_RESTRICTIONS_UNIVERSAL,
|
api_category=DATA_RESTRICTIONS_UNIVERSAL,
|
||||||
@ -66,7 +66,7 @@ BINARY_SENSOR_DESCRIPTIONS = (
|
|||||||
),
|
),
|
||||||
RainMachineBinarySensorDescription(
|
RainMachineBinarySensorDescription(
|
||||||
key=TYPE_HOT_DAYS,
|
key=TYPE_HOT_DAYS,
|
||||||
name="Extra Water on Hot Days",
|
name="Extra water on hot days",
|
||||||
icon="mdi:thermometer-lines",
|
icon="mdi:thermometer-lines",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
api_category=DATA_RESTRICTIONS_UNIVERSAL,
|
api_category=DATA_RESTRICTIONS_UNIVERSAL,
|
||||||
@ -74,7 +74,7 @@ BINARY_SENSOR_DESCRIPTIONS = (
|
|||||||
),
|
),
|
||||||
RainMachineBinarySensorDescription(
|
RainMachineBinarySensorDescription(
|
||||||
key=TYPE_HOURLY,
|
key=TYPE_HOURLY,
|
||||||
name="Hourly Restrictions",
|
name="Hourly restrictions",
|
||||||
icon="mdi:cancel",
|
icon="mdi:cancel",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
@ -83,7 +83,7 @@ BINARY_SENSOR_DESCRIPTIONS = (
|
|||||||
),
|
),
|
||||||
RainMachineBinarySensorDescription(
|
RainMachineBinarySensorDescription(
|
||||||
key=TYPE_MONTH,
|
key=TYPE_MONTH,
|
||||||
name="Month Restrictions",
|
name="Month restrictions",
|
||||||
icon="mdi:cancel",
|
icon="mdi:cancel",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
@ -92,7 +92,7 @@ BINARY_SENSOR_DESCRIPTIONS = (
|
|||||||
),
|
),
|
||||||
RainMachineBinarySensorDescription(
|
RainMachineBinarySensorDescription(
|
||||||
key=TYPE_RAINDELAY,
|
key=TYPE_RAINDELAY,
|
||||||
name="Rain Delay Restrictions",
|
name="Rain delay restrictions",
|
||||||
icon="mdi:cancel",
|
icon="mdi:cancel",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
@ -101,7 +101,7 @@ BINARY_SENSOR_DESCRIPTIONS = (
|
|||||||
),
|
),
|
||||||
RainMachineBinarySensorDescription(
|
RainMachineBinarySensorDescription(
|
||||||
key=TYPE_RAINSENSOR,
|
key=TYPE_RAINSENSOR,
|
||||||
name="Rain Sensor Restrictions",
|
name="Rain sensor restrictions",
|
||||||
icon="mdi:cancel",
|
icon="mdi:cancel",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
@ -110,7 +110,7 @@ BINARY_SENSOR_DESCRIPTIONS = (
|
|||||||
),
|
),
|
||||||
RainMachineBinarySensorDescription(
|
RainMachineBinarySensorDescription(
|
||||||
key=TYPE_WEEKDAY,
|
key=TYPE_WEEKDAY,
|
||||||
name="Weekday Restrictions",
|
name="Weekday restrictions",
|
||||||
icon="mdi:cancel",
|
icon="mdi:cancel",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
@ -68,7 +68,7 @@ class RainMachineSensorDescriptionUid(
|
|||||||
SENSOR_DESCRIPTIONS = (
|
SENSOR_DESCRIPTIONS = (
|
||||||
RainMachineSensorDescriptionApiCategory(
|
RainMachineSensorDescriptionApiCategory(
|
||||||
key=TYPE_FLOW_SENSOR_CLICK_M3,
|
key=TYPE_FLOW_SENSOR_CLICK_M3,
|
||||||
name="Flow Sensor Clicks per Cubic Meter",
|
name="Flow sensor clicks per cubic meter",
|
||||||
icon="mdi:water-pump",
|
icon="mdi:water-pump",
|
||||||
native_unit_of_measurement=f"clicks/{VOLUME_CUBIC_METERS}",
|
native_unit_of_measurement=f"clicks/{VOLUME_CUBIC_METERS}",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
@ -79,7 +79,7 @@ SENSOR_DESCRIPTIONS = (
|
|||||||
),
|
),
|
||||||
RainMachineSensorDescriptionApiCategory(
|
RainMachineSensorDescriptionApiCategory(
|
||||||
key=TYPE_FLOW_SENSOR_CONSUMED_LITERS,
|
key=TYPE_FLOW_SENSOR_CONSUMED_LITERS,
|
||||||
name="Flow Sensor Consumed Liters",
|
name="Flow sensor consumed liters",
|
||||||
icon="mdi:water-pump",
|
icon="mdi:water-pump",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
native_unit_of_measurement="liter",
|
native_unit_of_measurement="liter",
|
||||||
@ -90,7 +90,7 @@ SENSOR_DESCRIPTIONS = (
|
|||||||
),
|
),
|
||||||
RainMachineSensorDescriptionApiCategory(
|
RainMachineSensorDescriptionApiCategory(
|
||||||
key=TYPE_FLOW_SENSOR_START_INDEX,
|
key=TYPE_FLOW_SENSOR_START_INDEX,
|
||||||
name="Flow Sensor Start Index",
|
name="Flow sensor start index",
|
||||||
icon="mdi:water-pump",
|
icon="mdi:water-pump",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
native_unit_of_measurement="index",
|
native_unit_of_measurement="index",
|
||||||
@ -100,7 +100,7 @@ SENSOR_DESCRIPTIONS = (
|
|||||||
),
|
),
|
||||||
RainMachineSensorDescriptionApiCategory(
|
RainMachineSensorDescriptionApiCategory(
|
||||||
key=TYPE_FLOW_SENSOR_WATERING_CLICKS,
|
key=TYPE_FLOW_SENSOR_WATERING_CLICKS,
|
||||||
name="Flow Sensor Clicks",
|
name="Flow sensor clicks",
|
||||||
icon="mdi:water-pump",
|
icon="mdi:water-pump",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
native_unit_of_measurement="clicks",
|
native_unit_of_measurement="clicks",
|
||||||
@ -111,7 +111,7 @@ SENSOR_DESCRIPTIONS = (
|
|||||||
),
|
),
|
||||||
RainMachineSensorDescriptionApiCategory(
|
RainMachineSensorDescriptionApiCategory(
|
||||||
key=TYPE_FREEZE_TEMP,
|
key=TYPE_FREEZE_TEMP,
|
||||||
name="Freeze Protect Temperature",
|
name="Freeze protect temperature",
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
@ -149,6 +149,8 @@ async def async_setup_entry(
|
|||||||
("zone", zone_coordinator, RainMachineZone, RainMachineZoneEnabled),
|
("zone", zone_coordinator, RainMachineZone, RainMachineZoneEnabled),
|
||||||
):
|
):
|
||||||
for uid, data in coordinator.data.items():
|
for uid, data in coordinator.data.items():
|
||||||
|
name = data["name"].capitalize()
|
||||||
|
|
||||||
# Add a switch to start/stop the program or zone:
|
# Add a switch to start/stop the program or zone:
|
||||||
entities.append(
|
entities.append(
|
||||||
switch_class(
|
switch_class(
|
||||||
@ -157,7 +159,7 @@ async def async_setup_entry(
|
|||||||
controller,
|
controller,
|
||||||
RainMachineSwitchDescription(
|
RainMachineSwitchDescription(
|
||||||
key=f"{kind}_{uid}",
|
key=f"{kind}_{uid}",
|
||||||
name=data["name"],
|
name=name,
|
||||||
icon="mdi:water",
|
icon="mdi:water",
|
||||||
uid=uid,
|
uid=uid,
|
||||||
),
|
),
|
||||||
@ -172,7 +174,7 @@ async def async_setup_entry(
|
|||||||
controller,
|
controller,
|
||||||
RainMachineSwitchDescription(
|
RainMachineSwitchDescription(
|
||||||
key=f"{kind}_{uid}_enabled",
|
key=f"{kind}_{uid}_enabled",
|
||||||
name=f"{data['name']} Enabled",
|
name=f"{name} enabled",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
icon="mdi:cog",
|
icon="mdi:cog",
|
||||||
uid=uid,
|
uid=uid,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user