tinytuya
tinytuya copied to clipboard
Tinytuya server command /sync is deleting mappings in
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
- Open url like : http://192.168.xx.xx:8888/status/
and see the mapping codes and values correctly displayed as last field of screen - Execute http://192.168.xx.xx:8888/sync Result is Ok But ...
- Reopen same url as step 5 and see that mappings are not displayed anymore
- 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
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