Skip to content

Commit

Permalink
fix: main feature entity name (#259)
Browse files Browse the repository at this point in the history
* fix: main feature entity name

* feat(40): new entity name translation

* chore(pre-commit.ci): auto fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
caibinqing and pre-commit-ci[bot] authored Jul 30, 2024
1 parent 4c1aac4 commit 2a663fb
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 2 deletions.
14 changes: 13 additions & 1 deletion custom_components/midea_ac_lan/midea_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,26 +197,38 @@
0x40: {
"name": "Integrated Ceiling Fan",
"entities": {
"fan": {"type": Platform.FAN, "icon": "mdi:fan", "default": True},
"fan": {
"type": Platform.FAN,
"has_entity_name": True,
"icon": "mdi:fan",
"default": True,
},
X40Attributes.current_temperature: {
"type": Platform.SENSOR,
"has_entity_name": True,
"name": "Current Temperature",
"device_class": SensorDeviceClass.TEMPERATURE,
"unit": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT,
},
X40Attributes.light: {
"type": Platform.SWITCH,
"has_entity_name": True,
"translation_key": "light",
"name": "Light",
"icon": "mdi:lightbulb",
},
X40Attributes.ventilation: {
"type": Platform.SWITCH,
"has_entity_name": True,
"translation_key": "ventilation",
"name": "Ventilation",
"icon": "mdi:air-filter",
},
X40Attributes.smelly_sensor: {
"type": Platform.SWITCH,
"has_entity_name": True,
"translation_key": "smelly_sensor",
"name": "Smelly Sensor",
"icon": "mdi:scent",
},
Expand Down
6 changes: 5 additions & 1 deletion custom_components/midea_ac_lan/midea_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def __init__(self, device: MideaDevice, entity_key: str) -> None:

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
if self.has_entity_name:
if self._config.get("name") is None:
self._attr_name = None
else:
# old behavior
self._attr_name = (
f"{self._device_name} {self._config.get('name')}"
if "name" in self._config
Expand Down
9 changes: 9 additions & 0 deletions custom_components/midea_ac_lan/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,17 @@
}
},
"switch": {
"light": {
"name": "Light"
},
"power": {
"name": "Power"
},
"smelly_sensor": {
"name": "Smelly Sensor"
},
"ventilation": {
"name": "Ventilation"
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions custom_components/midea_ac_lan/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,17 @@
}
},
"switch": {
"light": {
"name": "Light"
},
"power": {
"name": "Power"
},
"smelly_sensor": {
"name": "Smelly Sensor"
},
"ventilation": {
"name": "Ventilation"
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions custom_components/midea_ac_lan/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,17 @@
}
},
"switch": {
"light": {
"name": "Light"
},
"power": {
"name": "Power"
},
"smelly_sensor": {
"name": "Smelly Sensor"
},
"ventilation": {
"name": "Ventilation"
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions custom_components/midea_ac_lan/translations/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,17 @@
}
},
"switch": {
"light": {
"name": "Light"
},
"power": {
"name": "Power"
},
"smelly_sensor": {
"name": "Smelly Sensor"
},
"ventilation": {
"name": "Ventilation"
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions custom_components/midea_ac_lan/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,17 @@
}
},
"switch": {
"light": {
"name": "Light"
},
"power": {
"name": "Power"
},
"smelly_sensor": {
"name": "Smelly Sensor"
},
"ventilation": {
"name": "Ventilation"
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions custom_components/midea_ac_lan/translations/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,17 @@
}
},
"switch": {
"light": {
"name": "Light"
},
"power": {
"name": "Power"
},
"smelly_sensor": {
"name": "Smelly Sensor"
},
"ventilation": {
"name": "Ventilation"
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions custom_components/midea_ac_lan/translations/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,17 @@
}
},
"switch": {
"light": {
"name": "灯光"
},
"power": {
"name": "电源开关"
},
"smelly_sensor": {
"name": "异味感应"
},
"ventilation": {
"name": "换气"
}
}
},
Expand Down

0 comments on commit 2a663fb

Please sign in to comment.