AMoo-Miki / homebridge-tuya-lan

Homebridge plugin for IoT devices that use Tuya Smart's platform
MIT License
196 stars 50 forks source link

not a valid key #285

Open wormpy001 opened 1 year ago

wormpy001 commented 1 year ago

When I try to add the pasword for a tuna device I get an error about that the key is not valid Previosly I get a key like "397a16f2689cf1f6" and now the key is like "ylAf_1TD'r44@&?>" but homebridge gives an error "[25/6/2023 09:43:58] [TuyaLan] ylAf_1TD'r44****, key for Lightstrip Radio (bf8ee5bf9391cbcab8og8s), is not a valid key." I tried to delete the device and install the device again but it always gives a pasword with strange combinations. Is there a work-around?

Akury83 commented 1 year ago

Are you using HOOBS? If so,

  1. Head to /var/lib/hoobs/tuyalanbridge/node_modules/homebridge-tuya-lan
  2. edit your index.js file at line 76 and comment out the statement if (!/^[0-9a-f]+$/i.test(device.key)) return this.log.error('%s, key for %s (%s), is not a valid key.', device.key.replace(/.{4}$/, '****'), device.name || 'unnamed device', device.id); by putting a // in front of the line.

Or you could use this solution if you're running homebridge: https://github.com/iRayanKhan/homebridge-tuya/issues/409

wormpy001 commented 1 year ago

Thanks It works again

beze commented 11 months ago

@Akury83 , the homebridge solution link is broken, can you tell me what is the solution for homebridge?

thordnel commented 11 months ago

@Akury83 , the homebridge solution link is broken, can you tell me what is the solution for homebridge?

I think you have to copy the link and paste it in the browser address. Because when i tried to click the link above it goes into a different page.

RoboChopp commented 10 months ago

Another Tuya Lan plugin has the same issue with the new key formats. Commenting out the line that checks for the invalid key character errors lets the plugin continue processing the command, but fails silently as it can't understand certain characters in the key e.g. '

Here was jconsolatti's finding, quoted:

"Little python debugging and it seems to confirm the parsing issue..

Orginal and broken:

d = tinytuya.OutletDevice('12345eb1f71e050cetfww', '100.88.55.77', '12345%$A'hACm:ts')

Working: local_key = "12345%$A'hACm:ts"

d = tinytuya.OutletDevice('12345eb1f71e050cetfww', '100.88.55.77', str(local_key))"

Basically creating a string that contains the key and then calling that. Could this be rolled out or tested on this plugin?

link to other thread:

https://github.com/iRayanKhan/homebridge-tuya/issues/409