-
Notifications
You must be signed in to change notification settings - Fork 1
/
idose.go
215 lines (190 loc) · 7.95 KB
/
idose.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
package datastructs
// IDose
type iDoseShadow struct {
State StateIDose `json:"state"`
}
// StateIDose represents the State data structure from an IntelliDose packet
type StateIDose struct {
Reported ReportedIDose `json:"reported"`
}
// ReportedIDose represents the Reported data structure from an IntelliDose packet
type ReportedIDose struct {
Config ConfigIDose `json:"config"`
Metrics MetricsIDose `json:"metrics"`
Status StatusIDose `json:"status"`
Source string `json:"source"`
Device string `json:"device"`
Timestamp int64 `json:"timestamp"`
Connected bool `json:"connected"`
}
// ConfigIDose represents the Config data structure from an IntelliDose packet
type ConfigIDose struct {
Units UnitsIDose `json:"units"`
Times TimesIDose `json:"times"`
Functions FunctionsIDose `json:"functions"`
Advanced AdvancedIDose `json:"advanced"`
General GeneralIDose `json:"general"`
Scheduling SchedulingIDose `json:"scheduling"`
Reminders RemindersIDose `json:"reminder"`
}
// MetricsIDose represents the Metrics data structure from an IntelliDose packet
type MetricsIDose struct {
Ec float64 `json:"ec"`
NutTemp float64 `json:"nut_temp"`
PH float64 `json:"pH"`
}
// StatusIDose represents the Status data structure from an IntelliDose packet
type StatusIDose struct {
General GeneralStatusIDose `json:"general"`
Nutrient NutrientIDose `json:"nutrient"`
SetPoints SetPointsIDose `json:"set_points"`
Status []StatusStatusIDose `json:"status"`
}
// GeneralStatusIDose represents the GeneralStatus data structure from an IntelliDose packet
type GeneralStatusIDose struct {
DoseInterval byte `json:"dose_interval"`
NutrientDoseTime byte `json:"nutrient_dose_time"`
WaterOnTime byte `json:"water_on_time"`
IrrigationInterval1 IrrigationIntervalIDose `json:"irrigation_interval_1"`
IrrigationInterval2 IrrigationIntervalIDose `json:"irrigation_interval_2"`
IrrigationInterval3 IrrigationIntervalIDose `json:"irrigation_interval_3"`
IrrigationInterval4 IrrigationIntervalIDose `json:"irrigation_interval_4"`
IrrigationDuration1 int `json:"irrigation_duration_1"`
IrrigationDuration2 int `json:"irrigation_duration_2"`
IrrigationDuration3 int `json:"irrigation_duration_3"`
IrrigationDuration4 int `json:"irrigation_duration_4"`
MaxNutrientDoseTime byte `json:"max_nutrient_dose_time"`
MaxPhDoseTime byte `json:"max_ph_dose_time"`
Mix1 byte `json:"mix_1"`
Mix2 byte `json:"mix_2"`
Mix3 byte `json:"mix_3"`
Mix4 byte `json:"mix_4"`
Mix5 byte `json:"mix_5"`
Mix6 byte `json:"mix_6"`
Mix7 byte `json:"mix_7"`
Mix8 byte `json:"mix_8"`
PhDoseTime byte `json:"ph_dose_time"`
}
// IrrigationIntervalIDose represents the IrrigationInterval data structure from an IntelliDose packet
type IrrigationIntervalIDose struct {
Day int `json:"day"`
Night int `json:"night"`
Every int `json:"every"`
}
// NutrientIDose represents the Nutrient data structure from an IntelliDose packet
type NutrientIDose struct {
Detent byte `json:"detent"`
Ec EcIDose `json:"ec"`
NutTemp NutTempIDose `json:"nut_temp"`
Ph PhIDose `json:"ph"`
}
// EcIDose represents the Ec data structure from an IntelliDose packet
type EcIDose struct {
Enabled bool `json:"enabled"`
Max float64 `json:"max"`
Min float64 `json:"min"`
}
// NutTempIDose represents the NutTemp data structure from an IntelliDose packet
type NutTempIDose struct {
Enabled bool `json:"enabled"`
Max float64 `json:"max"`
Min float64 `json:"min"`
}
// PhIDose represents the Ph data structure from an IntelliDose packet
type PhIDose struct {
Enabled bool `json:"enabled"`
Max float64 `json:"max"`
Min float64 `json:"min"`
}
// SetPointsIDose represents the SetPoints data structure from an IntelliDose packet
type SetPointsIDose struct {
Nutrient float64 `json:"nutrient"`
NutrientNight float64 `json:"nutrient_night"`
PhDosing string `json:"ph_dosing"`
Ph float64 `json:"ph"`
}
// StatusStatusIDose represents the StatusStatus data structure from an IntelliDose packet
type StatusStatusIDose struct {
Active bool `json:"active"`
Enabled bool `json:"enabled"`
ForceOn bool `json:"force_on"`
Function string `json:"function"`
}
// UnitsIDose represents the Units data structure from an IntelliDose packet
type UnitsIDose struct {
DateFormat string `json:"date_format"`
Temperature string `json:"temperature"`
Ec string `json:"ec"`
TdsConversationStandart int `json:"tds_conversation_standart"`
}
// TimesIDose represents the Times data structure from an IntelliDose packet
type TimesIDose struct {
DayStart int `json:"day_start"`
DayEnd int `json:"day_end"`
}
// FunctionsIDose represents the Functions data structure from an IntelliDose packet
type FunctionsIDose struct {
NutrientsParts byte `json:"nutrients_parts"`
PhDosing string `json:"ph_dosing"`
IrrigationMode string `json:"irrigation_mode"`
IrrigationStations byte `json:"irrigation_stations"`
SeparatePumpOutput bool `json:"separate_pump_output"`
UseWater bool `json:"use_water"`
ExternalAlarm bool `json:"external_alarm"`
DayNightEc bool `json:"day_night_ec"`
IrrigationStation1 string `json:"irrigation_station_1"`
IrrigationStation2 string `json:"irrigation_station_2"`
IrrigationStation3 string `json:"irrigation_station_3"`
IrrigationStation4 string `json:"irrigation_station_4"`
Scheduling bool `json:"scheduling"`
MuteBuzzer bool `json:"mute_buzzer"`
}
// AdvancedIDose represents the Advanced data structure from an IntelliDose packet
type AdvancedIDose struct {
ProportinalDosing bool `json:"proportinal_dosing"`
SequentialDosing bool `json:"sequential_dosing"`
DisableEc bool `json:"disable_ec"`
DisablePh bool `json:"disable_ph"`
MntnReminderFreq string `json:"mntn_reminder_freq"`
}
// GeneralIDose represents the General data structure from an IntelliDose packet
type GeneralIDose struct {
DeviceName string `json:"device_name"`
Firmware float64 `json:"firmware"`
Growroom string `json:"growroom"`
}
// SchedulingIDose represents the scheduling data structure from an IntelliDose packet
type SchedulingIDose struct {
LastUpdated float64 `json:"last_updated"`
Mode string `json:"mode"`
}
// ReminderIDose represents the a single reminder data structure from an IntelliDose packet
type ReminderIDose struct {
CleanECProbe float64 `json:"clean_ec_probe"`
CleanpHProbe float64 `json:"clean_ph_electrode"`
CheckECProbe float64 `json:"check_ec_probe"`
CalibratePH float64 `json:"calibrate_ph"`
CleanFilters float64 `json:"clean_filters"`
}
// RemindersIDose represents the reminders data structure from an IntelliDose packet
type RemindersIDose struct {
Frequency string `json:"frequency"`
StartDate float64 `json:"start_date"`
ReminderList ReminderIDose `json:"reminder_list"`
}
// DoserHistory - consists of a slice of history points
type DoserHistory struct {
Points []*DoserHistoryPoint `json:"points"`
}
// DoseMetricsHistory - Metrics the history point contains
type DoseMetricsHistory struct {
EC float64 `json:"ec"`
PH float64 `json:"pH"`
Temp float64 `json:"nut_temp"`
}
// DoserHistoryPoint - defines a single history point reported for a IntelliDose
type DoserHistoryPoint struct {
Timestamp float64 `json:"timestamp"`
Status Status `json:"status"`
Metrics DoseMetricsHistory `json:"metrics"`
}