Lucy handler add

This commit is contained in:
Stian Fredrik Aune
2021-09-28 21:54:03 +02:00
parent 0cd325e8db
commit c7d7e264ca
10 changed files with 196 additions and 46 deletions
+6 -5
View File
@@ -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) {
+26
View File
@@ -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
}
}