Skip to content

Commit

Permalink
feat: add audio queue size sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
fuatakgun committed Nov 24, 2023
1 parent eada05e commit db39390
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions custom_components/eufy_security/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class PropertyToEntityDescription(Enum):
stream_url = EntityDescription(id=auto(), category=EntityCategory.DIAGNOSTIC)
stream_status = EntityDescription(id=auto(), category=EntityCategory.DIAGNOSTIC)
video_queue_size = EntityDescription(id=auto(), category=EntityCategory.DIAGNOSTIC)
audio_queue_size = EntityDescription(id=auto(), category=EntityCategory.DIAGNOSTIC)


# device binary sensor
motionDetected = EntityDescription(id=auto(), device_class=BinarySensorDeviceClass.MOTION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def chunk_generator(self, queue):
while True:
try:
item = await asyncio.wait_for(queue.get(), timeout=2.5)
_LOGGER.debug(f"chunk_generator yield data - {len(item)}")
#_LOGGER.debug(f"chunk_generator yield data - {len(item)}")
yield bytearray(item)
except TimeoutError as te:
_LOGGER.debug(f"chunk_generator timeout Exception %s - traceback: %s", te, traceback.format_exc())
Expand Down
8 changes: 6 additions & 2 deletions custom_components/eufy_security/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class CameraSensor(Enum):
stream_url = "Stream URL"
stream_status = "Stream Status"
video_queue_size = "Video Queue Size"
audio_queue_size = "Audio Queue Size"



async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback) -> None:
Expand Down Expand Up @@ -51,9 +53,11 @@ def __init__(self, coordinator: EufySecurityDataUpdateCoordinator, metadata: Met
def native_value(self):
"""Return the value reported by the sensor."""
if self.metadata.name in CameraSensor.__members__:
if self.metadata.name == "video_queue_size":
if self.metadata.name == CameraSensor.video_queue_size.name:
return self.product.video_queue.qsize()
if self.metadata.name == "stream_provider":
if self.metadata.name == CameraSensor.audio_queue_size.name:
return self.product.audio_queue.qsize()
if self.metadata.name == CameraSensor.stream_provider.name:
return self.product.stream_provider.name
return get_child_value(self.product.__dict__, self.metadata.name)

Expand Down

0 comments on commit db39390

Please sign in to comment.