SecKatie / ha-wyzeapi

Home Assistant Integration for Wyze devices.
761 stars 116 forks source link

[Feature Request] Support Colour Bulb Groups #142

Closed seorasray closed 3 years ago

seorasray commented 3 years ago

Do you think it is technically possible to support Bulb Groups at all? I have 7 bulbs in one room and in the Wyze App I can trigger the Bulb Group to turn on and off and they react almost as well as my Hue bulbs. With Home Assistant calling each bulb individually it can take around 5 seconds or so before they all react which is less than ideal.

I do have a workaround for simple on/off functionality by using a Wyze App Rule to trigger the Bulb Group to Turn On/Off based on a Wyze Plug state and then switching that Plug state in Home Assistant. Scene or brightness changes go direct though and those can be quite slow.

Once again, thank you for all the hard work and the great software, this is a minor inconvenience, not a big deal at all.

LucasPMagno commented 3 years ago

Have you tried creating a group in home assistant or are you switching the 7 bulbs individually?

seorasray commented 3 years ago

I've got them in an HA Light Group right now and have tried using the group, individual bulb entities or area selections but they all change individually one by one. I'm pretty sure it is just due to the "api calls" being iterated in serial as opposed to being able to call a different Wyze Bulb Group endpoint. A workaround might be to use concurrent calls but not sure how HA events are structured or whether the Wyze endpoint is rate limited or similar. EDIT: I am very new to HA so maybe I am missing something super obvious in how to configure the lights?

I know there will only be so much that can be done without an actual API though. I am happy to help with debugging if I can. I presume you are using some type of dns host override, mitm tls proxy and wireshark. I have done it in the past but only for an app that I could make ignore the proxy generated cert. I have no idea how you would do that for a closed source app like Wyze :)

LucasPMagno commented 3 years ago

I have bulb groups of 3 bulbs (not the color bulb though) and they all turn off and on within a fraction of a second.

The way I've done to intercept api calls is to root android in BlueStacks so that I can use a cert from mitm proxy in place of the system proxy.

seorasray commented 3 years ago

I wish I had seen your comment before I decided to have a go and intercepting the API calls myself.. I ended up with the same solution, Bluestacks, supersu and mitmproxy.

Annoyingly enough when I looked at what was happening when I clicked on the Bulb Group I didn't see a special API, just a list of lights to enable. Shown in attached screenshot.

For a room that has 3 of the same Wyze colour bulbs they appear to turn on pretty quick, they are still done in serial, one after the other but they are done in a second. The room with 7 bulbs is a different story though. I'll keep poking around and see what I can find.

Screen Shot 2021-04-19 at 10 53 21 PM
LucasPMagno commented 3 years ago

I was on a previous version of this component, and I could spam-click the button for one of my lights and it would respond just the same as it would if I spam-clicked the button on the Wyze app. I just upgraded to the newest version and if I try to do that the light switches state on the first click and every 5-15 seconds. My group of 3 lights also doesn't turn on/off near instantaneously anymore, takes about a second or two. Edit: I was on version v0.5.15-vacuum-alpha.10

SecKatie commented 3 years ago

@LucasPMagno in the earlier version of the software I was using some complicated async code with retries and everything flowing through a request manager component. To speed up development I stripped this out.

I know that it is not quite as fast, but it works better for my development, so that is what I am utilizing now.

LucasPMagno commented 3 years ago

Ah, alright. That sounds like a nightmare to develop with. Btw, thanks for all your work on this.