Fixes suggested in PR #11
This commit is contained in:
@@ -43,8 +43,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_NAME = 'localtuyacover'
|
||||
|
||||
REQUIREMENTS = ['pytuya>=8.0.0']
|
||||
|
||||
CONF_DEVICE_ID = 'device_id'
|
||||
CONF_LOCAL_KEY = 'local_key'
|
||||
CONF_PROTOCOL_VERSION = 'protocol_version'
|
||||
@@ -84,7 +82,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
#_LOGGER.info("conf_STOP_cmd is %s", config.get(CONF_STOP_CMD))
|
||||
|
||||
covers = []
|
||||
pytuyadevice = pytuya.PytuyaDevice(config.get(CONF_DEVICE_ID), config.get(CONF_HOST), config.get(CONF_LOCAL_KEY))
|
||||
pytuyadevice = pytuya.TuyaDevice(config.get(CONF_DEVICE_ID), config.get(CONF_HOST), config.get(CONF_LOCAL_KEY))
|
||||
pytuyadevice.set_version(float(config.get(CONF_PROTOCOL_VERSION)))
|
||||
dps = {}
|
||||
dps[config.get(CONF_ID)]=None
|
||||
@@ -111,7 +109,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
|
||||
|
||||
class TuyaCache:
|
||||
"""Cache wrapper for pytuya.PytuyaDevice"""
|
||||
"""Cache wrapper for pytuya.TuyaDevice"""
|
||||
|
||||
def __init__(self, device):
|
||||
"""Initialize the cache."""
|
||||
@@ -139,15 +137,15 @@ class TuyaCache:
|
||||
# return None
|
||||
raise ConnectionError("Failed to update status .")
|
||||
|
||||
def set_dps(self, state, switchid):
|
||||
def set_dps(self, state, dps_index):
|
||||
#_LOGGER.info("running def set_dps from cover")
|
||||
"""Change the Tuya switch status and clear the cache."""
|
||||
self._cached_status = ''
|
||||
self._cached_status_time = 0
|
||||
for i in range(5):
|
||||
try:
|
||||
#_LOGGER.info("Running a try from def set_dps from cover where state=%s and switchid=%s", state, switchid)
|
||||
return self._device.set_dps(state, switchid)
|
||||
#_LOGGER.info("Running a try from def set_dps from cover where state=%s and dps_index=%s", state, dps_index)
|
||||
return self._device.set_dps(state, dps_index)
|
||||
except Exception:
|
||||
print('Failed to set status of device [{}]'.format(self._device.address))
|
||||
if i+1 == 3:
|
||||
@@ -185,7 +183,7 @@ class LocaltuyaCover(CoverEntity):
|
||||
self._open_cmd = open_cmd
|
||||
self._close_cmd = close_cmd
|
||||
self._stop_cmd = stop_cmd
|
||||
#_LOGGER.info("running def __init__ of TuyaDevice(PytuyaDevice) from cover.py with self=%s device=%s name=%s friendly_name=%s icon=%s switchid=%s open_cmd=%s close_cmd=%s stop_cmd=%s", self, device, name, friendly_name, icon, switchid, open_cmd, close_cmd, stop_cmd)
|
||||
#_LOGGER.info("running def __init__ of LocaltuyaCover(CoverEntity) with self=%s device=%s name=%s friendly_name=%s icon=%s switchid=%s open_cmd=%s close_cmd=%s stop_cmd=%s", self, device, name, friendly_name, icon, switchid, open_cmd, close_cmd, stop_cmd)
|
||||
print('Initialized tuya cover [{}] with switch status [{}] and state [{}]'.format(self._name, self._status, self._state))
|
||||
|
||||
@property
|
||||
|
Reference in New Issue
Block a user