PaulAnnekov / tuyaha

Implements the special Tuya Home Assistant API.
Other
141 stars 106 forks source link

Some devices not listed in API response? #6

Closed chadkouse closed 4 years ago

chadkouse commented 4 years ago

I tried my devices on the smart life app / platform -- and then when it didn't work I moved everything over to the tuya platform -- but essentially, devices I added a while back are working fine but I've added 2 new devices (a light and a switch) and they don't register.. I've tried pull_devices and force_reload but I can't even tell if they are doing anything (nothing in any log that I can see)

Is there a way to maybe completely reset any configuration that i may have cached / saved for the tuya component and pull everything down? Is there a way to tell if pull_devices or force_reload are doing anything?

chadkouse commented 4 years ago

Ok I bumped the HA log level to debug and now I can tell that pull_devices is running a discovery and only 3 devices are coming back (of the 5 in my account) -- I'm going to try to add these to another account and see what happens.

chadkouse commented 4 years ago

Another account shows the same behaviour -- I went so far as to put the url ( https://px1.tuyaus.com/homeassistant/skill ) into postman and grab the accessToken, etc and run the discovery command manually and it doesn't show them... Does this mean they aren't compatible with home assistant? :thinking:

PaulAnnekov commented 4 years ago

Does this mean they aren't compatible with home assistant?

Only Tuya HA API developers know what that means. Unfortunately they are silent: https://github.com/home-assistant/home-assistant/pull/24821#issuecomment-507063464.

TheBFGNL commented 4 years ago

I'm missing a led strip, also did the API calls via Postman and confirmed that it won't return the device altough it's available in Google Home and the Tuya app itself.

dannyshaw commented 4 years ago

I'm having issues too. Can I ask is everyone's problems with RGBW devices? I think perhaps there is a new device type and it is getting filtered out incorrectly.

https://github.com/home-assistant/home-assistant/issues/25163

dannyshaw commented 4 years ago

I have also emailed to ask for support. Let's see if there's any response.

edit: Contacted via developer support center and they're actually super responsive! Been asking for ids and seem to be on the case. Fingers crossed.

TheBFGNL commented 4 years ago

I will contact them as well, the more the better ;-). I also have API access now, but it seems that you need to create an own app.. It's doable I guess but one needs to rewrite this (Tuyaha) api as well.

It's realy the api on the tuya side (eg device discovery on https://px1.tuyaeu.com/homeassistant/skill)

{ "payload": { "devices": [ { "data": {}, "name": "Harmony on", "id": "ZSa6hD29cY1m0hBA", "dev_type": "scene", "ha_type": "scene" }, { "data": {}, "name": "Harmony off", "id": "KJtf0lTjdnZMn4no", "dev_type": "scene", "ha_type": "scene" } ], "scenes": [] }, "header": { "code": "SUCCESS", "payloadVersion": 1 } }

chadkouse commented 4 years ago

I'm having issues too. Can I ask is everyone's problems with RGBW devices? I think perhaps there is a new device type and it is getting filtered out incorrectly.

home-assistant/home-assistant#25163

One of mine is a RGBW led strip -- but the other is actually a garage door opener (registered in the app as just a "switch" but it does have a reed switch attached to it to tell me if the door is open or closed)

dannyshaw commented 4 years ago

I've received this unhelpful reply:

Hello, your product is a new version of the lighting, currently does not support HA, we are evaluating, follow-up support. Thank you for your support and cooperation.

Doesn't seem like a priority for them... I wonder how HA even got that api endpoint in the first place, perhaps a passionate employee.

TheBFGNL commented 4 years ago

I found a small work around.. You can make scenes that turns a device on and off. These scenes are found in HA and can be used to be intergrated in automations and scripts. The only thing one can´t control is the color of RGBW devices..

dannyshaw commented 4 years ago

Thanks @MatthijsDJ! Nice find.

I would highly encourage everyone who sees this issue to open up a tech help request ticket with Tuya and help raise the priority to getting these devices up and running.

This is what I sent (vary it a bit):

I have some Tuya based RGBW bulbs that are showing up in the TuyaSmart application but do not appear in the Home Assistant discovery API endpoint. The endpoint used to discover and interface with Home Assistant is provided by Tuya and found here: https://px1.tuyacn.com/homeassistant/skill with "discovery" payload.

