Add entity translations to iBeacon (#95460)
* Add entity translations to iBeacon * Add entity translations to iBeaconpull/95478/head
parent
4959fce1e0
commit
ecfb259438
|
@ -38,7 +38,6 @@ class IBeaconSensorEntityDescription(SensorEntityDescription, IBeaconRequiredKey
|
|||
SENSOR_DESCRIPTIONS = (
|
||||
IBeaconSensorEntityDescription(
|
||||
key="rssi",
|
||||
name="Signal Strength",
|
||||
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
entity_registry_enabled_default=False,
|
||||
|
@ -47,7 +46,7 @@ SENSOR_DESCRIPTIONS = (
|
|||
),
|
||||
IBeaconSensorEntityDescription(
|
||||
key="power",
|
||||
name="Power",
|
||||
translation_key="power",
|
||||
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
entity_registry_enabled_default=False,
|
||||
|
@ -56,7 +55,7 @@ SENSOR_DESCRIPTIONS = (
|
|||
),
|
||||
IBeaconSensorEntityDescription(
|
||||
key="estimated_distance",
|
||||
name="Estimated Distance",
|
||||
translation_key="estimated_distance",
|
||||
icon="mdi:signal-distance-variant",
|
||||
native_unit_of_measurement=UnitOfLength.METERS,
|
||||
value_fn=lambda ibeacon_advertisement: ibeacon_advertisement.distance,
|
||||
|
@ -65,7 +64,7 @@ SENSOR_DESCRIPTIONS = (
|
|||
),
|
||||
IBeaconSensorEntityDescription(
|
||||
key="vendor",
|
||||
name="Vendor",
|
||||
translation_key="vendor",
|
||||
entity_registry_enabled_default=False,
|
||||
value_fn=lambda ibeacon_advertisement: ibeacon_advertisement.vendor,
|
||||
),
|
||||
|
|
|
@ -19,5 +19,18 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"power": {
|
||||
"name": "Power"
|
||||
},
|
||||
"estimated_distance": {
|
||||
"name": "Estimated distance"
|
||||
},
|
||||
"vendor": {
|
||||
"name": "Vendor"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ async def test_sensors_updates_fixed_mac_address(hass: HomeAssistant) -> None:
|
|||
assert distance_sensor.state == "2"
|
||||
assert (
|
||||
distance_attributes[ATTR_FRIENDLY_NAME]
|
||||
== "BlueCharm_177999 8105 Estimated Distance"
|
||||
== "BlueCharm_177999 8105 Estimated distance"
|
||||
)
|
||||
assert distance_attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
|
||||
assert distance_attributes[ATTR_STATE_CLASS] == "measurement"
|
||||
|
@ -70,7 +70,7 @@ async def test_sensors_updates_fixed_mac_address(hass: HomeAssistant) -> None:
|
|||
assert distance_sensor.state == "0"
|
||||
assert (
|
||||
distance_attributes[ATTR_FRIENDLY_NAME]
|
||||
== "BlueCharm_177999 8105 Estimated Distance"
|
||||
== "BlueCharm_177999 8105 Estimated distance"
|
||||
)
|
||||
assert distance_attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
|
||||
assert distance_attributes[ATTR_STATE_CLASS] == "measurement"
|
||||
|
@ -97,7 +97,7 @@ async def test_sensors_updates_fixed_mac_address(hass: HomeAssistant) -> None:
|
|||
assert distance_sensor.state == "14"
|
||||
assert (
|
||||
distance_attributes[ATTR_FRIENDLY_NAME]
|
||||
== "BlueCharm_177999 8105 Estimated Distance"
|
||||
== "BlueCharm_177999 8105 Estimated distance"
|
||||
)
|
||||
assert distance_attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
|
||||
assert distance_attributes[ATTR_STATE_CLASS] == "measurement"
|
||||
|
@ -204,7 +204,7 @@ async def test_multiple_uuids_same_beacon(hass: HomeAssistant) -> None:
|
|||
distance_attributes = distance_sensor.attributes
|
||||
assert distance_sensor.state == "400"
|
||||
assert (
|
||||
distance_attributes[ATTR_FRIENDLY_NAME] == "FSC-BP108 EEFF Estimated Distance"
|
||||
distance_attributes[ATTR_FRIENDLY_NAME] == "FSC-BP108 EEFF Estimated distance"
|
||||
)
|
||||
assert distance_attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
|
||||
assert distance_attributes[ATTR_STATE_CLASS] == "measurement"
|
||||
|
@ -217,7 +217,7 @@ async def test_multiple_uuids_same_beacon(hass: HomeAssistant) -> None:
|
|||
distance_attributes = distance_sensor.attributes
|
||||
assert distance_sensor.state == "0"
|
||||
assert (
|
||||
distance_attributes[ATTR_FRIENDLY_NAME] == "FSC-BP108 EEFF Estimated Distance"
|
||||
distance_attributes[ATTR_FRIENDLY_NAME] == "FSC-BP108 EEFF Estimated distance"
|
||||
)
|
||||
assert distance_attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
|
||||
assert distance_attributes[ATTR_STATE_CLASS] == "measurement"
|
||||
|
@ -230,7 +230,7 @@ async def test_multiple_uuids_same_beacon(hass: HomeAssistant) -> None:
|
|||
distance_attributes = distance_sensor.attributes
|
||||
assert distance_sensor.state == "400"
|
||||
assert (
|
||||
distance_attributes[ATTR_FRIENDLY_NAME] == "FSC-BP108 EEFF Estimated Distance"
|
||||
distance_attributes[ATTR_FRIENDLY_NAME] == "FSC-BP108 EEFF Estimated distance"
|
||||
)
|
||||
assert distance_attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
|
||||
assert distance_attributes[ATTR_STATE_CLASS] == "measurement"
|
||||
|
@ -239,7 +239,7 @@ async def test_multiple_uuids_same_beacon(hass: HomeAssistant) -> None:
|
|||
distance_attributes = distance_sensor.attributes
|
||||
assert distance_sensor.state == "0"
|
||||
assert (
|
||||
distance_attributes[ATTR_FRIENDLY_NAME] == "FSC-BP108 EEFF Estimated Distance"
|
||||
distance_attributes[ATTR_FRIENDLY_NAME] == "FSC-BP108 EEFF Estimated distance"
|
||||
)
|
||||
assert distance_attributes[ATTR_UNIT_OF_MEASUREMENT] == "m"
|
||||
assert distance_attributes[ATTR_STATE_CLASS] == "measurement"
|
||||
|
|
Loading…
Reference in New Issue