mirror of
https://github.com/Andre0512/hon.git
synced 2025-05-13 22:54:23 -04:00
Small fixes, fix KeyError for switches #38
This commit is contained in:
parent
44794c35ca
commit
240dc85ff3
6 changed files with 33 additions and 27 deletions
|
@ -82,28 +82,28 @@ SWITCHES: dict[str, tuple[HonSwitchEntityDescription, ...]] = {
|
|||
translation_key="acqua_plus",
|
||||
),
|
||||
HonSwitchEntityDescription(
|
||||
key="extraRinse1",
|
||||
key="startProgram.extraRinse1",
|
||||
name="Extra Rinse 1",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
icon="mdi:numeric-1-box-multiple-outline",
|
||||
translation_key="extra_rinse_1",
|
||||
),
|
||||
HonSwitchEntityDescription(
|
||||
key="extraRinse2",
|
||||
key="startProgram.extraRinse2",
|
||||
name="Extra Rinse 2",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
icon="mdi:numeric-2-box-multiple-outline",
|
||||
translation_key="extra_rinse_2",
|
||||
),
|
||||
HonSwitchEntityDescription(
|
||||
key="extraRinse3",
|
||||
key="startProgram.extraRinse3",
|
||||
name="Extra Rinse 3",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
icon="mdi:numeric-3-box-multiple-outline",
|
||||
translation_key="extra_rinse_3",
|
||||
),
|
||||
HonSwitchEntityDescription(
|
||||
key="goodNight",
|
||||
key="startProgram.goodNight",
|
||||
name="Good Night",
|
||||
icon="mdi:weather-night",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
|
@ -324,14 +324,18 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
|
|||
if descriptions := SWITCHES.get(device.appliance_type):
|
||||
for description in descriptions:
|
||||
if (
|
||||
device.get(description.key) is not None
|
||||
or description.key in device.available_settings
|
||||
or description.turn_on_key in list(device.commands)
|
||||
or description.turn_off_key in list(device.commands)
|
||||
):
|
||||
appliances.extend(
|
||||
[HonSwitchEntity(hass, coordinator, entry, device, description)]
|
||||
description.entity_category == EntityCategory.CONFIG
|
||||
and description.key not in device.available_settings
|
||||
or not any(
|
||||
device.get(description.key) is not None
|
||||
or description.turn_on_key in list(device.commands)
|
||||
or description.turn_off_key in list(device.commands)
|
||||
)
|
||||
):
|
||||
continue
|
||||
appliances.extend(
|
||||
[HonSwitchEntity(hass, coordinator, entry, device, description)]
|
||||
)
|
||||
|
||||
async_add_entities(appliances)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue