Skip to content

Commit

Permalink
feat: set person name properly
Browse files Browse the repository at this point in the history
  • Loading branch information
fuatakgun committed Nov 23, 2024
1 parent 4e995af commit 4389a9f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions custom_components/eufy_security/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
from .eufy_security_api.util import get_child_value
from .util import get_product_properties_by_filter

PERSON_NAME = "personName"
EMPTY = ""
UNKNOWN = "Unknown"
PERSON_NAME_STATE_EMPTY = "No Person"
PERSON_NAME_STATE_UNKNOWN = "Unknown Person"
PERSON_NAME_VALUE_TO_STATE = {
EMPTY: PERSON_NAME_STATE_EMPTY,
UNKNOWN: PERSON_NAME_STATE_UNKNOWN,
}

_LOGGER: logging.Logger = logging.getLogger(__package__)


Expand Down Expand Up @@ -62,6 +72,10 @@ def native_value(self):
return get_child_value(self.product.__dict__, self.metadata.name)

value = get_child_value(self.product.properties, self.metadata.name)

if self.metadata.name == PERSON_NAME:
return PERSON_NAME_VALUE_TO_STATE.get(value, value)

if self.metadata.states is not None:
try:
return self.metadata.states[str(value)]
Expand Down

0 comments on commit 4389a9f

Please sign in to comment.