Skip to content

Commit

Permalink
Merge pull request #171 from maxyvon/default_get_value
Browse files Browse the repository at this point in the history
Changement de la valeur par défault du get_value de None à 'unknown'
  • Loading branch information
ic-dev21 authored Feb 5, 2024
2 parents fb88d67 + 42e5958 commit b62d241
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyhilo/device/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from datetime import datetime
from typing import TYPE_CHECKING, Any, Dict, Union, cast

from homeassistant.const import STATE_UNKNOWN

from pyhilo.const import (
HILO_DEVICE_ATTRIBUTES,
HILO_LIST_ATTRIBUTES,
Expand Down Expand Up @@ -150,7 +152,7 @@ def has_attribute(self, attr: str) -> bool:
return next((True for k in self.supported_attributes if k.attr == attr), False)

def get_value(
self, attribute: str, default: Union[str, int, float, None] = None
self, attribute: str, default: Union[str, int, float, None] = STATE_UNKNOWN
) -> Any:
attr = self.get_attribute(attribute)
return attr.value if attr else default
Expand Down

0 comments on commit b62d241

Please sign in to comment.