Improve dimmer support (#62)

* discover dimmers properly

* fix circular import, hopefully

* add is_color to SmartDevice API

* allow changing the dimming without implicitly turning the device on

* Add tests for device type handling for discovery data, make sure new fixtures are added to categories inside conftest
This commit is contained in:
Teemu R
2020-05-20 21:17:33 +02:00
committed by GitHub
parent e37244de0f
commit 012436c494
7 changed files with 71 additions and 8 deletions

View File

@@ -8,6 +8,7 @@ from typing import Awaitable, Callable, Dict, Mapping, Type, Union, cast
from kasa.protocol import TPLinkSmartHomeProtocol
from kasa.smartbulb import SmartBulb
from kasa.smartdevice import SmartDevice, SmartDeviceException
from kasa.smartdimmer import SmartDimmer
from kasa.smartplug import SmartPlug
from kasa.smartstrip import SmartStrip
@@ -195,7 +196,12 @@ class Discover:
else:
raise SmartDeviceException("No 'system' nor 'get_sysinfo' in response")
if "smartplug" in type_.lower() and "children" in sysinfo:
if (
"smartlife.iot.dimmer" in info
and "get_dimmer_parameters" in info["smartlife.iot.dimmer"]
):
return SmartDimmer
elif "smartplug" in type_.lower() and "children" in sysinfo:
return SmartStrip
elif "smartplug" in type_.lower():
return SmartPlug