Skip to content

Conversation

@lasswellt
Copy link

Summary

Complete rewrite of the Govee integration to use the official Govee API v2.0 with capability-based architecture, modern Home Assistant patterns, and full feature support.

Breaking Changes

  • Removed dependency on govee-api-laggat library - now uses inline API client
  • Config entry version bumped to 2 (automatic migration included)

New Features

API v2.0 Migration

  • New inline API client with full v2.0 endpoint support
  • Capability-based device control (dynamic feature detection)
  • Improved rate limiting (100/min, 10,000/day) with sliding window tracking
  • Better error handling with typed exceptions

Light Platform Enhancements

  • Dynamic color mode detection from device capabilities
  • Scene effects populated from device capabilities
  • Segment control for RGBIC devices
  • Music mode support

New Platforms & Entities

  • Select entities for dynamic scenes and DIY scenes (better UX for 80+ scene devices)
  • Switch entities for smart plugs/sockets
  • Night Light switch for devices with nightlight toggle (e.g., H601F)

New Services

  • govee.set_segment_color - Set color for specific RGBIC segments
  • govee.set_segment_brightness - Set brightness for specific segments
  • govee.set_music_mode - Activate music reactive modes
  • govee.refresh_scenes - Refresh scene list from cloud

Bug Fixes

  • Skip unsupported Govee Home app groups (SameModeGroup, BaseGroup, DreamViewScenic)
  • These pseudo-devices don't support API control and caused "unavailable" entities

Technical Changes

Modern Home Assistant Patterns

  • runtime_data pattern for typed config entry data
  • CoordinatorEntity base class for all entities
  • Proper async_forward_entry_setups (HA 2024.6+)
  • Config entry migration support

New Files

  • api/ - Complete v2.0 API client package
    • client.py - GoveeApiClient with all endpoints
    • const.py - API constants and capability types
    • exceptions.py - Typed exceptions
  • coordinator.py - DataUpdateCoordinator for state management
  • entity.py - GoveeEntity base class
  • models.py - Typed dataclasses for devices and state
  • select.py - Scene select entities
  • switch.py - Smart plug and night light switches
  • services.py - Service registration
  • services.yaml - Service definitions

Modified Files

  • __init__.py - Runtime data pattern, migration support
  • light.py - Full rewrite with capability-based features
  • config_flow.py - Uses new API client for validation
  • const.py - Platform mappings, device types, unsupported SKUs
  • manifest.json - Removed external dependency
  • strings.json / translations/en.json - New entity and service translations

Removed Files

  • learning_storage.py - No longer needed with v2.0 API

Supported Devices

Device Type Platforms
Lights & LED Strips Light, Select (scenes)
RGBIC Strips Light, Select + Segment services
Smart Plugs/Sockets Switch
Devices with Night Light Switch (additional)

Testing

  • Python syntax validation
  • Config flow (new setup)
  • Config migration (v1 → v2)
  • Light controls (on/off, brightness, color, color temp)
  • Scene selection
  • Segment control services
  • Night light toggle
  • Unsupported device filtering

Screenshots

N/A - Backend changes only

Related Issues

  • Fixes devices showing as "unavailable" when Govee Home app groups exist
  • Adds support for H601F night light mode
  • Adds segment control for RGBIC devices

Checklist

  • Code follows project style guidelines
  • Self-reviewed the code
  • Added translations for new strings
  • Updated README documentation
  • No breaking changes to existing entity IDs
  • Backward compatible with existing configurations

Tom Lasswell and others added 8 commits December 14, 2025 08:45
- Fix swapped min/max color temp properties (min_color_temp_kelvin now
  returns 2000K, max_color_temp_kelvin returns 9000K)
- Add missing await to async_forward_entry_unload call in
  _unload_component_entry to prevent race conditions
- Add error handling to async_turn_off to log API errors (matching
  async_turn_on pattern)
- Replace hass.states.set debug calls with _LOGGER.debug to avoid
  polluting Home Assistant state machine
- Add unit tests for color temp properties and turn_off error handling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add comprehensive type hints throughout __init__.py, light.py, and config_flow.py
- Increase default poll interval from 10s to 30s for better rate limit safety
- Update stale comment about single request API change
- Fix inconsistent error key naming (govee_ex -> govee_error)
- Add govee_error translation key to strings.json and en.json

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Major refactoring to replace external govee-api-laggat library with
inline v2.0 API client. This enables full feature support including
scenes, segments, music modes, and modern Home Assistant patterns.

Changes:
- Add inline API client (api/) with rate limiting and all v2.0 endpoints
- Add typed data models (models.py) for devices, state, capabilities
- Add DataUpdateCoordinator pattern (coordinator.py)
- Add base entity class (entity.py) with CoordinatorEntity
- Refactor light.py with capability-based features and effects
- Add select platform for dynamic/DIY scene selection
- Add switch platform for smart plugs/sockets
- Add services: set_segment_color, set_segment_brightness, set_music_mode, refresh_scenes
- Add config entry migration from v1 to v2
- Update manifest to remove external dependency (v2025.2.0)
- Remove learning_storage.py (no longer needed with v2.0 API)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add table of contents for easy navigation
- Add detailed HACS and manual installation instructions
- Add step-by-step API key acquisition guide
- Document all configuration options with tables
- Add supported devices section
- Document new features: scenes, segments, music mode
- Add complete service reference with parameters
- Add troubleshooting section with common issues
- Add debug logging instructions
- Update for Govee API v2.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Change HACS badge from Default to Custom
- Add custom repository installation instructions
- Update version to 2025.12.1 in README and manifest.json

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Update GitHub badges to lasswellt/hacs-govee
- Update HACS custom repository URL
- Update manifest.json codeowners, documentation, issue_tracker
- Update support links in README

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Features:
- Add Night Light toggle switch for devices that support it (e.g., H601F)
- Night Light state tracking in device state model
- New set_nightlight() API method

Fixes:
- Skip SameModeGroup, BaseGroup, and DreamViewScenic pseudo-devices
- These Govee Home app groups don't support API control (return 400 errors)
- Prevents "unavailable" entities and API error spam

Version bumped to 2025.12.2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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

Successfully merging this pull request may close these issues.

1 participant