| 1 | # Govee Local API |
| 2 | |
| 3 | [](https://github.com/Galorhallen/govee-local-api/actions/workflows/deploy.yml) |
| 4 | |
| 5 | Please note that scene and segment support is still **very** experimental. |
| 6 | |
| 7 | See [SUPPORTED_DEVICES.md](SUPPORTED_DEVICES.md) for the full list of known device models and their capabilities. |
| 8 | |
| 9 | # Requirements |
| 10 | |
| 11 | - Python >= 3.9 |
| 12 | - Govee Local API enabled. Refer to https://app-h5.govee.com/user-manual/wlan-guide |
| 13 | |
| 14 | # Installation |
| 15 | |
| 16 | From your terminal, run |
| 17 | |
| 18 | pip install govee-local-api |
| 19 | |
| 20 | or |
| 21 | |
| 22 | python3 -m pip install govee-local-api |
| 23 | |
| 24 | # Usage |
| 25 | |
| 26 | ## Basic Usage |
| 27 | |
| 28 | ```python |
| 29 | import asyncio |
| 30 | from govee_local_api import GoveeController |
| 31 | |
| 32 | async def main(): |
| 33 | # Simple single-interface setup |
| 34 | controller = GoveeController() |
| 35 | |
| 36 | # Discover devices |
| 37 | devices = await controller.scan_devices() |
| 38 | |
| 39 | # Control a device |
| 40 | if devices: |
| 41 | device = devices[0] |
| 42 | await device.turn_on() |
| 43 | await device.set_brightness(80) |
| 44 | await device.set_color(255, 0, 0) # Red |
| 45 | |
| 46 | asyncio.run(main()) |
| 47 | ``` |
| 48 | |
| 49 | ## Multi-Interface Setup |
| 50 | |
| 51 | For complex network environments with multiple interfaces: |
| 52 | |
| 53 | ```python |
| 54 | # Multiple listening addresses (basic) |
| 55 | controller = GoveeController( |
| 56 | listening_addresses=["192.168.1.100", "10.0.0.100", "172.16.1.100"] |
| 57 | ) |
| 58 | ``` |
| 59 | |
| 60 | ## Network Mask Configuration |
| 61 | |
| 62 | For precise subnet-aware device routing (recommended for enterprise/VLAN environments), embed the network mask directly in the address using CIDR or netmask notation: |
| 63 | |
| 64 | ```python |
| 65 | # Precise subnet matching with embedded network masks |
| 66 | controller = GoveeController( |
| 67 | listening_addresses=[ |
| 68 | "192.168.1.100/24", # Main LAN (CIDR) |
| 69 | "192.168.10.100/255.255.255.0", # IoT VLAN (dotted netmask) |
| 70 | "10.0.0.100/8" # Management network |
| 71 | ] |
| 72 | ) |
| 73 | ``` |
| 74 | |
| 75 | ### Supported Network Mask Formats |
| 76 | |
| 77 | - **CIDR Notation**: `192.168.1.100/24`, `10.0.0.100/8`, etc. |
| 78 | - **Dotted Decimal**: `192.168.1.100/255.255.255.0`, etc. |
| 79 | - **No mask**: `192.168.1.100` (uses heuristic subnet matching) |
| 80 | - **Wildcard**: `0.0.0.0` (listens on all interfaces, no subnet matching) |
| 81 | |
| 82 | ## Advanced Features |
| 83 | |
| 84 | ### Device Discovery and Control |
| 85 | |
| 86 | ```python |
| 87 | async def discover_and_control(): |
| 88 | controller = GoveeController( |
| 89 | listening_addresses=["192.168.1.100/24", "192.168.10.100/24"] |
| 90 | ) |
| 91 | |
| 92 | # Scan for devices across all networks |
| 93 | devices = await controller.scan_devices() |
| 94 | |
| 95 | # Filter devices by network |
| 96 | main_lan_devices = [d for d in devices if d.ip.startswith("192.168.1.")] |
| 97 | iot_vlan_devices = [d for d in devices if d.ip.startswith("192.168.10.")] |
| 98 | |
| 99 | # Control devices on specific networks |
| 100 | for device in main_lan_devices: |
| 101 | await device.turn_on() |
| 102 | await device.set_brightness(50) |
| 103 | |
| 104 | for device in iot_vlan_devices: |
| 105 | await device.turn_off() |
| 106 | ``` |
| 107 | |
| 108 | ### Direct Device Control |
| 109 | |
| 110 | ```python |
| 111 | # Control device by IP address (uses intelligent transport selection) |
| 112 | await controller.control_device("192.168.1.100", turn_on=True) |
| 113 | await controller.control_device("192.168.1.100", brightness=75) |
| 114 | await controller.control_device("192.168.1.100", color_rgb=(0, 255, 0)) |
| 115 | ``` |
| 116 | |
| 117 | ## Documentation |
| 118 | |
| 119 | - **[Supported Devices](SUPPORTED_DEVICES.md)** - Auto-generated list of known device models and their capabilities |
| 120 | - **[Network Mask Configuration Guide](NETWORK_MASKS.md)** - Comprehensive guide for multi-network setups |
| 121 | - **[API Reference](https://github.com/Galorhallen/govee-local-api)** - Full API documentation |
| 122 | |
| 123 | ## Use Cases |
| 124 | |
| 125 | - **Home Networks**: Simple single-interface setup |
| 126 | - **Small Office**: Multi-interface with heuristic matching |
| 127 | - **Enterprise/VLAN**: Network mask configuration for precise routing |
| 128 | - **IoT Deployments**: Isolated network segments with dedicated interfaces |
| 129 | - **Multi-Building**: Physically separated networks with same IP ranges |