mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Expose smart child device map as a class constant (#1173)
To facilitate distinguishing between smart and smart camera child devices.
This commit is contained in:
parent
dcc36e1dfe
commit
c6f2d89d44
@ -21,6 +21,17 @@ class SmartChildDevice(SmartDevice):
|
|||||||
This wraps the protocol communications and sets internal data for the child.
|
This wraps the protocol communications and sets internal data for the child.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
CHILD_DEVICE_TYPE_MAP = {
|
||||||
|
"plug.powerstrip.sub-plug": DeviceType.Plug,
|
||||||
|
"subg.trigger.contact-sensor": DeviceType.Sensor,
|
||||||
|
"subg.trigger.temp-hmdt-sensor": DeviceType.Sensor,
|
||||||
|
"subg.trigger.water-leak-sensor": DeviceType.Sensor,
|
||||||
|
"kasa.switch.outlet.sub-fan": DeviceType.Fan,
|
||||||
|
"kasa.switch.outlet.sub-dimmer": DeviceType.Dimmer,
|
||||||
|
"subg.trv": DeviceType.Thermostat,
|
||||||
|
"subg.trigger.button": DeviceType.Sensor,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
parent: SmartDevice,
|
parent: SmartDevice,
|
||||||
@ -76,16 +87,7 @@ class SmartChildDevice(SmartDevice):
|
|||||||
@property
|
@property
|
||||||
def device_type(self) -> DeviceType:
|
def device_type(self) -> DeviceType:
|
||||||
"""Return child device type."""
|
"""Return child device type."""
|
||||||
child_device_map = {
|
dev_type = self.CHILD_DEVICE_TYPE_MAP.get(self.sys_info["category"])
|
||||||
"plug.powerstrip.sub-plug": DeviceType.Plug,
|
|
||||||
"subg.trigger.contact-sensor": DeviceType.Sensor,
|
|
||||||
"subg.trigger.temp-hmdt-sensor": DeviceType.Sensor,
|
|
||||||
"subg.trigger.water-leak-sensor": DeviceType.Sensor,
|
|
||||||
"kasa.switch.outlet.sub-fan": DeviceType.Fan,
|
|
||||||
"kasa.switch.outlet.sub-dimmer": DeviceType.Dimmer,
|
|
||||||
"subg.trv": DeviceType.Thermostat,
|
|
||||||
}
|
|
||||||
dev_type = child_device_map.get(self.sys_info["category"])
|
|
||||||
if dev_type is None:
|
if dev_type is None:
|
||||||
_LOGGER.warning("Unknown child device type, please open issue ")
|
_LOGGER.warning("Unknown child device type, please open issue ")
|
||||||
dev_type = DeviceType.Unknown
|
dev_type = DeviceType.Unknown
|
||||||
|
Loading…
Reference in New Issue
Block a user