1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-26 13:48:49 +08:00

Account for devices which are not commanders

This commit is contained in:
Adrian Zankich 2014-12-03 10:59:19 -08:00
parent be963f989c
commit f1e94b5a1a

View File

@ -25,8 +25,10 @@ func NewJSONDevice(device Device) *JSONDevice {
if device.Connection() != nil {
jsonDevice.Connection = device.Connection().Name()
}
for command := range device.(Commander).Commands() {
jsonDevice.Commands = append(jsonDevice.Commands, command)
if commander, ok := device.(Commander); ok {
for command := range commander.Commands() {
jsonDevice.Commands = append(jsonDevice.Commands, command)
}
}
return jsonDevice
}