-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththings.go
89 lines (86 loc) · 2.53 KB
/
things.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"github.com/connctd/connector-go"
"github.com/connctd/connector-go/connctd"
)
const (
RandomComponentId = "random"
RandomPropertyId = "value"
SearchComponentId = "search"
SearchPropertyId = "value"
SearchActionId = "search"
SearchActionParameterId = "keyword"
)
// thingTemplates returns a thing that can be registered with the connctd platform together with an external id.
// The external id can be used to map external devices or objects to the thing and is stored in the connector by the default service.
// In our case it is left empty.
// Note that the thing ID is generated by connctd and returned when the thing is created.
// The connctd platform will store all information regarding the thing.
// The connector therefore should only store its ID.
// The thing will have two components.
// random will periodically updated by a new random value.
// search will only be updated when a search action is triggered.
func thingTemplate(request connector.InstantiationRequest) []connector.ThingTemplate {
thing := connctd.Thing{
Name: "Giphy",
Manufacturer: "IoT connctd GmbH",
DisplayType: "core.SENSOR",
MainComponentID: RandomComponentId,
Status: "AVAILABLE",
Attributes: []connctd.ThingAttribute{},
Components: []connctd.Component{
{
ID: RandomComponentId,
Name: "Giphy random component",
ComponentType: "core.Sensor",
Capabilities: []string{
"core.RANDOMIZE",
},
Properties: []connctd.Property{
{
ID: RandomPropertyId,
Name: "Giphy random property",
Value: "",
Type: connctd.ValueTypeString,
PropertyType: "giphy.IMAGE_URL",
},
},
Actions: []connctd.Action{},
},
{
ID: SearchComponentId,
Name: "Giphy search",
ComponentType: "core.Sensor",
Capabilities: []string{
"giphy.SEARCH",
},
Properties: []connctd.Property{
{
ID: SearchPropertyId,
Name: "Giphy search property",
Type: connctd.ValueTypeString,
PropertyType: "giphy.SEARCH_RESULT",
},
},
Actions: []connctd.Action{
{
ID: SearchActionId,
Name: "Giphy search action",
Parameters: []connctd.ActionParameter{
{
Name: SearchActionParameterId,
Type: connctd.ValueTypeString,
},
},
},
},
},
},
}
return []connector.ThingTemplate{
{
Thing: thing,
ExternalID: "",
},
}
}