All checks were successful
CI / changes (push) Successful in 19s
CI / test (push) Successful in 24s
CI / build-ai-gateway (push) Successful in 1m6s
CI / build-ha-gateway (push) Successful in 1m3s
CI / build-discord-bot (push) Successful in 1m4s
CI / build-alexa-bridge (push) Successful in 1m15s
CI / build-tts-gateway (push) Successful in 1m5s
CI / build-tts-sidecar (push) Has been skipped
CI / build-tts-model (push) Has been skipped
- Implemented SetTemperature in ClimateService for setting an absolute target temperature. - Updated ClimateServiceClient and ClimateServiceServer interfaces to include SetTemperature. - Added corresponding handler and tests for SetTemperature in ClimateGRPC. - Modified ClimateApp to handle SetTemperature requests without clamping. - Updated climate.proto to define SetTemperatureRequest message. - Adjusted Dockerfiles to include alexa-bridge dependencies.
72 lines
2.0 KiB
Go
72 lines
2.0 KiB
Go
package directive
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gitea.nik4nao.com/nik/home-services/alexa-bridge/internal/alexa"
|
|
)
|
|
|
|
func slotValue(slots map[string]alexa.Slot, name string) (string, error) {
|
|
s, ok := slots[name]
|
|
if !ok || s.Value == "" {
|
|
return "", fmt.Errorf("missing or empty slot %q", name)
|
|
}
|
|
return s.Value, nil
|
|
}
|
|
|
|
func brightnessParams(slots map[string]alexa.Slot) (map[string]any, error) {
|
|
v, err := slotValue(slots, "Brightness")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return map[string]any{"brightness_pct": v}, nil
|
|
}
|
|
|
|
func colorTempParams(slots map[string]alexa.Slot) (map[string]any, error) {
|
|
v, err := slotValue(slots, "ColorTemp")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return map[string]any{"color_temp_kelvin": v}, nil
|
|
}
|
|
|
|
// colorParams reads three separate numeric slots (Red/Green/Blue) rather
|
|
// than a single named-color slot. A nicer "set it to warm white" voice UX
|
|
// would need a custom slot type mapping color names to RGB triples — an
|
|
// interaction-model addition, not a backend gap — deliberately left for
|
|
// later rather than inventing a name/RGB table here.
|
|
func colorParams(slots map[string]alexa.Slot) (map[string]any, error) {
|
|
r, err := slotValue(slots, "Red")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
g, err := slotValue(slots, "Green")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
b, err := slotValue(slots, "Blue")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return map[string]any{"rgb_color": map[string]any{"r": r, "g": g, "b": b}}, nil
|
|
}
|
|
|
|
func hvacModeParams(slots map[string]alexa.Slot) (map[string]any, error) {
|
|
v, err := slotValue(slots, "HVACMode")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return map[string]any{"hvac_mode": v}, nil
|
|
}
|
|
|
|
// temperatureParams backs SetTemperatureIntent, added alongside
|
|
// ClimateService.SetTemperature — see plan.md's "Decisions on open
|
|
// questions" #1.
|
|
func temperatureParams(slots map[string]alexa.Slot) (map[string]any, error) {
|
|
v, err := slotValue(slots, "Temperature")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return map[string]any{"target_temperature": v}, nil
|
|
}
|