Rename var to compliant name in August integration (#56812)
This commit is contained in:
parent
c6f48056fd
commit
ee28dd57c1
2 changed files with 10 additions and 12 deletions
|
@ -93,7 +93,7 @@ def _native_datetime() -> datetime:
|
|||
class AugustRequiredKeysMixin:
|
||||
"""Mixin for required keys."""
|
||||
|
||||
state_provider: Callable[[AugustData, DoorbellDetail], bool]
|
||||
value_fn: Callable[[AugustData, DoorbellDetail], bool]
|
||||
is_time_based: bool
|
||||
|
||||
|
||||
|
@ -115,21 +115,21 @@ SENSOR_TYPES_DOORBELL: tuple[AugustBinarySensorEntityDescription, ...] = (
|
|||
key="doorbell_ding",
|
||||
name="Ding",
|
||||
device_class=DEVICE_CLASS_OCCUPANCY,
|
||||
state_provider=_retrieve_ding_state,
|
||||
value_fn=_retrieve_ding_state,
|
||||
is_time_based=True,
|
||||
),
|
||||
AugustBinarySensorEntityDescription(
|
||||
key="doorbell_motion",
|
||||
name="Motion",
|
||||
device_class=DEVICE_CLASS_MOTION,
|
||||
state_provider=_retrieve_motion_state,
|
||||
value_fn=_retrieve_motion_state,
|
||||
is_time_based=True,
|
||||
),
|
||||
AugustBinarySensorEntityDescription(
|
||||
key="doorbell_online",
|
||||
name="Online",
|
||||
device_class=DEVICE_CLASS_CONNECTIVITY,
|
||||
state_provider=_retrieve_online_state,
|
||||
value_fn=_retrieve_online_state,
|
||||
is_time_based=False,
|
||||
),
|
||||
)
|
||||
|
@ -225,9 +225,7 @@ class AugustDoorbellBinarySensor(AugustEntityMixin, BinarySensorEntity):
|
|||
def _update_from_data(self):
|
||||
"""Get the latest state of the sensor."""
|
||||
self._cancel_any_pending_updates()
|
||||
self._attr_is_on = self.entity_description.state_provider(
|
||||
self._data, self._detail
|
||||
)
|
||||
self._attr_is_on = self.entity_description.value_fn(self._data, self._detail)
|
||||
|
||||
if self.entity_description.is_time_based:
|
||||
self._attr_available = _retrieve_online_state(self._data, self._detail)
|
||||
|
|
|
@ -55,7 +55,7 @@ T = TypeVar("T", LockDetail, KeypadDetail)
|
|||
class AugustRequiredKeysMixin(Generic[T]):
|
||||
"""Mixin for required keys."""
|
||||
|
||||
state_provider: Callable[[T], int | None]
|
||||
value_fn: Callable[[T], int | None]
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -68,13 +68,13 @@ class AugustSensorEntityDescription(
|
|||
SENSOR_TYPE_DEVICE_BATTERY = AugustSensorEntityDescription[LockDetail](
|
||||
key="device_battery",
|
||||
name="Battery",
|
||||
state_provider=_retrieve_device_battery_state,
|
||||
value_fn=_retrieve_device_battery_state,
|
||||
)
|
||||
|
||||
SENSOR_TYPE_KEYPAD_BATTERY = AugustSensorEntityDescription[KeypadDetail](
|
||||
key="linked_keypad_battery",
|
||||
name="Battery",
|
||||
state_provider=_retrieve_linked_keypad_battery_state,
|
||||
value_fn=_retrieve_linked_keypad_battery_state,
|
||||
)
|
||||
|
||||
|
||||
|
@ -97,7 +97,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
|
||||
for device in batteries["device_battery"]:
|
||||
detail = data.get_device_detail(device.device_id)
|
||||
if detail is None or SENSOR_TYPE_DEVICE_BATTERY.state_provider(detail) is None:
|
||||
if detail is None or SENSOR_TYPE_DEVICE_BATTERY.value_fn(detail) is None:
|
||||
_LOGGER.debug(
|
||||
"Not adding battery sensor for %s because it is not present",
|
||||
device.device_name,
|
||||
|
@ -268,7 +268,7 @@ class AugustBatterySensor(AugustEntityMixin, SensorEntity, Generic[T]):
|
|||
@callback
|
||||
def _update_from_data(self):
|
||||
"""Get the latest state of the sensor."""
|
||||
self._attr_native_value = self.entity_description.state_provider(self._detail)
|
||||
self._attr_native_value = self.entity_description.value_fn(self._detail)
|
||||
self._attr_available = self._attr_native_value is not None
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue