Debian Codegraph @

kasa/system.go

raw symbols SCIP
1 package kasa
2
3 import "strings"
4
5 type KasaClientSystemService struct {
6 c *KasaClient
7 ctx *KasaRequestContext
8 }
9
10 type GetSysInfoRequest struct {
11 }
12
13 type SysInfoChildren struct {
14 ID string `mapstructure:"id"`
15 State int `mapstructure:"state"`
16 Alias string `mapstructure:"alias"`
17 OnTime int `mapstructure:"on_time"`
18 }
19
20 type GetSysInfoResponse struct {
21 MAC string `mapstructure:"mac"`
22 Model string `mapstructure:"model"`
23 Alias string `mapstructure:"alias"`
24 Feature string `mapstructure:"feature"`
25 RelayState int `mapstructure:"relay_state"`
26 RSSI int `mapstructure:"rssi"`
27 LEDOff int `mapstructure:"led_off"`
28 OnTime int `mapstructure:"on_time"`
29 DeviceID string `mapstructure:"deviceId"`
30 SoftwareVersion string `mapstructure:"sw_ver"`
31 HardwareVersion string `mapstructure:"hw_ver"`
32 Children []SysInfoChildren `mapstructure:"children"`
33 }
34
35 func (s *KasaClientSystemService) GetSysInfo() (*GetSysInfoResponse, error) {
36 var response GetSysInfoResponse
37 err := s.c.RPC("system", "get_sysinfo", s.ctx, GetSysInfoRequest{}, &response)
38
39 return &response, err
40 }
41
42 func (s *KasaClientSystemService) EmeterSupported(r *GetSysInfoResponse) bool {
43 return strings.Contains(r.Feature, "ENE")
44 }