Make these easier to find.
This commit is contained in:
parent
c5c1907be7
commit
8659adfcb2
|
|
@ -60,9 +60,6 @@ func (u *Unifi) parseDevices(data []json.RawMessage) *Devices {
|
||||||
devices := new(Devices)
|
devices := new(Devices)
|
||||||
// Loop each item in the raw JSON message, detect its type and unmarshal it.
|
// Loop each item in the raw JSON message, detect its type and unmarshal it.
|
||||||
for i, r := range data {
|
for i, r := range data {
|
||||||
var usg USG
|
|
||||||
var usw USW
|
|
||||||
var uap UAP
|
|
||||||
// Unamrshal into a map and check "type"
|
// Unamrshal into a map and check "type"
|
||||||
var obj map[string]interface{}
|
var obj map[string]interface{}
|
||||||
if err := json.Unmarshal(r, &obj); err != nil {
|
if err := json.Unmarshal(r, &obj); err != nil {
|
||||||
|
|
@ -77,18 +74,21 @@ func (u *Unifi) parseDevices(data []json.RawMessage) *Devices {
|
||||||
// Unmarshal again into the correct type..
|
// Unmarshal again into the correct type..
|
||||||
switch assetType {
|
switch assetType {
|
||||||
case "uap":
|
case "uap":
|
||||||
|
var uap UAP
|
||||||
if err := json.Unmarshal(r, &uap); err != nil {
|
if err := json.Unmarshal(r, &uap); err != nil {
|
||||||
u.eLogf("%d: json.Unmarshal([]UAP): %v", i, err)
|
u.eLogf("%d: json.Unmarshal([]UAP): %v", i, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
devices.UAPs = append(devices.UAPs, uap)
|
devices.UAPs = append(devices.UAPs, uap)
|
||||||
case "ugw", "usg": // in case they ever fix the name in the api.
|
case "ugw", "usg": // in case they ever fix the name in the api.
|
||||||
|
var usg USG
|
||||||
if err := json.Unmarshal(r, &usg); err != nil {
|
if err := json.Unmarshal(r, &usg); err != nil {
|
||||||
u.eLogf("%d: json.Unmarshal([]USG): %v", i, err)
|
u.eLogf("%d: json.Unmarshal([]USG): %v", i, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
devices.USGs = append(devices.USGs, usg)
|
devices.USGs = append(devices.USGs, usg)
|
||||||
case "usw":
|
case "usw":
|
||||||
|
var usw USW
|
||||||
if err := json.Unmarshal(r, &usw); err != nil {
|
if err := json.Unmarshal(r, &usw); err != nil {
|
||||||
u.eLogf("%d: json.Unmarshal([]USW): %v", i, err)
|
u.eLogf("%d: json.Unmarshal([]USW): %v", i, err)
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue