Files
Cyrene_v2/backend/internal/plugin/iot.go
T
Aska 750d594055 feat(plugin): add plugin interface system and iot-mock implementation
- internal/plugin: Plugin/IoTProvider/ToolProvider/RAGProvider interfaces
- internal/plugin: Registry with type-safe auto-detection, 11 tests
- plugins/iot-mock: 8 simulated smart home devices, 11 tests
- 63 total tests, build + vet clean
2026-08-09 20:38:37 +08:00

26 lines
824 B
Go

package plugin
import "context"
// IoTProvider is implemented by plugins that manage IoT devices.
// Only one IoTProvider can be active at a time.
type IoTProvider interface {
Plugin
// ListDevices returns all managed devices.
ListDevices(ctx context.Context) ([]Device, error)
// GetDevice returns a single device by ID.
GetDevice(ctx context.Context, id string) (*Device, error)
// SetDevice sets a property on a device (e.g., brightness=80).
SetDevice(ctx context.Context, id, field string, value any) error
// ToggleDevice toggles a device's power state.
ToggleDevice(ctx context.Context, id string) error
// SubscribeChanges returns a channel that emits device state changes.
// The channel is closed when the context is cancelled.
SubscribeChanges(ctx context.Context) (<-chan DeviceEvent, error)
}