mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Add power switch only if it is available at Home Connect (#135930)
This commit is contained in:
parent
f3222045ae
commit
33d552e3f7
@ -98,6 +98,12 @@ SWITCHES = (
|
||||
)
|
||||
|
||||
|
||||
POWER_SWITCH_DESCRIPTION = SwitchEntityDescription(
|
||||
key=BSH_POWER_STATE,
|
||||
translation_key="power",
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
entry: HomeConnectConfigEntry,
|
||||
@ -117,7 +123,8 @@ async def async_setup_entry(
|
||||
HomeConnectProgramSwitch(device, program)
|
||||
for program in programs
|
||||
)
|
||||
entities.append(HomeConnectPowerSwitch(device))
|
||||
if BSH_POWER_STATE in device.appliance.status:
|
||||
entities.append(HomeConnectPowerSwitch(device))
|
||||
entities.extend(
|
||||
HomeConnectSwitch(device, description)
|
||||
for description in SWITCHES
|
||||
@ -310,7 +317,7 @@ class HomeConnectPowerSwitch(HomeConnectEntity, SwitchEntity):
|
||||
"""Initialize the entity."""
|
||||
super().__init__(
|
||||
device,
|
||||
SwitchEntityDescription(key=BSH_POWER_STATE, translation_key="power"),
|
||||
POWER_SWITCH_DESCRIPTION,
|
||||
)
|
||||
if (
|
||||
power_state := device.appliance.status.get(BSH_POWER_STATE, {}).get(
|
||||
|
Loading…
x
Reference in New Issue
Block a user