-
Notifications
You must be signed in to change notification settings - Fork 6
/
alexa.go
50 lines (42 loc) · 1.09 KB
/
alexa.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
package smarthome
import "time"
type alexa struct {
sh *Smarthome
}
func (a *alexa) ReportState(endpoint Endpoint) (resp EndpointResponse, err error) {
device := a.sh.GetDevice(endpoint.EndpointID)
if device == nil {
return
}
for _, capability := range device.GetCapabilityHandlers() {
for name, propHander := range capability.propertyHandlers {
val, err := propHander.GetValue()
if err != nil {
// TODO log error
continue
}
resp.Properties = append(resp.Properties, Property{
Namespace: capability.Interface,
Name: name,
Value: val,
TimeOfSample: zuluTime{time.Now()},
UncertaintyInMilliseconds: 0,
})
}
}
/*
Alexa.EndpointHealth
*/
if device.GetCapabilityHandler("Alexa.EndpointHealth") == nil {
resp.Properties = append(resp.Properties, Property{
Namespace: "Alexa.EndpointHealth",
Name: "connectivity",
Value: map[string]interface{}{
"value": "OK",
},
TimeOfSample: zuluTime{time.Now()},
UncertaintyInMilliseconds: 0,
})
}
return
}