Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H610A: Support for scenes over IoT API #7

Closed
rygwdn opened this issue Jan 4, 2024 · 12 comments
Closed

H610A: Support for scenes over IoT API #7

rygwdn opened this issue Jan 4, 2024 · 12 comments

Comments

@rygwdn
Copy link

rygwdn commented Jan 4, 2024

Would it be possible to support getting and activating scenes or "one click shortcuts" over the IoT API, and force the addon to use that API rather than the official one for certain devices? I have an H610A which doesn't report any functionality other than on/off from the official API despite being full RGBIC (reported to Govee here without much luck). The scenes can be activated with homebridge-govee with some manual setup, so I believe it's possible over the IoT API.

Thanks for the awesome work on this!

@wez
Copy link
Owner

wez commented Jan 4, 2024

I'll take a look. As it happens, I also have an H610A but I didn't notice this because I replaced it with a more beefy home made strip(!) and it's been sitting in the corner.

I do have some logic to read the "one click shortcuts", but it is a bit murky to try to reverse engineer most of those.

I also recently did some reverse engineering around scenes and getting things to work via the LAN API: egold555/Govee-Reverse-Engineering#11 I'm not sure that it works for 100% of all scenes, but it might be enough to satisfy you.

@rygwdn
Copy link
Author

rygwdn commented Jan 4, 2024

I can actually pull DIY scenes and the built-in dynamic scenes for the device via the official API (/router/api/v1/device/scenes and /router/api/v1/device/diy-scenes) it just doesn't report that the device is capable of receiving those commands, and refuses to accept them if I try.

wez added a commit that referenced this issue Jan 4, 2024
At the time of writing, the platform API doesn't return correct
information for this device, and refuses to control it appropriately.

This commit adds the concept of a quirks database that can be used
to override the metadata and try to arrive at a better outcome.

This is sufficient to regain color and brightness control over this
device.

For scenes, this commit attempts to use the fruits of some reverse
engineering to compute a scene code to send via an undocumented
part of the LAN API.  In practice, this is most reliable with
scene codes that fit in a single byte; the others likely need
to get routed via the IoT MQTT connection.

That can be examined in a follow up commit.

refs: #7
@wez
Copy link
Owner

wez commented Jan 4, 2024

I just pushed some basic improvements for this device; you can now control the color and brightness.
It does also have limited support for scenes; in practice, it is just scenes with scene codes in the range 1-255.
Scenes like Breathe and Rainbow work for me with this for example.

I'll need to do some more digging to see about enabling things like the one-click shortcuts.

wez added a commit that referenced this issue Jan 5, 2024
Add a bit of summarized output at the end.

refs: #7
wez added a commit that referenced this issue Jan 5, 2024
wez added a commit that referenced this issue Jan 5, 2024
@wez
Copy link
Owner

wez commented Jan 5, 2024

I just pushed a version that now adds a home assistant scene for each One Click you have defined in the app.
You can find them under "Settings > Automations and Scenes > Scenes".

@rygwdn
Copy link
Author

rygwdn commented Jan 6, 2024

Thank you! It works perfectly 🎉 I can finally get rid of my homebridge server I was running just for this functionality 😄 . Hopefully the official API and/or LAN API get support for this at some point, but this is an excellent workaround.

@rygwdn rygwdn closed this as completed Jan 6, 2024
@rygwdn
Copy link
Author

rygwdn commented Jan 6, 2024

would it be possible to have the one-click scenes show up as effects under the relevant devices as well? Don't worry about it if it's complicated!

@wez
Copy link
Owner

wez commented Jan 6, 2024

it's a bit awkward to add to the effects list for a couple of reasons:

  • one-click scenes are potentially multi-device, which feels like a bit of a mismatch in intent for per-device effects
  • figuring out that an effect is a one-click scene would have to resort to some icky string checks and the jumping across layers in the code to actually execute it

What may be a bit easier to fit in is adding a button for each scene the device belongs to, which would show up similarly to how the scenes show up in the Govee to MQTT virtual device, but for the light in question:

image

I wonder if I can make this automatically happen without adding additional entities; if there is some way to associate the scene entity with the device(s) that belong to it, then the default behavior of showing the scenes in the UI should kick in. Again, this is visible with the Govee to MQTT virtual device:

image

@rygwdn
Copy link
Author

rygwdn commented Jan 6, 2024

My goal was to be able to add the govee scene as part of a larger HA scene (e.g. have a HA scene that triggers a govee scene/one-click and also applies other settings for other devices). Some kind of button or switch might work for that..

@wez
Copy link
Owner

wez commented Jan 6, 2024

you could create a home assistant script that triggers both the home assistant scene that you create and the one click scene(s)

@rygwdn
Copy link
Author

rygwdn commented Jan 10, 2024

Looks like they fixed the platform API for my H610A, so the quirks may no longer be needed for it!

@wez
Copy link
Owner

wez commented Jan 10, 2024

Confirmed: I can set all the scenes for mine here with that quirk override removed

wez added a commit that referenced this issue Jan 10, 2024
So remove the quirk that avoids it

refs: #7 (comment)
@wez
Copy link
Owner

wez commented Jan 10, 2024

@rygwdn latest version removes the quirk, enjoy!

@wez wez changed the title Support for scenes over IoT API H610A: Support for scenes over IoT API Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants