Closed polyedre closed 4 years ago
I'm having similar issues, can you provide some guidance on calling this directly as i'm running this via home-assistant
Minimal working example:
>>> import tuyaha
>>> client = tuyaha.TuyaApi()
>>> client.init("<username>", "<password>", "<countrycode>")
>>> client.discover_devices()
[]
>>> client.get_all_devices()
[]
I could get the json by printing response in this line https://github.com/PaulAnnekov/tuyaha/blob/88afb602d58077b327bd5d5f570df267948a9fd9/tuyaha/tuyaapi.py#L108
I did a work around by creating a custom component that work in LAN, do you want me to publish it ?
@polyedre Yes I would love to see the custom component, I had tried to use an old version that enabled local device control (not via the cloud) but ran into compatibility issues in HA 0.97.2
I just published it here: https://github.com/polyedre/tuya-lan
Thanks @polyedre I'll give this a go, I am also getting the same results as you when calling this directly. Thankfully I've already discovered my device id's and local keys.
Same issue here. I have three bulbs and none is detected by the lib. But I am able to see my Tuya scene in HA.
@polyedre I tried your custom component but it also didn't work for me, I need switches not sensors for my wifi fan/light switches as it appears your using smart plugs which include power monitoring. I was going to look at using your code to add this but I haven't had a chance to progress as having issues connect to these devices locally for some reason.
@RXM307 Let's continue this discussion directly on my repo because it is about lan and not the tuyaha library :)
Unfortunately, I have no access to tuya API servers. Did you try to set different <countrycode>
(1, 86 or your country code from https://www.countrycode.org/)? Also try to path 4th argument. One of: tuya
, smart_life
, jinvoo_smart
.
Hi Paul,
I was using the Smart Life APP but migrated to the Tuyasmart app as other reported this was working for them, so I've tried using smart_life but I'll try with tuya also
I've only tried setting to my country code 61 which is the same as the APP is using which is also using a1.tuyaeu.com, I've also tried setting the DEFAULTREGION to eu in tuyaapi.py but no change I'll try the countrycode changes and report back.
Looking how the APP authenticates it authenticates to a1.tuyaeu.com/log.json before posting to a1.tuyaeu.com/api.json
I'm suffering from the same issue here as well. The Tuya HTTP API reports back no devices.
>>> tuya.init('REDACTED', 'REDACTED', 61, 'tuya')
[]
smart_life
) initially and I had the same resultsTuyaAPIException
- as expectedTuyaSmart
iOS App reports and responds to my device fine though...The amazon link
What am I missing? :(
@PaulAnnekov No Change with the country code or with the tuya platform
import tuyaha client = tuyaha.TuyaApi() client.init("xxx.xxx@gmail.com", "SomePassword", "61", "tuya") [] client.discover_devices() [] client.get_all_devices() [] client.init("xxxx.xxxx@gmail.com", "SomePassword", "1", "tuya") [] client.discover_devices() [] client.get_all_devices() [] client.init("xxxx.xxx@gmail.com", "SomePassword", "86", "tuya") [] client.discover_devices() [] client.get_all_devices() []
~So I just checked again and my device appears to be available in the API now. Perhaps its a propagation time for something~
I was wrong. I'm seeing a Scene inside my account but not my device.
Hi Paul,
I was using the Smart Life APP but migrated to the Tuyasmart app as other reported this was working for them, so I've tried using smart_life but I'll try with tuya also
I've only tried setting to my country code 61 which is the same as the APP is using which is also using a1.tuyaeu.com, I've also tried setting the DEFAULTREGION to eu in tuyaapi.py but no change I'll try the countrycode changes and report back.
Looking how the APP authenticates it authenticates to a1.tuyaeu.com/log.json before posting to a1.tuyaeu.com/api.json
@PaulAnnekov perhaps might be better use the App like connections to the new API https://docs.tuya.com/en/cloudapi/app_access.html
@RXM307 it's not "new API". It's an API for OEM mobile apps. I already explained it to you here https://github.com/PaulAnnekov/tuyaha/issues/3#issuecomment-523656935. It's very hard to use for end-users.
I'm closing this issue, because I don't know how to help you here. If someone will find a reason, I will try to handle it.
Hi,
I tried to integrate a Tuya smart plug with home assistant, but the function discover_devices only return
{'payload': {'devices': [], 'scenes': []}, 'header': {'code': 'SUCCESS', 'payloadVersion': 1}}
I have successfully added the plug to my Tuya app, can control it (so the device is registered and associated with my account).
Do you have an Idea why nothing is returned ?
Thank