Skip to content

Commit

Permalink
Fix a few bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
postlund committed Oct 22, 2020
1 parent 9d9f8a8 commit 6f8d856
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 3 additions & 4 deletions custom_components/localtuya/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ async def async_step_user(self, user_input=None):
return await self.async_step_basic_info()

# Use cache if available or fallback to manual discovery
if DOMAIN in self.hass.data:
data = self.hass.data.get(DOMAIN, {})
if DATA_DISCOVERY in data:
devices = self.hass.data[DOMAIN][DATA_DISCOVERY].devices
else:
devices = await discover()
Expand Down Expand Up @@ -359,9 +360,7 @@ async def async_step_debug(self, user_input=None):
type_convert = DEBUG_TYPES_CONVERSIONS[user_input[CONF_DATA_TYPE]]
value = type_convert(user_input[CONF_VALUE])
dp = user_input[CONF_DATAPOINT].split(" ")[0]
await _tuya_command(
self.hass, self.basic_info, "set_dps", value, dp
)
await _tuya_command(self.hass, self.basic_info, "set_dp", value, dp)
except Exception: # pylint: disable=broad-except
_LOGGER.exception(f"failed to set datapoint {dp}={value}")
errors["base"] = "set_dp_failed"
Expand Down
5 changes: 3 additions & 2 deletions custom_components/localtuya/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ async def start(self):
def close(self):
"""Stop discovery."""
self.callback = None
for transport, _ in self.listeners:
transport.close()
if self._listeners is not None:
for transport, _ in self._listeners:
transport.close()

def datagram_received(self, data, addr):
"""Handle received broadcast message."""
Expand Down

0 comments on commit 6f8d856

Please sign in to comment.