Remove Reolink event connection sensor (#96903)
This commit is contained in:
parent
0502879d10
commit
e449f8e0e5
3 changed files with 2 additions and 49 deletions
|
@ -432,15 +432,6 @@ class ReolinkHost:
|
|||
webhook.async_unregister(self._hass, self.webhook_id)
|
||||
self.webhook_id = None
|
||||
|
||||
@property
|
||||
def event_connection(self) -> str:
|
||||
"""Return the event connection type."""
|
||||
if self._webhook_reachable:
|
||||
return "onvif_push"
|
||||
if self._long_poll_received:
|
||||
return "onvif_long_poll"
|
||||
return "fast_poll"
|
||||
|
||||
async def _async_long_polling(self, *_) -> None:
|
||||
"""Use ONVIF long polling to immediately receive events."""
|
||||
# This task will be cancelled once _async_stop_long_polling is called
|
||||
|
|
|
@ -9,7 +9,6 @@ from decimal import Decimal
|
|||
from reolink_aio.api import Host
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
|
@ -63,13 +62,11 @@ async def async_setup_entry(
|
|||
"""Set up a Reolink IP Camera."""
|
||||
reolink_data: ReolinkData = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
entities: list[ReolinkHostSensorEntity | EventConnectionSensorEntity] = [
|
||||
async_add_entities(
|
||||
ReolinkHostSensorEntity(reolink_data, entity_description)
|
||||
for entity_description in HOST_SENSORS
|
||||
if entity_description.supported(reolink_data.host.api)
|
||||
]
|
||||
entities.append(EventConnectionSensorEntity(reolink_data))
|
||||
async_add_entities(entities)
|
||||
)
|
||||
|
||||
|
||||
class ReolinkHostSensorEntity(ReolinkHostCoordinatorEntity, SensorEntity):
|
||||
|
@ -92,30 +89,3 @@ class ReolinkHostSensorEntity(ReolinkHostCoordinatorEntity, SensorEntity):
|
|||
def native_value(self) -> StateType | date | datetime | Decimal:
|
||||
"""Return the value reported by the sensor."""
|
||||
return self.entity_description.value(self._host.api)
|
||||
|
||||
|
||||
class EventConnectionSensorEntity(ReolinkHostCoordinatorEntity, SensorEntity):
|
||||
"""Reolink Event connection sensor."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
reolink_data: ReolinkData,
|
||||
) -> None:
|
||||
"""Initialize Reolink binary sensor."""
|
||||
super().__init__(reolink_data)
|
||||
self.entity_description = SensorEntityDescription(
|
||||
key="event_connection",
|
||||
translation_key="event_connection",
|
||||
icon="mdi:swap-horizontal",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
options=["onvif_push", "onvif_long_poll", "fast_poll"],
|
||||
)
|
||||
|
||||
self._attr_unique_id = f"{self._host.unique_id}_{self.entity_description.key}"
|
||||
|
||||
@property
|
||||
def native_value(self) -> str:
|
||||
"""Return the value reported by the sensor."""
|
||||
return self._host.event_connection
|
||||
|
|
|
@ -95,14 +95,6 @@
|
|||
}
|
||||
},
|
||||
"sensor": {
|
||||
"event_connection": {
|
||||
"name": "Event connection",
|
||||
"state": {
|
||||
"onvif_push": "ONVIF push",
|
||||
"onvif_long_poll": "ONVIF long poll",
|
||||
"fast_poll": "Fast poll"
|
||||
}
|
||||
},
|
||||
"wifi_signal": {
|
||||
"name": "Wi-Fi signal"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue