mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Binary sensor description for BTHome (#78408)
This commit is contained in:
parent
13c7a7bbcc
commit
fad0b00fbc
@ -3,7 +3,10 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from bthome_ble import BTHOME_BINARY_SENSORS, SensorUpdate
|
from bthome_ble import (
|
||||||
|
BinarySensorDeviceClass as BTHomeBinarySensorDeviceClass,
|
||||||
|
SensorUpdate,
|
||||||
|
)
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
@ -23,18 +26,119 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .device import device_key_to_bluetooth_entity_key, sensor_device_info_to_hass
|
from .device import device_key_to_bluetooth_entity_key, sensor_device_info_to_hass
|
||||||
|
|
||||||
BINARY_SENSOR_DESCRIPTIONS = {}
|
BINARY_SENSOR_DESCRIPTIONS = {
|
||||||
for key in BTHOME_BINARY_SENSORS:
|
BTHomeBinarySensorDeviceClass.BATTERY: BinarySensorEntityDescription(
|
||||||
# Not all BTHome device classes are available in Home Assistant
|
key=BTHomeBinarySensorDeviceClass.BATTERY,
|
||||||
DEV_CLASS: str | None = key
|
device_class=BinarySensorDeviceClass.BATTERY,
|
||||||
try:
|
),
|
||||||
BinarySensorDeviceClass(key)
|
BTHomeBinarySensorDeviceClass.BATTERY_CHARGING: BinarySensorEntityDescription(
|
||||||
except ValueError:
|
key=BTHomeBinarySensorDeviceClass.BATTERY_CHARGING,
|
||||||
DEV_CLASS = None
|
device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
|
||||||
BINARY_SENSOR_DESCRIPTIONS[key] = BinarySensorEntityDescription(
|
),
|
||||||
key=key,
|
BTHomeBinarySensorDeviceClass.CO: BinarySensorEntityDescription(
|
||||||
device_class=DEV_CLASS,
|
key=BTHomeBinarySensorDeviceClass.CO,
|
||||||
)
|
device_class=BinarySensorDeviceClass.CO,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.COLD: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.COLD,
|
||||||
|
device_class=BinarySensorDeviceClass.COLD,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.CONNECTIVITY: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.CONNECTIVITY,
|
||||||
|
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.DOOR: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.DOOR,
|
||||||
|
device_class=BinarySensorDeviceClass.DOOR,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.HEAT: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.HEAT,
|
||||||
|
device_class=BinarySensorDeviceClass.HEAT,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.GARAGE_DOOR: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.GARAGE_DOOR,
|
||||||
|
device_class=BinarySensorDeviceClass.GARAGE_DOOR,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.GAS: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.GAS,
|
||||||
|
device_class=BinarySensorDeviceClass.GAS,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.GENERIC: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.GENERIC,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.LIGHT: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.LIGHT,
|
||||||
|
device_class=BinarySensorDeviceClass.LIGHT,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.LOCK: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.LOCK,
|
||||||
|
device_class=BinarySensorDeviceClass.LOCK,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.MOISTURE: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.MOISTURE,
|
||||||
|
device_class=BinarySensorDeviceClass.MOISTURE,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.MOTION: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.MOTION,
|
||||||
|
device_class=BinarySensorDeviceClass.MOTION,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.MOVING: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.MOVING,
|
||||||
|
device_class=BinarySensorDeviceClass.MOVING,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.OCCUPANCY: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.OCCUPANCY,
|
||||||
|
device_class=BinarySensorDeviceClass.OCCUPANCY,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.OPENING: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.OPENING,
|
||||||
|
device_class=BinarySensorDeviceClass.OPENING,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.PLUG: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.PLUG,
|
||||||
|
device_class=BinarySensorDeviceClass.PLUG,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.POWER: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.POWER,
|
||||||
|
device_class=BinarySensorDeviceClass.POWER,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.PRESENCE: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.PRESENCE,
|
||||||
|
device_class=BinarySensorDeviceClass.PRESENCE,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.PROBLEM: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.PROBLEM,
|
||||||
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.RUNNING: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.RUNNING,
|
||||||
|
device_class=BinarySensorDeviceClass.RUNNING,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.SAFETY: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.SAFETY,
|
||||||
|
device_class=BinarySensorDeviceClass.SAFETY,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.SMOKE: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.SMOKE,
|
||||||
|
device_class=BinarySensorDeviceClass.SMOKE,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.SOUND: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.SOUND,
|
||||||
|
device_class=BinarySensorDeviceClass.SOUND,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.TAMPER: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.TAMPER,
|
||||||
|
device_class=BinarySensorDeviceClass.TAMPER,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.VIBRATION: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.VIBRATION,
|
||||||
|
device_class=BinarySensorDeviceClass.VIBRATION,
|
||||||
|
),
|
||||||
|
BTHomeBinarySensorDeviceClass.WINDOW: BinarySensorEntityDescription(
|
||||||
|
key=BTHomeBinarySensorDeviceClass.WINDOW,
|
||||||
|
device_class=BinarySensorDeviceClass.WINDOW,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def sensor_update_to_bluetooth_data_update(
|
def sensor_update_to_bluetooth_data_update(
|
||||||
@ -48,9 +152,10 @@ def sensor_update_to_bluetooth_data_update(
|
|||||||
},
|
},
|
||||||
entity_descriptions={
|
entity_descriptions={
|
||||||
device_key_to_bluetooth_entity_key(device_key): BINARY_SENSOR_DESCRIPTIONS[
|
device_key_to_bluetooth_entity_key(device_key): BINARY_SENSOR_DESCRIPTIONS[
|
||||||
description.device_key.key
|
description.device_class
|
||||||
]
|
]
|
||||||
for device_key, description in sensor_update.binary_entity_descriptions.items()
|
for device_key, description in sensor_update.binary_entity_descriptions.items()
|
||||||
|
if description.device_class
|
||||||
},
|
},
|
||||||
entity_data={
|
entity_data={
|
||||||
device_key_to_bluetooth_entity_key(device_key): sensor_values.native_value
|
device_key_to_bluetooth_entity_key(device_key): sensor_values.native_value
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
"service_data_uuid": "0000181e-0000-1000-8000-00805f9b34fb"
|
"service_data_uuid": "0000181e-0000-1000-8000-00805f9b34fb"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"requirements": ["bthome-ble==1.2.0"],
|
"requirements": ["bthome-ble==1.2.2"],
|
||||||
"dependencies": ["bluetooth"],
|
"dependencies": ["bluetooth"],
|
||||||
"codeowners": ["@Ernst79"],
|
"codeowners": ["@Ernst79"],
|
||||||
"iot_class": "local_push"
|
"iot_class": "local_push"
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
from bthome_ble import DeviceClass, SensorUpdate, Units
|
from bthome_ble import SensorDeviceClass as BTHomeSensorDeviceClass, SensorUpdate, Units
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.bluetooth.passive_update_processor import (
|
from homeassistant.components.bluetooth.passive_update_processor import (
|
||||||
@ -40,93 +40,102 @@ from .const import DOMAIN
|
|||||||
from .device import device_key_to_bluetooth_entity_key, sensor_device_info_to_hass
|
from .device import device_key_to_bluetooth_entity_key, sensor_device_info_to_hass
|
||||||
|
|
||||||
SENSOR_DESCRIPTIONS = {
|
SENSOR_DESCRIPTIONS = {
|
||||||
(DeviceClass.TEMPERATURE, Units.TEMP_CELSIUS): SensorEntityDescription(
|
(BTHomeSensorDeviceClass.TEMPERATURE, Units.TEMP_CELSIUS): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}",
|
key=f"{BTHomeSensorDeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
(DeviceClass.HUMIDITY, Units.PERCENTAGE): SensorEntityDescription(
|
(BTHomeSensorDeviceClass.HUMIDITY, Units.PERCENTAGE): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.HUMIDITY}_{Units.PERCENTAGE}",
|
key=f"{BTHomeSensorDeviceClass.HUMIDITY}_{Units.PERCENTAGE}",
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
(DeviceClass.ILLUMINANCE, Units.LIGHT_LUX): SensorEntityDescription(
|
(BTHomeSensorDeviceClass.ILLUMINANCE, Units.LIGHT_LUX): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.ILLUMINANCE}_{Units.LIGHT_LUX}",
|
key=f"{BTHomeSensorDeviceClass.ILLUMINANCE}_{Units.LIGHT_LUX}",
|
||||||
device_class=SensorDeviceClass.ILLUMINANCE,
|
device_class=SensorDeviceClass.ILLUMINANCE,
|
||||||
native_unit_of_measurement=LIGHT_LUX,
|
native_unit_of_measurement=LIGHT_LUX,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
(DeviceClass.PRESSURE, Units.PRESSURE_MBAR): SensorEntityDescription(
|
(BTHomeSensorDeviceClass.PRESSURE, Units.PRESSURE_MBAR): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.PRESSURE}_{Units.PRESSURE_MBAR}",
|
key=f"{BTHomeSensorDeviceClass.PRESSURE}_{Units.PRESSURE_MBAR}",
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
native_unit_of_measurement=PRESSURE_MBAR,
|
native_unit_of_measurement=PRESSURE_MBAR,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
(DeviceClass.BATTERY, Units.PERCENTAGE): SensorEntityDescription(
|
(BTHomeSensorDeviceClass.BATTERY, Units.PERCENTAGE): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.BATTERY}_{Units.PERCENTAGE}",
|
key=f"{BTHomeSensorDeviceClass.BATTERY}_{Units.PERCENTAGE}",
|
||||||
device_class=SensorDeviceClass.BATTERY,
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
),
|
),
|
||||||
(DeviceClass.VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription(
|
(
|
||||||
key=str(Units.ELECTRIC_POTENTIAL_VOLT),
|
BTHomeSensorDeviceClass.VOLTAGE,
|
||||||
|
Units.ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
): SensorEntityDescription(
|
||||||
|
key=f"{BTHomeSensorDeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}",
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
(DeviceClass.ENERGY, Units.ENERGY_KILO_WATT_HOUR): SensorEntityDescription(
|
(
|
||||||
key=str(Units.ENERGY_KILO_WATT_HOUR),
|
BTHomeSensorDeviceClass.ENERGY,
|
||||||
|
Units.ENERGY_KILO_WATT_HOUR,
|
||||||
|
): SensorEntityDescription(
|
||||||
|
key=f"{BTHomeSensorDeviceClass.ENERGY}_{Units.ENERGY_KILO_WATT_HOUR}",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
(DeviceClass.POWER, Units.POWER_WATT): SensorEntityDescription(
|
(BTHomeSensorDeviceClass.POWER, Units.POWER_WATT): SensorEntityDescription(
|
||||||
key=str(Units.POWER_WATT),
|
key=f"{BTHomeSensorDeviceClass.POWER}_{Units.POWER_WATT}",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=POWER_WATT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
DeviceClass.PM10,
|
BTHomeSensorDeviceClass.PM10,
|
||||||
Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
): SensorEntityDescription(
|
): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.PM10}_{Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER}",
|
key=f"{BTHomeSensorDeviceClass.PM10}_{Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER}",
|
||||||
device_class=SensorDeviceClass.PM10,
|
device_class=SensorDeviceClass.PM10,
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
DeviceClass.PM25,
|
BTHomeSensorDeviceClass.PM25,
|
||||||
Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
): SensorEntityDescription(
|
): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.PM25}_{Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER}",
|
key=f"{BTHomeSensorDeviceClass.PM25}_{Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER}",
|
||||||
device_class=SensorDeviceClass.PM25,
|
device_class=SensorDeviceClass.PM25,
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
(DeviceClass.CO2, Units.CONCENTRATION_PARTS_PER_MILLION,): SensorEntityDescription(
|
(
|
||||||
key=f"{DeviceClass.CO2}_{Units.CONCENTRATION_PARTS_PER_MILLION}",
|
BTHomeSensorDeviceClass.CO2,
|
||||||
|
Units.CONCENTRATION_PARTS_PER_MILLION,
|
||||||
|
): SensorEntityDescription(
|
||||||
|
key=f"{BTHomeSensorDeviceClass.CO2}_{Units.CONCENTRATION_PARTS_PER_MILLION}",
|
||||||
device_class=SensorDeviceClass.CO2,
|
device_class=SensorDeviceClass.CO2,
|
||||||
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
|
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
DeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
|
BTHomeSensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
|
||||||
Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
): SensorEntityDescription(
|
): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.VOLATILE_ORGANIC_COMPOUNDS}_{Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER}",
|
key=f"{BTHomeSensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS}_{Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER}",
|
||||||
device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
|
device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
DeviceClass.SIGNAL_STRENGTH,
|
BTHomeSensorDeviceClass.SIGNAL_STRENGTH,
|
||||||
Units.SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
Units.SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
): SensorEntityDescription(
|
): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.SIGNAL_STRENGTH}_{Units.SIGNAL_STRENGTH_DECIBELS_MILLIWATT}",
|
key=f"{BTHomeSensorDeviceClass.SIGNAL_STRENGTH}_{Units.SIGNAL_STRENGTH_DECIBELS_MILLIWATT}",
|
||||||
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@ -134,36 +143,36 @@ SENSOR_DESCRIPTIONS = {
|
|||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
# Used for mass sensor with kg unit
|
# Used for mass sensor with kg unit
|
||||||
(None, Units.MASS_KILOGRAMS): SensorEntityDescription(
|
(BTHomeSensorDeviceClass.MASS, Units.MASS_KILOGRAMS): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.MASS}_{Units.MASS_KILOGRAMS}",
|
key=f"{BTHomeSensorDeviceClass.MASS}_{Units.MASS_KILOGRAMS}",
|
||||||
device_class=None,
|
device_class=None,
|
||||||
native_unit_of_measurement=MASS_KILOGRAMS,
|
native_unit_of_measurement=MASS_KILOGRAMS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
# Used for mass sensor with lb unit
|
# Used for mass sensor with lb unit
|
||||||
(None, Units.MASS_POUNDS): SensorEntityDescription(
|
(BTHomeSensorDeviceClass.MASS, Units.MASS_POUNDS): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.MASS}_{Units.MASS_POUNDS}",
|
key=f"{BTHomeSensorDeviceClass.MASS}_{Units.MASS_POUNDS}",
|
||||||
device_class=None,
|
device_class=None,
|
||||||
native_unit_of_measurement=MASS_POUNDS,
|
native_unit_of_measurement=MASS_POUNDS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
# Used for moisture sensor
|
# Used for moisture sensor
|
||||||
(DeviceClass.MOISTURE, Units.PERCENTAGE): SensorEntityDescription(
|
(BTHomeSensorDeviceClass.MOISTURE, Units.PERCENTAGE): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.MOISTURE}_{Units.PERCENTAGE}",
|
key=f"{BTHomeSensorDeviceClass.MOISTURE}_{Units.PERCENTAGE}",
|
||||||
device_class=SensorDeviceClass.MOISTURE,
|
device_class=SensorDeviceClass.MOISTURE,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
# Used for dew point sensor
|
# Used for dew point sensor
|
||||||
(None, Units.TEMP_CELSIUS): SensorEntityDescription(
|
(BTHomeSensorDeviceClass.DEW_POINT, Units.TEMP_CELSIUS): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.DEW_POINT}_{Units.TEMP_CELSIUS}",
|
key=f"{BTHomeSensorDeviceClass.DEW_POINT}_{Units.TEMP_CELSIUS}",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
# Used for count sensor
|
# Used for count sensor
|
||||||
(None, None): SensorEntityDescription(
|
(BTHomeSensorDeviceClass.COUNT, None): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.COUNT}",
|
key=f"{BTHomeSensorDeviceClass.COUNT}",
|
||||||
device_class=None,
|
device_class=None,
|
||||||
native_unit_of_measurement=None,
|
native_unit_of_measurement=None,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@ -185,6 +194,7 @@ def sensor_update_to_bluetooth_data_update(
|
|||||||
(description.device_class, description.native_unit_of_measurement)
|
(description.device_class, description.native_unit_of_measurement)
|
||||||
]
|
]
|
||||||
for device_key, description in sensor_update.entity_descriptions.items()
|
for device_key, description in sensor_update.entity_descriptions.items()
|
||||||
|
if description.device_class
|
||||||
},
|
},
|
||||||
entity_data={
|
entity_data={
|
||||||
device_key_to_bluetooth_entity_key(device_key): sensor_values.native_value
|
device_key_to_bluetooth_entity_key(device_key): sensor_values.native_value
|
||||||
|
@ -464,7 +464,7 @@ bsblan==0.5.0
|
|||||||
bt_proximity==0.2.1
|
bt_proximity==0.2.1
|
||||||
|
|
||||||
# homeassistant.components.bthome
|
# homeassistant.components.bthome
|
||||||
bthome-ble==1.2.0
|
bthome-ble==1.2.2
|
||||||
|
|
||||||
# homeassistant.components.bt_home_hub_5
|
# homeassistant.components.bt_home_hub_5
|
||||||
bthomehub5-devicelist==0.1.1
|
bthomehub5-devicelist==0.1.1
|
||||||
|
@ -365,7 +365,7 @@ brunt==1.2.0
|
|||||||
bsblan==0.5.0
|
bsblan==0.5.0
|
||||||
|
|
||||||
# homeassistant.components.bthome
|
# homeassistant.components.bthome
|
||||||
bthome-ble==1.2.0
|
bthome-ble==1.2.2
|
||||||
|
|
||||||
# homeassistant.components.buienradar
|
# homeassistant.components.buienradar
|
||||||
buienradar==1.0.5
|
buienradar==1.0.5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user