Lucy handler add
This commit is contained in:
@@ -196,11 +196,12 @@ func (c *EventCondition) matches(value string) bool {
|
||||
}
|
||||
|
||||
type EventAction struct {
|
||||
SetPower *bool `json:"setPower"`
|
||||
SetColor *string `json:"setColor"`
|
||||
SetIntensity *float64 `json:"setIntensity"`
|
||||
AddIntensity *float64 `json:"addIntensity"`
|
||||
FireEvent *Event `json:"fireEvent"`
|
||||
SetPower *bool `json:"setPower"`
|
||||
SetColor *string `json:"setColor"`
|
||||
SetIntensity *float64 `json:"setIntensity"`
|
||||
SetTemperature *int `json:"setTemperature"`
|
||||
AddIntensity *float64 `json:"addIntensity"`
|
||||
FireEvent *Event `json:"fireEvent"`
|
||||
}
|
||||
|
||||
func (action *EventAction) Apply(other EventAction) {
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ReferenceKind string
|
||||
|
||||
var (
|
||||
@@ -9,3 +14,24 @@ var (
|
||||
RKAll ReferenceKind = "All"
|
||||
RKName ReferenceKind = "Name"
|
||||
)
|
||||
|
||||
func ParseFetchString(fetchStr string) (ReferenceKind, string) {
|
||||
if strings.HasPrefix(fetchStr, "tag:") {
|
||||
return RKTag, fetchStr[4:]
|
||||
} else if strings.HasPrefix(fetchStr, "bridge:") {
|
||||
return RKBridgeID, fetchStr[7:]
|
||||
} else if strings.HasPrefix(fetchStr, "id:") {
|
||||
return RKDeviceID, fetchStr[7:]
|
||||
} else if strings.HasPrefix(fetchStr, "name:") {
|
||||
return RKName, fetchStr[7:]
|
||||
} else if fetchStr == "all" {
|
||||
return RKAll, ""
|
||||
} else {
|
||||
_, err := strconv.Atoi(fetchStr)
|
||||
if err != nil {
|
||||
return RKName, fetchStr
|
||||
}
|
||||
|
||||
return RKDeviceID, fetchStr
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user