package uistate import ( "fmt" "git.aiterp.net/lucifer3/server/device" "git.aiterp.net/lucifer3/server/effects" "git.aiterp.net/lucifer3/server/events" "github.com/google/uuid" ) type Patch struct { Assignment *AssignmentPatch `json:"assignment,omitempty"` Device *DevicePatch `json:"device,omitempty"` } func (e Patch) EventDescription() string { if e.Device != nil { switch { case e.Device.DesiredState != nil: return fmt.Sprintf("uistate.Patch(device=%s, desired state)", e.Device.ID) default: return fmt.Sprintf("uistate.Patch(device=%s)", e.Device.ID) } } else if e.Assignment != nil { return fmt.Sprintf("uistate.Patch(assignment=%s)", e.Assignment.ID) } 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"` 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"` }