|
@@ -6,6 +6,8 @@ import json
|
|
|
import logging
|
|
import logging
|
|
|
from threading import Lock, Timer
|
|
from threading import Lock, Timer
|
|
|
from time import time
|
|
from time import time
|
|
|
|
|
+from tinytuya import CONTROL, Device as TuyaDevice
|
|
|
|
|
+
|
|
|
|
|
|
|
|
from homeassistant.const import TEMP_CELSIUS
|
|
from homeassistant.const import TEMP_CELSIUS
|
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.core import HomeAssistant
|
|
@@ -39,12 +41,10 @@ class TuyaLocalDevice(object):
|
|
|
address (str): The network address.
|
|
address (str): The network address.
|
|
|
local_key (str): The encryption key.
|
|
local_key (str): The encryption key.
|
|
|
"""
|
|
"""
|
|
|
- import tinytuya
|
|
|
|
|
-
|
|
|
|
|
self._name = name
|
|
self._name = name
|
|
|
self._api_protocol_version_index = None
|
|
self._api_protocol_version_index = None
|
|
|
self._api_protocol_working = False
|
|
self._api_protocol_working = False
|
|
|
- self._api = tinytuya.Device(dev_id, address, local_key)
|
|
|
|
|
|
|
+ self._api = TuyaDevice(dev_id, address, local_key)
|
|
|
self._refresh_task = None
|
|
self._refresh_task = None
|
|
|
self._rotate_api_protocol_version()
|
|
self._rotate_api_protocol_version()
|
|
|
|
|
|
|
@@ -207,7 +207,7 @@ class TuyaLocalDevice(object):
|
|
|
|
|
|
|
|
def _send_pending_updates(self):
|
|
def _send_pending_updates(self):
|
|
|
pending_properties = self._get_pending_properties()
|
|
pending_properties = self._get_pending_properties()
|
|
|
- payload = self._api.generate_payload("set", pending_properties)
|
|
|
|
|
|
|
+ payload = self._api.generate_payload(CONTROL, pending_properties)
|
|
|
|
|
|
|
|
_LOGGER.debug(f"sending dps update: {json.dumps(pending_properties)}")
|
|
_LOGGER.debug(f"sending dps update: {json.dumps(pending_properties)}")
|
|
|
|
|
|