I have accessed it using this library (also by Tuya): https://pypi.org/project/tuyapy/

Open A Tech Request ticket here https://iot.tuya.com/council/chat/

You will potentially need to create a new Tuya account for this as non china accounts don't seem to work.

StreetGuru commented 4 years ago

I've also been using scenes to control some tuya lightning - between HA and Smart_Life app I can have complete control over all devices in my house (except from a damn led strip).

I'm just on my second week using Home Assistant (still figuring it out) and I've only start buying lights and switches a couple months ago - and so ended up buying everything Tuya (except for one led strip controller that works with "Magic Home" app); I now have 10 switches, 4 covers, 8 plugs and 8 lights controlling all lights in my 2 bedroom apartment - all of them use Tuya/Smart Life platform - 1 Tuya bulb costs less than 10€ compared to 40€ for a Philips hue... and they work superbly once you find the right models (did take me a few returns on Amazon to find good devices).

I'm unwilling to flash over other firmware as Tuya works flawlessly for me.

I noticed that contrary to popular believe, you do not need any internet access to control tuya devices - I can control all devices locally through "smart life" app, even if not connected to the internet (as long as one is logged in the same lan as the devices - for me a separate vlan I've created without lan access). I assume one can analyse the packets being sent locally between the app and the devices and figure out the required controls? Unfortunately I am just speculating as this is beyond my technical abilities. I just see so many people flashing their tuya devices on the reason that one cannot control them without cloud access so I'm wondering if the ability to control all devices locally was introduced not long ago?

Of all devices I have only 4 bulbs (2 different brands) that do not show in HA but as they are all configured within lightning scenes, I can easily activate them through HA. It would be great to have full control through Tuya add-on though.

mzbac commented 4 years ago

After contacting with tuya tech support, they confirmed the new version of the light devices don't support HA. :(

dannyshaw commented 4 years ago

Hello, this will be scheduled as soon as possible, I will not close this ticket, the new version of the lighting support HA still takes a while.

Hang in there guys. There's hope.

lloydpick commented 4 years ago

Today I've started to see the newer lights connect, however seeing a lot of stack traces in the HA logs.


  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 275, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 316, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 477, in state_attributes
    data[ATTR_BRIGHTNESS] = self.brightness
  File "/usr/src/homeassistant/homeassistant/components/tuya/light.py", line 43, in brightness
    if self.tuya.brightness() is None:
  File "/usr/local/lib/python3.7/site-packages/tuyaha/devices/light.py", line 16, in brightness
    brightness = int(self.data.get('color').get('brightness') * 255 / 100)
AttributeError: 'NoneType' object has no attribute 'get'```
StreetGuru commented 4 years ago

Today I've started to see the newer lights connect, however seeing a lot of stack traces in the HA logs.

https://github.com/home-assistant/home-assistant/issues/25163

PaulAnnekov commented 4 years ago

This issue https://github.com/PaulAnnekov/tuyaha/issues/6#issuecomment-551343962 should gone after the merge of https://github.com/PaulAnnekov/tuyaha/pull/13. Also made a PR to HA https://github.com/home-assistant/home-assistant/pull/30213.

mk-maddin commented 4 years ago

I have a topic like this with my smoke sensor. I can see it within the app, but not using HA or directly using tuyaha python module and TuyaaApi._request('Discovery', 'discovery') methode. I additionally can see that within tuyapy-0.1.3 pythoon module it seems it is not listed there, too. (While on all of these a test scene of mine is visible)

Is there support for any sensors at all?

josemalena commented 4 years ago

I have an IR blaster that doesn't loads, and several ceiling fan controllers, none of the shows up on HA.

denwilliams commented 4 years ago

Also having this issue with a ceiling fan+light.

Confirmed that it isn't including in results using debug_discovery.py so this is all on Tuya.

Seems to be a trend for ceiling fans not supported with Tuya's API. Hopefully they fix it soon!

PaulAnnekov commented 4 years ago

I am closing this issue, because it's too broad and we can't handle it w/o actions from tuya side. If your device is not listed, check this instruction and act as it says https://github.com/PaulAnnekov/tuyaha#how-to-check-whether-the-api-this-library-using-can-control-your-device.