Skip to content

Commit

Permalink
Speed up get accessories (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Jun 25, 2022
1 parent 6c2b95c commit 42f61f1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pyhap/characteristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
PROP_UNIT = "unit"
PROP_VALID_VALUES = "ValidValues"

PROP_NUMERIC = (PROP_MAX_VALUE, PROP_MIN_VALUE, PROP_MIN_STEP, PROP_UNIT)
PROP_NUMERIC = {PROP_MAX_VALUE, PROP_MIN_VALUE, PROP_MIN_STEP, PROP_UNIT}

CHAR_BUTTON_EVENT = UUID("00000126-0000-1000-8000-0026BB765291")
CHAR_PROGRAMMABLE_SWITCH_EVENT = UUID("00000073-0000-1000-8000-0026BB765291")
Expand Down Expand Up @@ -358,7 +358,10 @@ def to_HAP(self):
value = self.get_value()
if self.properties[PROP_FORMAT] in HAP_FORMAT_NUMERICS:
hap_rep.update(
{k: self.properties[k] for k in self.properties.keys() & PROP_NUMERIC}
{
k: self.properties[k]
for k in PROP_NUMERIC.intersection(self.properties)
}
)

if PROP_VALID_VALUES in self.properties:
Expand Down

0 comments on commit 42f61f1

Please sign in to comment.