本文整理匯總了Golang中github.com/barnybug/gohome/pubsub.Event.Command方法的典型用法代碼示例。如果您正苦於以下問題:Golang Event.Command方法的具體用法?Golang Event.Command怎麽用?Golang Event.Command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/barnybug/gohome/pubsub.Event
的用法示例。
在下文中一共展示了Event.Command方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: translateCommands
// Translate command messages into rfxtrx packets
func translateCommands(ev *pubsub.Event) (gorfxtrx.OutPacket, error) {
device := ev.Device()
command := ev.Command()
if command != "off" && command != "on" {
log.Println("Command not recognised:", command)
return nil, nil
}
pids := services.Config.LookupDeviceProtocol(device)
if len(pids) == 0 {
log.Println("Device not found for:", device)
return nil, nil
}
switch {
case pids["homeeasy"] != "":
return gorfxtrx.NewLightingHE(0x00, pids["homeeasy"], command)
case pids["x10"] != "":
return gorfxtrx.NewLightingX10(0x01, pids["x10"], command)
}
return nil, nil
}