Skip to content

Commit

Permalink
Add icon translations to DROP connect (#111373)
Browse files Browse the repository at this point in the history
* Add icon translations to DROP connect

* Add icon translations to DROP connect
  • Loading branch information
joostlek committed Feb 28, 2024
1 parent 7ad1d3e commit 40431a9
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 51 deletions.
10 changes: 0 additions & 10 deletions homeassistant/components/drop_connect/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@

_LOGGER = logging.getLogger(__name__)

LEAK_ICON = "mdi:pipe-leak"
NOTIFICATION_ICON = "mdi:bell-ring"
PUMP_ICON = "mdi:water-pump"
SALT_ICON = "mdi:shaker"
WATER_ICON = "mdi:water"

# Binary sensor type constants
LEAK_DETECTED = "leak"
Expand All @@ -56,32 +51,27 @@ class DROPBinarySensorEntityDescription(BinarySensorEntityDescription):
DROPBinarySensorEntityDescription(
key=LEAK_DETECTED,
translation_key=LEAK_DETECTED,
icon=LEAK_ICON,
device_class=BinarySensorDeviceClass.MOISTURE,
value_fn=lambda device: device.drop_api.leak_detected(),
),
DROPBinarySensorEntityDescription(
key=PENDING_NOTIFICATION,
translation_key=PENDING_NOTIFICATION,
icon=NOTIFICATION_ICON,
value_fn=lambda device: device.drop_api.notification_pending(),
),
DROPBinarySensorEntityDescription(
key=SALT_LOW,
translation_key=SALT_LOW,
icon=SALT_ICON,
value_fn=lambda device: device.drop_api.salt_low(),
),
DROPBinarySensorEntityDescription(
key=RESERVE_IN_USE,
translation_key=RESERVE_IN_USE,
icon=WATER_ICON,
value_fn=lambda device: device.drop_api.reserve_in_use(),
),
DROPBinarySensorEntityDescription(
key=PUMP_STATUS,
translation_key=PUMP_STATUS,
icon=PUMP_ICON,
value_fn=lambda device: device.drop_api.pump_status(),
),
]
Expand Down
65 changes: 65 additions & 0 deletions homeassistant/components/drop_connect/icons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"entity": {
"binary_sensor": {
"leak": {
"default": "mdi:pipe-leak"
},
"pending_notification": {
"default": "mdi:bell-ring"
},
"pump": {
"default": "mdi:water-pump"
},
"reserve_in_use": {
"default": "mdi:water"
},
"salt": {
"default": "mdi:shaker"
}
},
"select": {
"protect_mode": {
"default": "mdi:home-flood"
}
},
"sensor": {
"current_flow_rate": {
"default": "mdi:shower-head"
},
"peak_flow_rate": {
"default": "mdi:shower-head"
},
"inlet_tds": {
"default": "mdi:water-opacity"
},
"outlet_tds": {
"default": "mdi:water-opacity"
},
"cart1": {
"default": "mdi:gauge"
},
"cart2": {
"default": "mdi:gauge"
},
"cart3": {
"default": "mdi:gauge"
}
},
"switch": {
"water": {
"default": "mdi:valve",
"state": {
"on": "mdi:valve-open",
"off": "mdi:valve-closed"
}
},
"bypass": {
"default": "mdi:valve",
"state": {
"on": "mdi:valve-open",
"off": "mdi:valve-closed"
}
}
}
}
}
3 changes: 0 additions & 3 deletions homeassistant/components/drop_connect/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

PROTECT_MODE_OPTIONS = ["away", "home", "schedule"]

FLOOD_ICON = "mdi:home-flood"


