-
Notifications
You must be signed in to change notification settings - Fork 0
/
humidity.go
135 lines (110 loc) · 3.34 KB
/
humidity.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package shelly
import (
"context"
"github.com/mongoose-os/mos/common/mgrpc"
"github.com/mongoose-os/mos/common/mgrpc/frame"
)
// HumidityGetConfigRequest contains parameters for the Humidity.GetConfig RPC request.
type HumidityGetConfigRequest struct {
// ID of the humidity component instance.
ID int `json:"id"`
}
func (r *HumidityGetConfigRequest) Method() string {
return "Humidity.GetConfig"
}
func (r *HumidityGetConfigRequest) NewTypedResponse() *HumidityConfig {
return &HumidityConfig{}
}
func (r *HumidityGetConfigRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *HumidityGetConfigRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*HumidityConfig,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}
// HumiditySetConfigRequest contains parameters for the Humidity.SetConfig RPC request.
type HumiditySetConfigRequest struct {
// ID of the humidity component instance.
ID int `json:"id"`
// Config that the method takes.
Config HumidityConfig `json:"config"`
}
func (r *HumiditySetConfigRequest) Method() string {
return "Humidity.SetConfig"
}
func (r *HumiditySetConfigRequest) NewTypedResponse() *SetConfigResponse {
return &SetConfigResponse{}
}
func (r *HumiditySetConfigRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *HumiditySetConfigRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*SetConfigResponse,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}
// HumidityGetStatusRequst contains parameters for the Humidity.GetStatus RPC request.
type HumidityGetStatusRequest struct {
// ID of the humidity component instance.
ID int `json:"id"`
}
func (r *HumidityGetStatusRequest) Method() string {
return "Humidity.GetStatus"
}
func (r *HumidityGetStatusRequest) NewTypedResponse() *HumidityStatus {
return &HumidityStatus{}
}
func (r *HumidityGetStatusRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *HumidityGetStatusRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*HumidityStatus,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}
// HumidityConfig provides configuration for humidity component instances.
type HumidityConfig struct {
// ID of the humidity component instance.
ID int `json:"id"`
// Name of the humidity instance.
Name *string `json:"name"`
// ReportTHR is the humidity report threshold in %. Accepted range is device-specific,
// default [1.0..20.0]% unless specified otherwise.
ReportTHR *float64 `json:"report_thr,omitempty"`
// Offset in %. Value is applied to measured humidity. Accepted range is device-specific, default [-50.0..50.0]% unless specified otherwise
Offset *float64 `json:"offset,omitempty"`
}
// HumidityStatus describes the status of humidity component instances.
type HumidityStatus struct {
// ID of the humidity component instance.
ID int `json:"id"`
// RH is the relative humidity in % (null if valid value could not be obtained)
RH *float64 `json:"rh,omitempty"`
// Errors is a list of error events related to humidity.
Errors []string `json:"errors,omitempty"`
}