Improve lists in integrations [G-H] (#113168)

This commit is contained in:
Joost Lekkerkerker 2024-03-13 17:25:27 +01:00 committed by GitHub
parent d4ae4a9cd0
commit 761933acfe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 392 additions and 433 deletions

View file

@ -160,7 +160,7 @@ def enumerate_stateless_switch_group(service: Service) -> list[dict[str, Any]]:
)
)
results = []
results: list[dict[str, Any]] = []
for idx, switch in enumerate(switches):
char = switch[CharacteristicsTypes.INPUT_EVENT]
@ -168,15 +168,15 @@ def enumerate_stateless_switch_group(service: Service) -> list[dict[str, Any]]:
# manufacturer might not - clamp options to what they say.
all_values = clamp_enum_to_char(InputEventValues, char)
for event_type in all_values:
results.append(
{
"characteristic": char.iid,
"value": event_type,
"type": f"button{idx + 1}",
"subtype": HK_TO_HA_INPUT_EVENT_VALUES[event_type],
}
)
results.extend(
{
"characteristic": char.iid,
"value": event_type,
"type": f"button{idx + 1}",
"subtype": HK_TO_HA_INPUT_EVENT_VALUES[event_type],
}
for event_type in all_values
)
return results
@ -188,17 +188,15 @@ def enumerate_doorbell(service: Service) -> list[dict[str, Any]]:
# manufacturer might not - clamp options to what they say.
all_values = clamp_enum_to_char(InputEventValues, input_event)
results = []
for event_type in all_values:
results.append(
{
"characteristic": input_event.iid,
"value": event_type,
"type": "doorbell",
"subtype": HK_TO_HA_INPUT_EVENT_VALUES[event_type],
}
)
return results
return [
{
"characteristic": input_event.iid,
"value": event_type,
"type": "doorbell",
"subtype": HK_TO_HA_INPUT_EVENT_VALUES[event_type],
}
for event_type in all_values
]
TRIGGER_FINDERS = {