FlagX / ha-ledvance-tuya-resync-localkey

pyscript for homeassistant to resync local keys from private tuya api
MIT License
121 stars 18 forks source link

Add ledvance device #27

Closed wiresio closed 6 months ago

wiresio commented 6 months ago

Following these instructions I was able to connect a device from the Tuya Smart app to FHEM.

Now I want to do the same for a device from the Ledvance LDV WiFi app but have no chance for connecting this app to the Tuya cloud. Your tool allows my to extract the local key and device id, but I still didn't succeed in onboarding it to FHEM. For this two methods are possible:

define tuya_system fhempy tuya setup API_KEY API_SECRET DEVICE_ID
set tuya_system start_scan

or

define wifi_plug fhempy tuya PRODUCT_ID DEVICE_ID IP [VERSION] [API_KEY] [API_SECRET]
attr wifi_plug localkey LOCALKEY_FROM_TUYA_SYSTEM_READINGS

Is there a way to get PRODUCT_ID and API_KEY / API_SECRET? I assume that it is also needed for HA.

FlagX commented 6 months ago

I don't know about the PRODUCT_ID but you can try key/secret from here: https://github.com/FlagX/ha-ledvance-tuya-resync-localkey/blob/main/pyscript_modules/tuya/const.py

It would make sense to me if the PRODUCT_ID is the "device id" that is printed out by the print-local-keys.py script. This is also required for the setup in home assistant.

wiresio commented 6 months ago

Tinytuya provides me with the PRODUCT_ID- however it is still not working. Shouldn't API_KEY/ API_SECRETbe related to my personal accout, i.e. are they somehow derived from username / password?

FlagX commented 6 months ago

Api key/secret are the tuya vendor specific private API credentials. Those in the const.py file are extracted from the Ledvance app and work for all Ledvance accounts.

wiresio commented 6 months ago

Trying

define ledvance_system fhempy tuya setup fx3fvkvusmw45d7jn8xh A_armptsqyfpxa4ftvtc739ardncett3uy_cgqx3ku34mh5qdesd7fcaru3gx7tyurr 5fe5abb36728cce7b9cd2185625edccbd6d9bd787e40

I get: {'Error': 'Unable to Get Cloud Token', 'Err': '911', 'Payload': "Cloud _gettoken() failed: 'data not exist'"}

wiresio commented 6 months ago

I'll close it here since it is not your issue. Thanks for your help!