rewrite of publishing mechanism to make scenes first-class.
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-09-26 22:15:49 +02:00
parent f87c69efc7
commit ffa757f742
4 changed files with 120 additions and 422 deletions
+4 -9
View File
@@ -113,7 +113,7 @@ func (r *SceneRole) Validate() error {
}
switch r.PowerMode {
case SPScene, SPDevice, SPOverride:
case SPScene, SPDevice:
default:
return ErrSceneRoleUnknownPowerMode
}
@@ -165,7 +165,7 @@ func (r *SceneRole) ApplyOrder(devices []Device) {
}
}
func (r *SceneRole) ApplyEffect(device *Device, c SceneRunContext) (newState NewDeviceState, deviceChanged bool) {
func (r *SceneRole) ApplyEffect(device *Device, c SceneRunContext) (newState NewDeviceState) {
switch r.Effect {
case SEStatic:
newState = r.States[0]
@@ -184,11 +184,6 @@ func (r *SceneRole) ApplyEffect(device *Device, c SceneRunContext) (newState New
newState.Power = nil
case SPScene:
// Do nothing
case SPOverride:
if newState.Power != nil && device.State.Power != *newState.Power {
device.State.Power = *newState.Power
deviceChanged = true
}
}
return
@@ -226,10 +221,10 @@ type ScenePowerMode string
const (
SPDevice ScenePowerMode = "Device" // Device state decides power. Scene state may only power off.
SPScene ScenePowerMode = "Scene" // Scene state decide power.
SPOverride ScenePowerMode = "Override" // Same as above, but Scene state set Device state' power. This is good for "wake up" scenes.
)
// DeviceSceneAssignment is an entry on the device stack.
// DeviceSceneAssignment is an entry on the device stack. StartTime and DurationMS are only respected when the scene
// instance is created for the group.
type DeviceSceneAssignment struct {
SceneID int `json:"sceneId"`
Group string `json:"group"`