Detect unsupported devices via discovery packet

pull/521/head
Colin Kuebler 2020-01-24 18:47:54 -05:00
parent 77f3d257f7
commit b34909021b
1 changed files with 7 additions and 2 deletions

View File

@ -33,13 +33,18 @@ class TuyaDiscovery(asyncio.DatagramProtocol):
try:
data = decrypt_udp(data)
except:
pass
data = data.decode()
print(addr[0], data)
# parse json
try:
data = json.loads(data)
# there is a typo present only in Tuya SDKs for non-ESP devices ("ablilty")
# it is spelled correctly in the Tuya SDK for the ESP ("ability")
# we can use this as a clue to report unsupported devices
if "ablilty" in data:
print("WARNING: it appears this device does not use an ESP82xx and therefore cannot install ESP based firmware")
except:
pass
print(addr[0], data)
def main():
loop = asyncio.get_event_loop()