From 87a0ac236397cc048e11e52a114f8a651f6feaae Mon Sep 17 00:00:00 2001 From: fancygaphtrn Date: Tue, 30 Jun 2020 07:23:14 -0400 Subject: [PATCH] Fan support --- custom_components/localtuya/pytuya/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/custom_components/localtuya/pytuya/__init__.py b/custom_components/localtuya/pytuya/__init__.py index 8e2a01c..46064e0 100644 --- a/custom_components/localtuya/pytuya/__init__.py +++ b/custom_components/localtuya/pytuya/__init__.py @@ -367,6 +367,7 @@ class Device(XenonDevice): on(bool): True for 'on', False for 'off'. switch(int): The switch to set """ + log.debug("set_status: %s", on) # open device, send request, then close connection if isinstance(switch, int): switch = str(switch) # index and payload is a string @@ -386,6 +387,7 @@ class Device(XenonDevice): index(int): index to set value(int): new value for the index """ + log.debug("set_value: index=%s value=%s", index, value) # open device, send request, then close connection if isinstance(index, int): index = str(index) # index and payload is a string @@ -435,7 +437,16 @@ class OutletDevice(Device): dev_type = 'device20' super(OutletDevice, self).__init__(dev_id, address, local_key, dev_type) +class FanDevice(Device): + DPS_INDEX_SPEED = '2' + def __init__(self, dev_id, address, local_key=None): + if len(dev_id) == 22: + dev_type = 'device22' + else: + dev_type = 'device20' + super(FanDevice, self).__init__(dev_id, address, local_key, dev_type) + class CoverEntity(Device): DPS_INDEX_MOVE = '1' DPS_INDEX_BL = '101'