Open wez opened 8 months ago
Very Useful Thank You, for taking the time to document this and explain this.
FWIW, it doesn't seem to work reliably for scene codes larger than 0xff, so this isn't 100%, but it does give a way to map from the list of known codes to data you can send to the device.
I am not able to get any codes to work on my H61A8 -- even if less than 0xff (255).
For the H61A8, "Sunrise" is 128, which yields a command of MwUEgAAAAAAAAAAAAAAAAAAAALI= (feel free to check me on that).
But, every time I push that command (or any other valid command), the scene pattern restarts. It does not change the scene to the one I set, it simply restarts the current scene. Further, if the command is invalid, nothing happens. So, I am pretty sure I am pushing the right command, it just doesn't change it.
Is this the only way to control scenes via LAN (that is publicly known)? Most scene codes for the H61A8 are larger than 255.
This is awesome, thanks for this documentation!
Unsure if you think we should leave this as a open issue (Maybe we pin it) or is it worth adding a file / folder for documentation like this to the repo?
I am open to any and all ideas
Hi @wez!
Yesterday I've got some Govee Floor Lamps Basic on my birthday and wanted to integrate them into my Home Assistant. Unfortunately it didn't work as easy as I expected. These are my first Govee devices. I encountered your name and your posts at different places and obviousley you're the man that knows the most about the propriatary Govee solutions. I integrated the lamps into HA with different addons and I also tried your Govee2MQTT addon which runs quite well, but faces some problems when it comes to setting colors onto single segments. Mainly it works, but since it's using the cloud, the reaction time is very bad, when setting segments 0..7 one by one. I'm a programmer and I quickly setup my own UDP server to check the local LAN API. It was no problem to discover the lamps and setting color and brightness, but no word about setting single segments in the manual. I nearly gave up and then discovered this post and the "ptReal" command. But I didn't get how to discover the payload for this command.
You write Convert to hex to produce: 0x27cf which you can break into two bytes and swap around, adding on to a scene mode packet, similar to the others discussed in this repo
I understand how to find the appropriate scene code, but wrapping the hex code of this scene code around WHAT? How do I build the correct scene mode packet and calculate the checksum? Can you give me some hints?
My intention actually is to use my Govee Floor Lamps not with the predefined scenes, but just some static gradients. I don't like the animations. Maybe for a party, but in my everyday life I just want the lamps to shine in different static gradients. Do you think this will be possible localy without using the Govee app? Will these be anyhow possible with the LAN API?
Besides, thank you very much for all your efforts that you are putting in for the community!
Best regards Andy
I've been poking at things and found something that I think you may find useful, and may be worth documenting here.
You can download a catalog of pre-defined scenes for a given sku; you need to pass the AppVersion header for it to return anything:
Which produces data like the following abbreviated excerpt:
The part of interest is the
sceneCode
in thelightEffects
list; for theRainbow
above, ignore its directsceneCode: 0
and look inside itslightEffects
list for itssceneCode: 10191
Using some
jq
, we can produce a simpler list:outputs something like this excerpt:
Armed with that you can now construct a BLE packet that will activate a scene if you know its name. Taking that
rainbow B
example, its scene code is10191
in decimal. Convert to hex to produce:0x27cf
which you can break into two bytes and swap around, adding on to a scene mode packet, similar to the others discussed in this repo:then zero-pad out to 19 bytes + checksum and voila, you have a packet that you can send either via BLE or via the LAN
ptReal
command that will activate that scene.I figured this out by following https://github.com/bwp91/homebridge-govee/wiki/Scene%2C-Music%2C-DIY-Modes which suggests saving a short-cut for a scene in the govee app, and then plucks the corresponding base64 encoded version of the packet out of some data returned from another govee URL.
Staring at some other data from the new HTTP platform API that returns scene codes (https://developer.govee.com/reference/get-light-scene), I realized that the code was embedded in that packet.
LAN Protocol and ptReal
The Govee LAN Protocol doesn't document this, but you can send BLE packets to the device via the LAN protocol by encoding them as base64 packets and sending data like this to UDP port 4003 on the target device: