Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new entity naming #174

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion custom_components/midea_ac_lan/midea_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1918,70 +1918,95 @@
0xED: {
"name": "Water Drinking Appliance",
"entities": {
EDAttributes.child_lock: {"type": Platform.LOCK, "name": "Child Lock"},
EDAttributes.child_lock: {
"type": Platform.LOCK,
"has_entity_name": True,
"translation_key": "child_lock",
"name": "Child Lock",
},
EDAttributes.power: {
"type": Platform.SWITCH,
"has_entity_name": True,
"translation_key": "power",
"name": "Power",
"icon": "mdi:power",
},
EDAttributes.filter1: {
"type": Platform.SENSOR,
"has_entity_name": True,
"translation_key": "filter1_days",
"name": "Filter1 Available Days",
"icon": "mdi:air-filter",
"unit": UnitOfTime.DAYS,
"state_class": SensorStateClass.MEASUREMENT,
},
EDAttributes.filter2: {
"type": Platform.SENSOR,
"has_entity_name": True,
"translation_key": "filter2_days",
"name": "Filter2 Available Days",
"icon": "mdi:air-filter",
"unit": UnitOfTime.DAYS,
"state_class": SensorStateClass.MEASUREMENT,
},
EDAttributes.filter3: {
"type": Platform.SENSOR,
"has_entity_name": True,
"translation_key": "filter3_days",
"name": "Filter3 Available Days",
"icon": "mdi:air-filter",
"unit": UnitOfTime.DAYS,
"state_class": SensorStateClass.MEASUREMENT,
},
EDAttributes.life1: {
"type": Platform.SENSOR,
"has_entity_name": True,
"translation_key": "filter1_life",
"name": "Filter1 Life Level",
"icon": "mdi:percent",
"unit": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT,
},
EDAttributes.life2: {
"type": Platform.SENSOR,
"has_entity_name": True,
"translation_key": "filter2_life",
"name": "Filter2 Life Level",
"icon": "mdi:percent",
"unit": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT,
},
EDAttributes.life3: {
"type": Platform.SENSOR,
"has_entity_name": True,
"translation_key": "filter3_life",
"name": "Filter3 Life Level",
"icon": "mdi:percent",
"unit": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT,
},
EDAttributes.in_tds: {
"type": Platform.SENSOR,
"has_entity_name": True,
"translation_key": "in_tds",
"name": "In TDS",
"icon": "mdi:water",
"unit": CONCENTRATION_PARTS_PER_MILLION,
"state_class": SensorStateClass.MEASUREMENT,
},
EDAttributes.out_tds: {
"type": Platform.SENSOR,
"has_entity_name": True,
"translation_key": "out_tds",
"name": "Out TDS",
"icon": "mdi:water-plus",
"unit": CONCENTRATION_PARTS_PER_MILLION,
"state_class": SensorStateClass.MEASUREMENT,
},
EDAttributes.water_consumption: {
"type": Platform.SENSOR,
"has_entity_name": True,
"translation_key": "water_consumption",
"name": "Water Consumption",
"icon": "mdi:water-pump",
"unit": UnitOfVolume.LITERS,
Expand Down
18 changes: 9 additions & 9 deletions custom_components/midea_ac_lan/midea_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ def __init__(self, device: MideaDevice, entity_key: str) -> None:
self.entity_id = self._unique_id
self._device_name = self._device.name

self._attr_translation_key = self._config.get("translation_key")
self._attr_has_entity_name = self._config.get("has_entity_name", False)
if not self.has_entity_name: # old behavior
self._attr_name = (
f"{self._device_name} {self._config.get('name')}"
if "name" in self._config
else self._device_name
)

@property
def device(self) -> MideaDevice:
"""Return device structure."""
Expand Down Expand Up @@ -62,15 +71,6 @@ def should_poll(self) -> bool:
"""Return true is integration should poll."""
return False

@property
def name(self) -> str:
"""Return entity name."""
return (
f"{self._device_name} {self._config.get('name')}"
if "name" in self._config
else self._device_name
)

@property
def available(self) -> bool:
"""Return entity availability."""
Expand Down
41 changes: 41 additions & 0 deletions custom_components/midea_ac_lan/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,47 @@
}
}
},
"entity": {
"lock": {
"child_lock": {
"name": "Child Lock"
}
},
"sensor": {
"filter1_days": {
"name": "Filter1 Available Days"
},
"filter2_days": {
"name": "Filter2 Available Days"
},
"filter3_days": {
"name": "Filter3 Available Days"
},
"filter1_life": {
"name": "Filter1 Life Level"
},
"filter2_life": {
"name": "Filter2 Life Level"
},
"filter3_life": {
"name": "Filter3 Life Level"
},
"in_tds": {
"name": "In TDS"
},
"out_tds": {
"name": "Out TDS"
},
"water_consumption": {
"name": "Water Consumption"
}
},
"switch": {
"power": {
"name": "Power"
}
}
},
"options": {
"step": {
"init": {
Expand Down
41 changes: 41 additions & 0 deletions custom_components/midea_ac_lan/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,47 @@
}
}
},
"entity": {
"lock": {
"child_lock": {
"name": "Child Lock"
}
},
"sensor": {
"filter1_days": {
"name": "Filter1 Available Days"
},
"filter2_days": {
"name": "Filter2 Available Days"
},
"filter3_days": {
"name": "Filter3 Available Days"
},
"filter1_life": {
"name": "Filter1 Life Level"
},
"filter2_life": {
"name": "Filter2 Life Level"
},
"filter3_life": {
"name": "Filter3 Life Level"
},
"in_tds": {
"name": "In TDS"
},
"out_tds": {
"name": "Out TDS"
},
"water_consumption": {
"name": "Water Consumption"
}
},
"switch": {
"power": {
"name": "Power"
}
}
},
"options": {
"step": {
"init": {
Expand Down
41 changes: 41 additions & 0 deletions custom_components/midea_ac_lan/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,47 @@
}
}
},
"entity": {
"lock": {
"child_lock": {
"name": "Child Lock"
}
},
"sensor": {
"filter1_days": {
"name": "Filter1 Available Days"
},
"filter2_days": {
"name": "Filter2 Available Days"
},
"filter3_days": {
"name": "Filter3 Available Days"
},
"filter1_life": {
"name": "Filter1 Life Level"
},
"filter2_life": {
"name": "Filter2 Life Level"
},
"filter3_life": {
"name": "Filter3 Life Level"
},
"in_tds": {
"name": "In TDS"
},
"out_tds": {
"name": "Out TDS"
},
"water_consumption": {
"name": "Water Consumption"
}
},
"switch": {
"power": {
"name": "Power"
}
}
},
"options": {
"step": {
"init": {
Expand Down
41 changes: 41 additions & 0 deletions custom_components/midea_ac_lan/translations/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,47 @@
}
}
},
"entity": {
"lock": {
"child_lock": {
"name": "Child Lock"
}
},
"sensor": {
"filter1_days": {
"name": "Filter1 Available Days"
},
"filter2_days": {
"name": "Filter2 Available Days"
},
"filter3_days": {
"name": "Filter3 Available Days"
},
"filter1_life": {
"name": "Filter1 Life Level"
},
"filter2_life": {
"name": "Filter2 Life Level"
},
"filter3_life": {
"name": "Filter3 Life Level"
},
"in_tds": {
"name": "In TDS"
},
"out_tds": {
"name": "Out TDS"
},
"water_consumption": {
"name": "Water Consumption"
}
},
"switch": {
"power": {
"name": "Power"
}
}
},
"options": {
"step": {
"init": {
Expand Down
41 changes: 41 additions & 0 deletions custom_components/midea_ac_lan/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,47 @@
}
}
},
"entity": {
"lock": {
"child_lock": {
"name": "Child Lock"
}
},
"sensor": {
"filter1_days": {
"name": "Filter1 Available Days"
},
"filter2_days": {
"name": "Filter2 Available Days"
},
"filter3_days": {
"name": "Filter3 Available Days"
},
"filter1_life": {
"name": "Filter1 Life Level"
},
"filter2_life": {
"name": "Filter2 Life Level"
},
"filter3_life": {
"name": "Filter3 Life Level"
},
"in_tds": {
"name": "In TDS"
},
"out_tds": {
"name": "Out TDS"
},
"water_consumption": {
"name": "Water Consumption"
}
},
"switch": {
"power": {
"name": "Power"
}
}
},
"options": {
"step": {
"init": {
Expand Down
Loading
Loading