Add RSSI sensors to Yale Access Bluetooth (#76590)
This commit is contained in:
parent
9919dd500d
commit
b5787fe8fa
3 changed files with 46 additions and 1 deletions
|
@ -1487,6 +1487,7 @@ omit =
|
|||
homeassistant/components/yalexs_ble/binary_sensor.py
|
||||
homeassistant/components/yalexs_ble/entity.py
|
||||
homeassistant/components/yalexs_ble/lock.py
|
||||
homeassistant/components/yalexs_ble/sensor.py
|
||||
homeassistant/components/yalexs_ble/util.py
|
||||
homeassistant/components/yale_smart_alarm/__init__.py
|
||||
homeassistant/components/yale_smart_alarm/alarm_control_panel.py
|
||||
|
|
|
@ -17,7 +17,7 @@ from .const import CONF_KEY, CONF_LOCAL_NAME, CONF_SLOT, DEVICE_TIMEOUT, DOMAIN
|
|||
from .models import YaleXSBLEData
|
||||
from .util import async_find_existing_service_info, bluetooth_callback_matcher
|
||||
|
||||
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.LOCK]
|
||||
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.LOCK, Platform.SENSOR]
|
||||
|
||||
|
||||
class YaleXSBLEDiscovery(TypedDict):
|
||||
|
|
44
homeassistant/components/yalexs_ble/sensor.py
Normal file
44
homeassistant/components/yalexs_ble/sensor.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
"""Support for yalexs ble sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from yalexs_ble import ConnectionInfo, LockInfo, LockState
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||
from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
from .entity import YALEXSBLEEntity
|
||||
from .models import YaleXSBLEData
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
entry: config_entries.ConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up YALE XS Bluetooth sensors."""
|
||||
data: YaleXSBLEData = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities([YaleXSBLERSSISensor(data)])
|
||||
|
||||
|
||||
class YaleXSBLERSSISensor(YALEXSBLEEntity, SensorEntity):
|
||||
"""Yale XS Bluetooth RSSI sensor."""
|
||||
|
||||
_attr_device_class = SensorDeviceClass.SIGNAL_STRENGTH
|
||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
_attr_entity_registry_enabled_default = False
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = "Signal strength"
|
||||
_attr_native_unit_of_measurement = SIGNAL_STRENGTH_DECIBELS_MILLIWATT
|
||||
|
||||
@callback
|
||||
def _async_update_state(
|
||||
self, new_state: LockState, lock_info: LockInfo, connection_info: ConnectionInfo
|
||||
) -> None:
|
||||
"""Update the state."""
|
||||
self._attr_native_value = connection_info.rssi
|
||||
super()._async_update_state(new_state, lock_info, connection_info)
|
Loading…
Add table
Reference in a new issue