strunker / GoveeSync

This code will allow you to use Govee internal UDP api to control your device as well as sync what is on the screen.
31 stars 3 forks source link

GoveeSync

This code will allow you to use Govee internal UDP api to control your device as well as sync what is on the screen. You need to install the below libs before running:
pip install wmi
pip install pywin32

Constants

Update the device IP of the device you want to control on line 21.

No Frills Screen Sync Script

If you don't want to get into the different functions and you just want something simple you can run and have work, just run GameSync2023.py file.

  1. Replace line 10 with your device IP, for example: DeviceIP = "192.168.0.1"
  2. Open cmd prompt then simply run with - python c:\PathToFile\GameSync2023.py
  3. You can simply do Ctrl + C to exit when you want to end the light sync.

Full Featured Code With Many Supported Commands - All of the below commands are implemented within GameSync.py

To turn the device on/off:
GoveeInternalControl("On")
GoveeInternalControl("Off")

To set the brightness:
GoveeInternalControl("BrightLevel",100) #1-100% expressed as an integer
GoveeInternalControl("BrightLevel",50) #1-100% expressed as an integer
GoveeInternalControl("BrightLevel",10) #1-100% expressed as an integer

To change the color:
GoveeInternalControl("Color",color=(0,255,0)) #Color expressed as a RGB tuple
GoveeInternalControl("Color",color=(255,0,0)) #Color expressed as a RGB tuple

To go into game mode where the screen will sync to the device:
Do note: in this mode the code will attempt to lock onto the window that is in focus.

There is a box size constant you can mess around with if you want to and see if you get better results.

This mode essentially works by creating a square in the center of the app's window. We sample a pixel at each of the four corners of the square, get the color values, then average those 4 color values together. That averaged out value is then sent to the Govee lights over UDP api.


GameTime()

Testing / Searching for devices - This is optional if you want to search for available Govee LAN api devices on your network.

Download UDPReceiver.py and UDPSender.py

  1. Start CMD prompt, navigate to the folder where you downloaded the above files. Then type: python UDPReceiver.py
    This should start a UDP multicast listener on port 4002
  2. Once the listener is started open another CMD prompt. Navigate to the folder, and type: python UDPSender.py
    This should output any Govee devices found to the shell.