@dataclass(kw_only=True, frozen=True)
class DROPSelectEntityDescription(SelectEntityDescription):
Expand All @@ -38,7 +36,6 @@ class DROPSelectEntityDescription(SelectEntityDescription):
DROPSelectEntityDescription(
key=PROTECT_MODE,
translation_key=PROTECT_MODE,
icon=FLOOD_ICON,
options=PROTECT_MODE_OPTIONS,
value_fn=lambda device: device.drop_api.protect_mode(),
set_fn=lambda device, value: device.set_protect_mode(value),
Expand Down
10 changes: 0 additions & 10 deletions homeassistant/components/drop_connect/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@

_LOGGER = logging.getLogger(__name__)

FLOW_ICON = "mdi:shower-head"
GAUGE_ICON = "mdi:gauge"
TDS_ICON = "mdi:water-opacity"

# Sensor type constants
CURRENT_FLOW_RATE = "current_flow_rate"
Expand Down Expand Up @@ -72,7 +69,6 @@ class DROPSensorEntityDescription(SensorEntityDescription):
DROPSensorEntityDescription(
key=CURRENT_FLOW_RATE,
translation_key=CURRENT_FLOW_RATE,
icon="mdi:shower-head",
native_unit_of_measurement="gpm",
suggested_display_precision=1,
value_fn=lambda device: device.drop_api.current_flow_rate(),
Expand All @@ -81,7 +77,6 @@ class DROPSensorEntityDescription(SensorEntityDescription):
DROPSensorEntityDescription(
key=PEAK_FLOW_RATE,
translation_key=PEAK_FLOW_RATE,
icon="mdi:shower-head",
native_unit_of_measurement="gpm",
suggested_display_precision=1,
value_fn=lambda device: device.drop_api.peak_flow_rate(),
Expand Down Expand Up @@ -161,7 +156,6 @@ class DROPSensorEntityDescription(SensorEntityDescription):
DROPSensorEntityDescription(
key=INLET_TDS,
translation_key=INLET_TDS,
icon=TDS_ICON,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
Expand All @@ -170,7 +164,6 @@ class DROPSensorEntityDescription(SensorEntityDescription):
DROPSensorEntityDescription(
key=OUTLET_TDS,
translation_key=OUTLET_TDS,
icon=TDS_ICON,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
Expand All @@ -179,7 +172,6 @@ class DROPSensorEntityDescription(SensorEntityDescription):
DROPSensorEntityDescription(
key=CARTRIDGE_1_LIFE,
translation_key=CARTRIDGE_1_LIFE,
icon=GAUGE_ICON,
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
Expand All @@ -189,7 +181,6 @@ class DROPSensorEntityDescription(SensorEntityDescription):
DROPSensorEntityDescription(
key=CARTRIDGE_2_LIFE,
translation_key=CARTRIDGE_2_LIFE,
icon=GAUGE_ICON,
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
Expand All @@ -199,7 +190,6 @@ class DROPSensorEntityDescription(SensorEntityDescription):
DROPSensorEntityDescription(
key=CARTRIDGE_3_LIFE,
translation_key=CARTRIDGE_3_LIFE,
icon=GAUGE_ICON,
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
Expand Down
12 changes: 0 additions & 12 deletions homeassistant/components/drop_connect/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@

_LOGGER = logging.getLogger(__name__)

ICON_VALVE_OPEN = "mdi:valve-open"
ICON_VALVE_CLOSED = "mdi:valve-closed"
ICON_VALVE_UNKNOWN = "mdi:valve"
ICON_VALVE = {False: ICON_VALVE_CLOSED, True: ICON_VALVE_OPEN, None: ICON_VALVE_UNKNOWN}

SWITCH_VALUE: dict[int | None, bool] = {0: False, 1: True}

# Switch type constants
Expand All @@ -49,14 +44,12 @@ class DROPSwitchEntityDescription(SwitchEntityDescription):
DROPSwitchEntityDescription(
key=WATER_SWITCH,
translation_key=WATER_SWITCH,
icon=ICON_VALVE_UNKNOWN,
value_fn=lambda device: device.drop_api.water(),
set_fn=lambda device, value: device.set_water(value),
),
DROPSwitchEntityDescription(
key=BYPASS_SWITCH,
translation_key=BYPASS_SWITCH,
icon=ICON_VALVE_UNKNOWN,
value_fn=lambda device: device.drop_api.bypass(),
set_fn=lambda device, value: device.set_bypass(value),
),
Expand Down Expand Up @@ -117,8 +110,3 @@ async def async_turn_on(self, **kwargs: Any) -> None:
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn switch off."""
await self.entity_description.set_fn(self.coordinator, 0)

@property
def icon(self) -> str:
"""Return the icon to use for dynamic states."""
return ICON_VALVE[self.is_on]
24 changes: 8 additions & 16 deletions tests/components/drop_connect/snapshots/test_binary_sensor.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.MOISTURE: 'moisture'>,
'original_icon': 'mdi:pipe-leak',
'original_icon': None,
'original_name': 'Leak detected',
'platform': 'drop_connect',
'previous_unique_id': None,
Expand All @@ -37,7 +37,6 @@
'attributes': ReadOnlyDict({
'device_class': 'moisture',
'friendly_name': 'Hub DROP-1_C0FFEE Leak detected',
'icon': 'mdi:pipe-leak',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.hub_drop_1_c0ffee_leak_detected',
Expand Down Expand Up @@ -69,7 +68,7 @@
'options': dict({
}),
'original_device_class': None,
'original_icon': 'mdi:bell-ring',
'original_icon': None,
'original_name': 'Notification unread',
'platform': 'drop_connect',
'previous_unique_id': None,
Expand All @@ -83,7 +82,6 @@
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Hub DROP-1_C0FFEE Notification unread',
'icon': 'mdi:bell-ring',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.hub_drop_1_c0ffee_notification_unread',
Expand Down Expand Up @@ -115,7 +113,7 @@
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.MOISTURE: 'moisture'>,
'original_icon': 'mdi:pipe-leak',
'original_icon': None,
'original_name': 'Leak detected',
'platform': 'drop_connect',
'previous_unique_id': None,
Expand All @@ -130,7 +128,6 @@
'attributes': ReadOnlyDict({
'device_class': 'moisture',
'friendly_name': 'Leak Detector Leak detected',
'icon': 'mdi:pipe-leak',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.leak_detector_leak_detected',
Expand Down Expand Up @@ -162,7 +159,7 @@
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.MOISTURE: 'moisture'>,
'original_icon': 'mdi:pipe-leak',
'original_icon': None,
'original_name': 'Leak detected',
'platform': 'drop_connect',
'previous_unique_id': None,
Expand All @@ -177,7 +174,6 @@
'attributes': ReadOnlyDict({
'device_class': 'moisture',
'friendly_name': 'Protection Valve Leak detected',
'icon': 'mdi:pipe-leak',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.protection_valve_leak_detected',
Expand Down Expand Up @@ -209,7 +205,7 @@
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.MOISTURE: 'moisture'>,
'original_icon': 'mdi:pipe-leak',
'original_icon': None,
'original_name': 'Leak detected',
'platform': 'drop_connect',
'previous_unique_id': None,
Expand All @@ -224,7 +220,6 @@
'attributes': ReadOnlyDict({
'device_class': 'moisture',
'friendly_name': 'Pump Controller Leak detected',
'icon': 'mdi:pipe-leak',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.pump_controller_leak_detected',
Expand Down Expand Up @@ -256,7 +251,7 @@
'options': dict({
}),
'original_device_class': None,
'original_icon': 'mdi:water-pump',
'original_icon': None,
'original_name': 'Pump status',
'platform': 'drop_connect',
'previous_unique_id': None,
Expand All @@ -270,7 +265,6 @@
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Pump Controller Pump status',
'icon': 'mdi:water-pump',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.pump_controller_pump_status',
Expand Down Expand Up @@ -302,7 +296,7 @@
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.MOISTURE: 'moisture'>,
'original_icon': 'mdi:pipe-leak',
'original_icon': None,
'original_name': 'Leak detected',
'platform': 'drop_connect',
'previous_unique_id': None,
Expand All @@ -317,7 +311,6 @@
'attributes': ReadOnlyDict({
'device_class': 'moisture',
'friendly_name': 'RO Filter Leak detected',
'icon': 'mdi:pipe-leak',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.ro_filter_leak_detected',
Expand Down Expand Up @@ -349,7 +342,7 @@
'options': dict({
}),
'original_device_class': None,
'original_icon': 'mdi:water',
'original_icon': None,
'original_name': 'Reserve capacity in use',
'platform': 'drop_connect',
'previous_unique_id': None,
Expand All @@ -363,7 +356,6 @@
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Softener Reserve capacity in use',
'icon': 'mdi:water',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.softener_reserve_capacity_in_use',
Expand Down

0 comments on commit 40431a9

Please sign in to comment.