tinytuya icon indicating copy to clipboard operation
tinytuya copied to clipboard

Tinytuya server command /sync is deleting mappings in

Open JRB202 opened this issue 1 year ago • 1 comments

Hi Jason,

I also discovered an other problem with mapping readings :

The tinytuya server command /sync is purging mapping descriptions in devices.json ! Obviously, following command /status/<DeviceID> are missing these dps_mapping.

To reproduce the problem : On machine running tinytuya server 1° Stop server : docker stop tinytuya 2) python3 -m tinytuya wizard with correct Tuya Cloud credentials 3) nano devices.json (as just updated by wizard) and see "mapping" field containing all devices mappings 4) docker start tinytuya

  1. Open url like : http://192.168.xx.xx:8888/status/ and see the mapping codes and values correctly displayed as last field of screen
  2. Execute http://192.168.xx.xx:8888/sync Result is Ok But ...
  3. Reopen same url as step 5 and see that mappings are not displayed anymore
  4. nano devices.json and see that mappings have been deleted from device definition which is cause of http://192.168.xx.xx:8888/status/ failure to display mappings

To restore correct mapping displays by server /status , rerun steps from 1 to 4 and do NOT execute http://192.168.xx.xx:8888/sync again !

The problem is probably localized in def getdevices from cloud.py between lines 396 and 513

JRB202 avatar Dec 19 '23 17:12 JRB202

As temporary workaround, this bash script could be used to regenerate correct mappings in devices.json instead of using tinyserver command /sync

#!/bin/bash cd ~/tinytuya docker stop tinytuya printf 'Y\nY\n\N\n' | python3 -m tinytuya wizard docker start tinytuya sleep 3 # Wait 3 seconds to let server be started before following commands exit

JRB202 avatar Dec 19 '23 19:12 JRB202