From 42f61f1af9c932e4fb6f000105b2faffeb5fd150 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 25 Jun 2022 01:27:54 -0500 Subject: [PATCH] Speed up get accessories (#9) --- pyhap/characteristic.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyhap/characteristic.py b/pyhap/characteristic.py index 02f85675..85461b56 100644 --- a/pyhap/characteristic.py +++ b/pyhap/characteristic.py @@ -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") @@ -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: