Judge that devices are communicating if they have returned any DPS rather than checking specific ones.
@@ -107,4 +107,4 @@ async def async_test_connection(config: dict, hass: HomeAssistant):
"Test", config[CONF_DEVICE_ID], config[CONF_HOST], config[CONF_LOCAL_KEY], hass
)
await device.async_refresh()
- return device.get_property("1") is not None or device.get_property("3") is not None
+ return device.has_returned_state()
@@ -76,6 +76,11 @@ class TuyaLocalDevice(object):
"manufacturer": "Tuya",
}
+ @property
+ def has_sent_state(self):
+ """Return True if the device has returned some state."""
+ return len(self._get_cached_state()) > 1
+
@property
def temperature_unit(self):
return self._TEMPERATURE_UNIT