mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Simplify motion blinds push callback (#44579)
This commit is contained in:
parent
e5f31665b1
commit
598202da07
@ -16,7 +16,6 @@ from homeassistant.components.cover import (
|
||||
CoverEntity,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ENTITY_MATCH_ALL, ENTITY_MATCH_NONE
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
@ -170,14 +169,9 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity):
|
||||
"""Return if the cover is closed or not."""
|
||||
return self._blind.position == 100
|
||||
|
||||
@callback
|
||||
def _push_callback(self):
|
||||
"""Update entity state when a push has been received."""
|
||||
self.schedule_update_ha_state(force_refresh=False)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Subscribe to multicast pushes and register signal handler."""
|
||||
self._blind.Register_callback(self.unique_id, self._push_callback)
|
||||
self._blind.Register_callback(self.unique_id, self.schedule_update_ha_state)
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(self.hass, DOMAIN, self.signal_handler)
|
||||
)
|
||||
|
@ -9,7 +9,6 @@ from homeassistant.const import (
|
||||
PERCENTAGE,
|
||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
@ -97,14 +96,9 @@ class MotionBatterySensor(CoordinatorEntity, Entity):
|
||||
"""Return device specific state attributes."""
|
||||
return {ATTR_BATTERY_VOLTAGE: self._blind.battery_voltage}
|
||||
|
||||
@callback
|
||||
def push_callback(self):
|
||||
"""Update entity state when a push has been received."""
|
||||
self.schedule_update_ha_state(force_refresh=False)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Subscribe to multicast pushes."""
|
||||
self._blind.Register_callback(self.unique_id, self.push_callback)
|
||||
self._blind.Register_callback(self.unique_id, self.schedule_update_ha_state)
|
||||
await super().async_added_to_hass()
|
||||
|
||||
async def async_will_remove_from_hass(self):
|
||||
@ -206,14 +200,9 @@ class MotionSignalStrengthSensor(CoordinatorEntity, Entity):
|
||||
"""Return the state of the sensor."""
|
||||
return self._device.RSSI
|
||||
|
||||
@callback
|
||||
def push_callback(self):
|
||||
"""Update entity state when a push has been received."""
|
||||
self.schedule_update_ha_state(force_refresh=False)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Subscribe to multicast pushes."""
|
||||
self._device.Register_callback(self.unique_id, self.push_callback)
|
||||
self._device.Register_callback(self.unique_id, self.schedule_update_ha_state)
|
||||
await super().async_added_to_hass()
|
||||
|
||||
async def async_will_remove_from_hass(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user