Rename set_dps to set_dp in pytuya

This commit is contained in:
Pierre Ståhl
2020-10-14 22:26:50 +02:00
committed by rospogrigio
parent 81c04bfc4e
commit 44db913514
8 changed files with 149 additions and 149 deletions

View File

@@ -21,9 +21,9 @@ Functions
json = status() # returns json payload
set_version(version) # 3.1 [default] or 3.3
detect_available_dps() # returns a list of available dps provided by the device
add_dps_to_request(dps_index) # adds dps_index to the list of dps used by the
add_dps_to_request(dp_index) # adds dp_index to the list of dps used by the
# device (to be queried in the payload)
set_dps(on, dps_index) # Set value of any dps index.
set_dp(on, dp_index) # Set value of any dps index.
Credits
@@ -428,15 +428,15 @@ class TuyaProtocol(asyncio.Protocol):
"""Send a heartbeat message."""
return await self.exchange(HEARTBEAT)
async def set_dps(self, value, dps_index):
async def set_dp(self, value, dp_index):
"""
Set value (may be any type: bool, int or string) of any dps index.
Args:
dps_index(int): dps index to set
dp_index(int): dps index to set
value: new value for the dps index
"""
return await self.exchange(SET, {str(dps_index): value})
return await self.exchange(SET, {str(dp_index): value})
async def detect_available_dps(self):
"""Return which datapoints are supported by the device."""
@@ -465,12 +465,12 @@ class TuyaProtocol(asyncio.Protocol):
self.log.debug("detected dps: %s", self.dps_cache)
return self.dps_cache
def add_dps_to_request(self, dps_index):
def add_dps_to_request(self, dp_indicies):
"""Add a datapoint (DP) to be included in requests."""
if isinstance(dps_index, int):
self.dps_to_request[str(dps_index)] = None
if isinstance(dp_indicies, int):
self.dps_to_request[str(dp_indicies)] = None
else:
self.dps_to_request.update({str(index): None for index in dps_index})
self.dps_to_request.update({str(index): None for index in dp_indicies})
def _decode_payload(self, payload):
self.log.debug("Decode payload: %s", payload)