| 1 | package kasascip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/ |
| 2 | |
| 3 | type KasaClientEmeterServicescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientEmeterService# struct { |
| 4 | cscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientEmeterService#c. *KasaClientscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClient# |
| 5 | ctxscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientEmeterService#ctx. *KasaRequestContextscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaRequestContext# |
| 6 | } |
| 7 | |
| 8 | type GetRealtimeRequestscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeRequest# struct { |
| 9 | } |
| 10 | |
| 11 | type GetRealtimeResponsescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse# struct { |
| 12 | // some fw/hw may use the following keys |
| 13 | Currentscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Current. float64 `mapstructure:"current"` // unit is A |
| 14 | Voltagescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Voltage. float64 `mapstructure:"voltage"` // unit is V |
| 15 | Powerscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Power. float64 `mapstructure:"power"` // unit is W |
| 16 | Totalscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Total. float64 `mapstructure:"total"` // unit is kWh |
| 17 | |
| 18 | // some may use these |
| 19 | CurrentmAscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#CurrentmA. float64 `mapstructure:"current_ma"` |
| 20 | VoltagemVscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#VoltagemV. float64 `mapstructure:"voltage_mv"` |
| 21 | PowermWscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#PowermW. float64 `mapstructure:"power_mw"` |
| 22 | TotalWhscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#TotalWh. float64 `mapstructure:"total_wh"` |
| 23 | } |
| 24 | |
| 25 | func (r *GetRealtimeResponsescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#) Normalizescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Normalize().() { |
| 26 | if r.TotalWhscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#TotalWh. != -1 { |
| 27 | r.Currentscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Current. = r.CurrentmAscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#CurrentmA. / 1000 |
| 28 | r.Voltagescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Voltage. = r.VoltagemVscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#VoltagemV. / 1000 |
| 29 | r.Powerscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Power. = r.PowermWscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#PowermW. / 1000 |
| 30 | r.Totalscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Total. = r.TotalWhscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#TotalWh. / 1000 |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | func (s *KasaClientEmeterServicescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientEmeterService#) GetRealtimescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientEmeterService#GetRealtime().() (*GetRealtimeResponsescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#, error) { |
| 35 | response := GetRealtimeResponsescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#{ |
| 36 | TotalWhscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#TotalWh.: -1, |
| 37 | } |
| 38 | err := s.cscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientEmeterService#c..RPCscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClient#RPC().("emeter", "get_realtime", s.ctxscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientEmeterService#ctx., GetRealtimeRequestscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeRequest#{}, &response) |
| 39 | |
| 40 | response.Normalizescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Normalize().() |
| 41 | |
| 42 | return &response, err |
| 43 | } |