Skip to content
Snippets Groups Projects
Commit 44b546c8 authored by KERDREUX Jerome's avatar KERDREUX Jerome
Browse files

Cleaned the device data to display

parent 29cdc0d3
No related branches found
No related tags found
No related merge requests found
......@@ -60,6 +60,28 @@ func (bDevice *BridgeDevice) SetTopic() string {
return bDevice.GetTopic() + "/set"
}
func (bDevices *BridgeDevice) dump() {
tab := table.NewWriter()
tab.SetTitle("Def:" + bDevices.FriendlyName)
tab.SetStyle(table.StyleRounded)
tab.AppendRow(table.Row{"IeeeAddr", bDevices.IeeeAddress})
tab.AppendRow(table.Row{"Vendor", bDevices.Definition.Vendor})
tab.AppendRow(table.Row{"Model", bDevices.Definition.Model})
tab.AppendRow(table.Row{"Type", bDevices.Type})
fmt.Println(tab.Render())
if len(bDevices.Definition.Exposes) > 0 {
expTab := table.NewWriter()
expTab.SetTitle("Exp:" + bDevices.FriendlyName)
expTab.SetStyle(table.StyleRounded)
expTab.AppendHeader(table.Row{"Name", "Type", "Unit"})
for _, expose := range bDevices.Definition.Exposes {
expTab.AppendRow(table.Row{expose.Name, expose.Type, expose.Unit})
}
fmt.Println(expTab.Render())
}
}
func parseDeviceJSON(jsonData []byte) {
var devices []BridgeDevice
err := json.Unmarshal([]byte(jsonData), &devices)
......@@ -81,13 +103,8 @@ func parseDeviceJSON(jsonData []byte) {
continue
}
// Extraction des informations
fmt.Println("Vendor:", device.Definition.Vendor)
fmt.Println("Model:", device.Definition.Model)
fmt.Println("Type:", device.Type)
fmt.Println("IEEE Address:", device.IeeeAddress)
device.dump()
// Extracting exposed features
for _, expose := range device.Definition.Exposes {
fmt.Printf("- Expose: %s[%s](%s)\n", expose.Name, expose.Type, expose.Unit)
if len(expose.Features) > 0 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment