mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +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(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry: HomeConnectConfigEntry,
|
entry: HomeConnectConfigEntry,
|
||||||
@ -117,7 +123,8 @@ async def async_setup_entry(
|
|||||||
HomeConnectProgramSwitch(device, program)
|
HomeConnectProgramSwitch(device, program)
|
||||||
for program in programs
|
for program in programs
|
||||||
)
|
)
|
||||||
entities.append(HomeConnectPowerSwitch(device))
|
if BSH_POWER_STATE in device.appliance.status:
|
||||||
|
entities.append(HomeConnectPowerSwitch(device))
|
||||||
entities.extend(
|
entities.extend(
|
||||||
HomeConnectSwitch(device, description)
|
HomeConnectSwitch(device, description)
|
||||||
for description in SWITCHES
|
for description in SWITCHES
|
||||||
@ -310,7 +317,7 @@ class HomeConnectPowerSwitch(HomeConnectEntity, SwitchEntity):
|
|||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
device,
|
device,
|
||||||
SwitchEntityDescription(key=BSH_POWER_STATE, translation_key="power"),
|
POWER_SWITCH_DESCRIPTION,
|
||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
power_state := device.appliance.status.get(BSH_POWER_STATE, {}).get(
|
power_state := device.appliance.status.get(BSH_POWER_STATE, {}).get(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user