package uistate import ( "fmt" "git.aiterp.net/lucifer3/server/device" "git.aiterp.net/lucifer3/server/effects" "git.aiterp.net/lucifer3/server/events" "git.aiterp.net/lucifer3/server/internal/color" "git.aiterp.net/lucifer3/server/services/variables" "github.com/google/uuid" ) type Patch struct { Assignment *AssignmentPatch `json:"assignment,omitempty"` Device *DevicePatch `json:"device,omitempty"` VariableProperty *variables.PropertyPatch `json:"variableProperty,omitempty"` } func (e Patch) VerboseKey() string { return "uistate.Patch" } func (e Patch) EventDescription() string { if e.Device != nil { switch { case e.Device.Name != nil: return fmt.Sprintf("uistate.Patch(device=%s, name=%s)", e.Device.ID, e.Device.Name) case e.Device.DesiredState != nil: return fmt.Sprintf("uistate.Patch(device=%s, desiredState=%s)", e.Device.ID, e.Device.DesiredState.String()) case e.Device.HWState != nil: return fmt.Sprintf("uistate.Patch(device=%s, hwState)", e.Device.ID) case e.Device.HWMetadata != nil: return fmt.Sprintf("uistate.Patch(device=%s, hwMetadata)", e.Device.ID) case e.Device.AddAlias != nil: return fmt.Sprintf("uistate.Patch(device=%s, addAlias=%s)", e.Device.ID, *e.Device.AddAlias) case e.Device.RemoveAlias != nil: return fmt.Sprintf("uistate.Patch(device=%s, removeAlias=%s)", e.Device.ID, *e.Device.RemoveAlias) case e.Device.ActiveColorRGB != nil: col := color.Color{RGB: e.Device.ActiveColorRGB} return fmt.Sprintf("uistate.Patch(device=%s, activeColorRgb=%s)", e.Device.ID, col.String()) default: return fmt.Sprintf("uistate.Patch(device=%s, ...other)", e.Device.ID) } } else if e.Assignment != nil { return fmt.Sprintf("uistate.Patch(assignment=%s)", e.Assignment.ID) } else if e.VariableProperty != nil { return fmt.Sprintf("uistate.Patch(variableProperty=%s)", e.VariableProperty.Key) } else { return "uistate.Patch" } } type DevicePatch struct { ID string `json:"id,omitempty"` Name *string `json:"name,omitempty"` HWMetadata *events.HardwareMetadata `json:"hwMetadata,omitempty"` HWState *events.HardwareState `json:"hwState,omitempty"` DesiredState *device.State `json:"desiredState,omitempty"` SetAliases []string `json:"setAliases,omitempty"` AddAlias *string `json:"addAlias,omitempty"` RemoveAlias *string `json:"removeAlias,omitempty"` Assignment *uuid.UUID `json:"assignment,omitempty"` ClearAssignment bool `json:"clearAssignment,omitempty"` ActiveColorRGB *color.RGB `json:"activeColorRgb,omitempty"` ClearActiveColorRGB bool `json:"clearActiveColorRGB,omitempty"` Sensors *DeviceSensors `json:"sensors,omitempty"` Delete bool `json:"delete,omitempty"` } type AssignmentPatch struct { ID uuid.UUID `json:"id"` AddDeviceID *string `json:"addDeviceId"` RemoveDeviceID *string `json:"removeDeviceId"` Effect *effects.Serializable `json:"effect"` Delete bool `json:"delete"` }