Migrate Switchbot to new entity naming style (#80008)

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
Patrick ZAJDA 2022-10-10 14:12:50 +02:00 committed by GitHub
parent c7b56f4079
commit d0bffb6c75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 7 deletions

View file

@ -26,6 +26,7 @@ PARALLEL_UPDATES = 0
SENSOR_TYPES: dict[str, SensorEntityDescription] = {
"rssi": SensorEntityDescription(
key="rssi",
name="Bluetooth signal strength",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
state_class=SensorStateClass.MEASUREMENT,
@ -34,6 +35,7 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
),
"wifi_rssi": SensorEntityDescription(
key="wifi_rssi",
name="Wi-Fi signal strength",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
state_class=SensorStateClass.MEASUREMENT,
@ -42,6 +44,7 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
),
"battery": SensorEntityDescription(
key="battery",
name="Battery",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
state_class=SensorStateClass.MEASUREMENT,
@ -49,18 +52,21 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
),
"lightLevel": SensorEntityDescription(
key="lightLevel",
name="Light level",
native_unit_of_measurement="Level",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.ILLUMINANCE,
),
"humidity": SensorEntityDescription(
key="humidity",
name="Humidity",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.HUMIDITY,
),
"temperature": SensorEntityDescription(
key="temperature",
name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
@ -97,8 +103,6 @@ class SwitchBotSensor(SwitchbotEntity, SensorEntity):
super().__init__(coordinator)
self._sensor = sensor
self._attr_unique_id = f"{coordinator.base_unique_id}-{sensor}"
name = coordinator.device_name
self._attr_name = f"{name} {sensor.replace('_', ' ').title()}"
self.entity_description = SENSOR_TYPES[sensor]
@property