@@ -144,11 +144,6 @@ type DeviceStatus struct {
144
144
IsGrouped bool `json:"group"`
145
145
IsMoving bool `json:"moving"`
146
146
SlidePosition int `json:"slidePosition"`
147
- FanMode int `json:"mode"`
148
- FanSpeed int `json:"speed"`
149
- IsShaking bool `json:"shaking"`
150
- ShakeCenter int `json:"shakeCenter"`
151
- ShakeRange int `json:"shakeRange"`
152
147
IsMoveDetected bool `json:"moveDetected"`
153
148
Brightness BrightnessState `json:"brightness"`
154
149
LightLevel int `json:"lightLevel"`
@@ -168,6 +163,12 @@ type DeviceStatus struct {
168
163
Version DeviceVersion `json:"version"`
169
164
Direction string `json:"direction"`
170
165
CO2 int `json:"CO2"`
166
+ Mode Mode `json:"mode"`
167
+ NightStatus NightStatus `json:"nightStatus"`
168
+ Oscillation OscillationStatus `json:"oscillation"`
169
+ VerticalOscillation OscillationStatus `json:"verticalOscillation"`
170
+ ChargingStatus ChargingStatus `json:"chargingStatus"`
171
+ FanSpeed int `json:"fanSpeed"`
171
172
}
172
173
173
174
type PowerState string
@@ -259,6 +260,68 @@ const (
259
260
CleanerInDustCollecting CleanerWorkingStatus = "InDustCollecting"
260
261
)
261
262
263
+ type Mode struct {
264
+ circulatorMode CirculatorMode
265
+ intMode int // evaporative humidifier or air purifier
266
+ }
267
+
268
+ func (mode * Mode ) UnmarshalJSON (b []byte ) error {
269
+ var iv int
270
+ if err := json .Unmarshal (b , & iv ); err != nil {
271
+ var sv string
272
+ if err := json .Unmarshal (b , & sv ); err != nil {
273
+ return fmt .Errorf ("cannot unmarshal to both of int and string: %w" , err )
274
+ }
275
+
276
+ mode .circulatorMode = CirculatorMode (sv )
277
+
278
+ return nil
279
+ }
280
+
281
+ mode .intMode = iv
282
+
283
+ return nil
284
+ }
285
+
286
+ func (mode Mode ) CirculatorMode () (CirculatorMode , error ) {
287
+ if mode .circulatorMode != "" {
288
+ return mode .circulatorMode , nil
289
+ }
290
+
291
+ return "" , errors .New ("circulator mode is only available for circulator and battery circulator" )
292
+ }
293
+
294
+ type CirculatorMode string
295
+
296
+ const (
297
+ CirculatorModeDirect CirculatorMode = "direct"
298
+ CirculatorModeNatural CirculatorMode = "natural"
299
+ CirculatorModeSleep CirculatorMode = "sleep"
300
+ CirculatorModeUltraQuitet CirculatorMode = "baby"
301
+ )
302
+
303
+ type NightStatus string
304
+
305
+ const (
306
+ NightStatusOff NightStatus = "off"
307
+ NightStatusMode1 NightStatus = "1"
308
+ NightStatusMode2 NightStatus = "2"
309
+ )
310
+
311
+ type OscillationStatus string
312
+
313
+ const (
314
+ OscillationStatusOn OscillationStatus = "on"
315
+ OscillationStatusOff OscillationStatus = "off"
316
+ )
317
+
318
+ type ChargingStatus string
319
+
320
+ const (
321
+ ChargingStatusCharging ChargingStatus = "charging"
322
+ ChargingStatusUncharged ChargingStatus = "uncharged"
323
+ )
324
+
262
325
// Status get the status of a physical device that has been added to the current
263
326
// user's account. Physical devices refer to the SwitchBot products.
264
327
// The first given argument `id` is a device ID which can be retrieved by
0 commit comments