diff --git a/homeassistant/components/switchbot/binary_sensor.py b/homeassistant/components/switchbot/binary_sensor.py index 675f3128721..00b22d9428c 100644 --- a/homeassistant/components/switchbot/binary_sensor.py +++ b/homeassistant/components/switchbot/binary_sensor.py @@ -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, ), } diff --git a/homeassistant/components/switchbot/sensor.py b/homeassistant/components/switchbot/sensor.py index 3ed43790b83..b5b34bf54ec 100644 --- a/homeassistant/components/switchbot/sensor.py +++ b/homeassistant/components/switchbot/sensor.py @@ -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, diff --git a/homeassistant/components/switchbot/strings.json b/homeassistant/components/switchbot/strings.json index 3262ffbd7bb..74226583420 100644 --- a/homeassistant/components/switchbot/strings.json +++ b/homeassistant/components/switchbot/strings.json @@ -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%]" + } + } } } diff --git a/tests/components/switchbot/test_sensor.py b/tests/components/switchbot/test_sensor.py index 80c85cdb601..12a570d5b26 100644 --- a/tests/components/switchbot/test_sensor.py +++ b/tests/components/switchbot/test_sensor.py @@ -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)