mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Add entity name translations to Switchbot (#90600)
* Add entity name translations to Switchbot Signed-off-by: Patrick ZAJDA <patrick@zajda.fr> * Apply suggestions from code review Signed-off-by: Patrick ZAJDA <patrick@zajda.fr> * Fix tests Signed-off-by: Patrick ZAJDA <patrick@zajda.fr> * Update homeassistant/components/switchbot/strings.json Co-authored-by: Patrick ZAJDA <patrick@zajda.fr> --------- Signed-off-by: Patrick ZAJDA <patrick@zajda.fr> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
186f47ba46
commit
4456557a02
@ -20,50 +20,50 @@ PARALLEL_UPDATES = 0
|
||||
BINARY_SENSOR_TYPES: dict[str, BinarySensorEntityDescription] = {
|
||||
"calibration": BinarySensorEntityDescription(
|
||||
key="calibration",
|
||||
name="Calibration",
|
||||
translation_key="calibration",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
"motion_detected": BinarySensorEntityDescription(
|
||||
key="pir_state",
|
||||
name="Motion detected",
|
||||
translation_key="motion",
|
||||
device_class=BinarySensorDeviceClass.MOTION,
|
||||
),
|
||||
"contact_open": BinarySensorEntityDescription(
|
||||
key="contact_open",
|
||||
name="Door open",
|
||||
translation_key="door_open",
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
),
|
||||
"contact_timeout": BinarySensorEntityDescription(
|
||||
key="contact_timeout",
|
||||
name="Door timeout",
|
||||
translation_key="door_timeout",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
"is_light": BinarySensorEntityDescription(
|
||||
key="is_light",
|
||||
name="Light",
|
||||
translation_key="light",
|
||||
device_class=BinarySensorDeviceClass.LIGHT,
|
||||
),
|
||||
"door_open": BinarySensorEntityDescription(
|
||||
key="door_status",
|
||||
name="Door status",
|
||||
translation_key="door_open",
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
),
|
||||
"unclosed_alarm": BinarySensorEntityDescription(
|
||||
key="unclosed_alarm",
|
||||
name="Door unclosed alarm",
|
||||
translation_key="door_unclosed_alarm",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
),
|
||||
"unlocked_alarm": BinarySensorEntityDescription(
|
||||
key="unlocked_alarm",
|
||||
name="Door unlocked alarm",
|
||||
translation_key="door_unclosed_alarm",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
),
|
||||
"auto_lock_paused": BinarySensorEntityDescription(
|
||||
key="auto_lock_paused",
|
||||
name="Door auto-lock paused",
|
||||
translation_key="door_auto_lock_paused",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ PARALLEL_UPDATES = 0
|
||||
SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
||||
"rssi": SensorEntityDescription(
|
||||
key="rssi",
|
||||
name="Bluetooth signal strength",
|
||||
translation_key="bluetooth_signal",
|
||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
@ -37,7 +37,7 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
||||
),
|
||||
"wifi_rssi": SensorEntityDescription(
|
||||
key="wifi_rssi",
|
||||
name="Wi-Fi signal strength",
|
||||
translation_key="wifi_signal",
|
||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
@ -46,7 +46,7 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
||||
),
|
||||
"battery": SensorEntityDescription(
|
||||
key="battery",
|
||||
name="Battery",
|
||||
translation_key="battery",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
device_class=SensorDeviceClass.BATTERY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
@ -54,27 +54,27 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
||||
),
|
||||
"lightLevel": SensorEntityDescription(
|
||||
key="lightLevel",
|
||||
name="Light level",
|
||||
translation_key="light_level",
|
||||
native_unit_of_measurement="Level",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
"humidity": SensorEntityDescription(
|
||||
key="humidity",
|
||||
name="Humidity",
|
||||
translation_key="humidity",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
device_class=SensorDeviceClass.HUMIDITY,
|
||||
),
|
||||
"temperature": SensorEntityDescription(
|
||||
key="temperature",
|
||||
name="Temperature",
|
||||
translation_key="temperature",
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
),
|
||||
"power": SensorEntityDescription(
|
||||
key="power",
|
||||
name="Power",
|
||||
translation_key="power",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
|
@ -58,5 +58,56 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"calibration": {
|
||||
"name": "Calibration"
|
||||
},
|
||||
"motion": {
|
||||
"name": "[%key:component::binary_sensor::entity_component::motion::name%]"
|
||||
},
|
||||
"door_open": {
|
||||
"name": "[%key:component::binary_sensor::entity_component::door::name%]"
|
||||
},
|
||||
"door_timeout": {
|
||||
"name": "Timeout"
|
||||
},
|
||||
"light": {
|
||||
"name": "[%key:component::binary_sensor::entity_component::light::name%]"
|
||||
},
|
||||
"door_unclosed_alarm": {
|
||||
"name": "Unclosed alarm"
|
||||
},
|
||||
"door_unlocked_alarm": {
|
||||
"name": "Unlocked alarm"
|
||||
},
|
||||
"door_auto_lock_paused": {
|
||||
"name": "Auto-lock paused"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"bluetooth_signal": {
|
||||
"name": "Bluetooth signal"
|
||||
},
|
||||
"wifi_signal": {
|
||||
"name": "Wi-Fi signal"
|
||||
},
|
||||
"battery": {
|
||||
"name": "[%key:component::sensor::entity_component::battery::name%]"
|
||||
},
|
||||
"light_level": {
|
||||
"name": "Light level"
|
||||
},
|
||||
"humidity": {
|
||||
"name": "[%key:component::sensor::entity_component::humidity::name%]"
|
||||
},
|
||||
"temperature": {
|
||||
"name": "[%key:component::sensor::entity_component::temperature::name%]"
|
||||
},
|
||||
"power": {
|
||||
"name": "[%key:component::sensor::entity_component::power::name%]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,12 +50,10 @@ async def test_sensors(
|
||||
assert battery_sensor_attrs[ATTR_UNIT_OF_MEASUREMENT] == "%"
|
||||
assert battery_sensor_attrs[ATTR_STATE_CLASS] == "measurement"
|
||||
|
||||
rssi_sensor = hass.states.get("sensor.test_name_bluetooth_signal_strength")
|
||||
rssi_sensor = hass.states.get("sensor.test_name_bluetooth_signal")
|
||||
rssi_sensor_attrs = rssi_sensor.attributes
|
||||
assert rssi_sensor.state == "-60"
|
||||
assert (
|
||||
rssi_sensor_attrs[ATTR_FRIENDLY_NAME] == "test-name Bluetooth signal strength"
|
||||
)
|
||||
assert rssi_sensor_attrs[ATTR_FRIENDLY_NAME] == "test-name Bluetooth signal"
|
||||
assert rssi_sensor_attrs[ATTR_UNIT_OF_MEASUREMENT] == "dBm"
|
||||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user