mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Map switch device class outlet to Outlets in homekit (#101760)
This commit is contained in:
parent
f7f9331c57
commit
f166e1cc1a
@ -17,6 +17,7 @@ from homeassistant.components.cover import CoverDeviceClass, CoverEntityFeature
|
||||
from homeassistant.components.media_player import MediaPlayerDeviceClass
|
||||
from homeassistant.components.remote import RemoteEntityFeature
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.components.switch import SwitchDeviceClass
|
||||
from homeassistant.const import (
|
||||
ATTR_BATTERY_CHARGING,
|
||||
ATTR_BATTERY_LEVEL,
|
||||
@ -228,8 +229,12 @@ def get_accessory( # noqa: C901
|
||||
a_type = "LightSensor"
|
||||
|
||||
elif state.domain == "switch":
|
||||
switch_type = config.get(CONF_TYPE, TYPE_SWITCH)
|
||||
a_type = SWITCH_TYPES[switch_type]
|
||||
if switch_type := config.get(CONF_TYPE):
|
||||
a_type = SWITCH_TYPES[switch_type]
|
||||
elif state.attributes.get(ATTR_DEVICE_CLASS) == SwitchDeviceClass.OUTLET:
|
||||
a_type = "Outlet"
|
||||
else:
|
||||
a_type = "Switch"
|
||||
|
||||
elif state.domain == "vacuum":
|
||||
a_type = "Vacuum"
|
||||
|
@ -22,6 +22,7 @@ from homeassistant.components.media_player import (
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.components.switch import SwitchDeviceClass
|
||||
from homeassistant.components.vacuum import VacuumEntityFeature
|
||||
from homeassistant.const import (
|
||||
ATTR_CODE,
|
||||
@ -315,6 +316,13 @@ def test_type_sensors(type_name, entity_id, state, attrs) -> None:
|
||||
("type_name", "entity_id", "state", "attrs", "config"),
|
||||
[
|
||||
("Outlet", "switch.test", "on", {}, {CONF_TYPE: TYPE_OUTLET}),
|
||||
(
|
||||
"Outlet",
|
||||
"switch.test",
|
||||
"on",
|
||||
{ATTR_DEVICE_CLASS: SwitchDeviceClass.OUTLET},
|
||||
{},
|
||||
),
|
||||
("Switch", "automation.test", "on", {}, {}),
|
||||
("Switch", "button.test", STATE_UNKNOWN, {}, {}),
|
||||
("Switch", "input_boolean.test", "on", {}, {}),
|
||||
|
Loading…
x
Reference in New Issue
Block a user