Nik Afiq 6ea4e84949
All checks were successful
CI / test (push) Successful in 4s
CI / build-ha-gateway (push) Successful in 1m7s
CI / build-discord-bot (push) Successful in 51s
Enhance Discord bot and HA gateway with improved structure and documentation
- Added detailed comments to clarify the purpose of various functions and types in the Discord bot and HA gateway.
- Introduced new methods in the CommandApp for handling light and switch operations, including HandleLightOn, HandleLightOff, HandleLightToggle, and their respective autocomplete functions.
- Updated the HAClient interface to include methods for fetching states and calling services, enhancing the interaction with Home Assistant.
- Improved the structure of entity and light domain models to include additional attributes and clearer documentation.
- Implemented logging enhancements in both the Discord bot and HA gateway to ensure better traceability and context in logs.
- Refactored the configuration loading process to streamline environment variable handling and defaults.
- Stubbed out switch control methods in the gRPC adapter, indicating future implementation plans.
- Enhanced telemetry setup to ensure proper initialization and shutdown procedures for observability.
2026-04-09 06:00:59 +09:00

63 lines
2.2 KiB
Go

package domain
// ColorMode describes a Home Assistant light color capability.
type ColorMode string
const (
// ColorModeColorTemp indicates color temperature control in kelvin.
ColorModeColorTemp ColorMode = "color_temp"
// ColorModeHS indicates hue/saturation color control.
ColorModeHS ColorMode = "hs"
// ColorModeXY indicates XY color control.
ColorModeXY ColorMode = "xy"
// ColorModeBrightness indicates brightness-only control.
ColorModeBrightness ColorMode = "brightness"
)
// Light represents a discovered light entity with presentation-friendly fields.
type Light struct {
// EntityID is the Home Assistant entity identifier.
EntityID EntityID
// FriendlyName is the user-facing name from Home Assistant attributes.
FriendlyName string
// State is the current raw light state, usually on, off, or unavailable.
State string // "on" | "off" | "unavailable"
// SupportedColorModes mirrors Home Assistant supported_color_modes.
SupportedColorModes []ColorMode
// MinColorTempKelvin is the lower supported color temperature bound.
MinColorTempKelvin uint32
// MaxColorTempKelvin is the upper supported color temperature bound.
MaxColorTempKelvin uint32
// IsHueGroup marks synthetic Hue group entities.
IsHueGroup bool
// EffectList contains supported named effects when exposed by Home Assistant.
EffectList []string
}
// TurnOnParams collects optional light turn-on parameters.
type TurnOnParams struct {
// EntityID is the target light entity.
EntityID EntityID
// BrightnessPct is nil when brightness should be left unchanged.
BrightnessPct *uint32
// ColorTempKelvin is nil when color temperature should be left unchanged.
ColorTempKelvin *uint32
// RGBColor is nil when RGB color should be left unchanged.
RGBColor *RGBColor
// Transition is nil when no explicit transition is requested.
Transition *uint32
}
// RGBColor represents an RGB color payload for Home Assistant light calls.
type RGBColor struct {
R, G, B uint8
}
// TurnOffParams collects optional light turn-off parameters.
type TurnOffParams struct {
// EntityID is the target light entity.
EntityID EntityID
// Transition is nil when no explicit transition is requested.
Transition *uint32
}