From b596456e098b40ad5897e9521f7a7bda5035e4aa Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 10:23:59 -0700 Subject: [PATCH 01/21] Add support for additional WeMo devices --- discover.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/discover.go b/discover.go index 016dbdb..f821ab3 100644 --- a/discover.go +++ b/discover.go @@ -27,9 +27,16 @@ type Wemo struct { func (self *Wemo) DiscoverAll(timeout time.Duration) ([]*Device, error) { urns := []string{ - "urn:Belkin:device:controllee:1", - "urn:Belkin:device:light:1", - "urn:Belkin:device:sensor:1", + // TODO: Include additional third-party WeMo devices from Holmes and Mr. Coffee + "urn:Belkin:device:bridge:1", // WeMo Link + "urn:Belkin:device:controllee:1", // WeMo Switch + "urn:Belkin:device:crockpot:1", // WeMo Crockpot + "urn:Belkin:device:insight:1", // WeMo Insight Switch + "urn:Belkin:device:lightswitch:1",// WeMo Light Switch + "urn:Belkin:device:Maker:1", // WeMo Maker + "urn:Belkin:device:netcam:1", // WeMo NetCam and NetCam HD+ + "urn:Belkin:device:sensor:1", // WeMo Motion Sensor + "urn:Belkin:device:wemo_baby:1", // WeMo Baby Monitor } var all []*Device From 2c4362590d0e3e95a3eb94d0266a65c0be17f858 Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 10:28:28 -0700 Subject: [PATCH 02/21] Include Mac Address in output TODO -- Correct MacAddress offset --- wemo/discover.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wemo/discover.go b/wemo/discover.go index 45c099f..d093298 100644 --- a/wemo/discover.go +++ b/wemo/discover.go @@ -36,9 +36,10 @@ func commandAction(c *cli.Context) { log.Fatal(err) } - format := "%-20s %-20s %-21s %-20s\n" + format := "%-20s %-20s %-20s %-21s %-20s\n" fmt.Printf(format, "Host", + "Mac Address", "Friendly Name", "Firmware Version", "Serial Number", @@ -48,6 +49,7 @@ func commandAction(c *cli.Context) { "----------------", "----------------", "----------------", + "----------------", ) deviceInfos := wemo.DeviceInfos{} @@ -63,6 +65,7 @@ func commandAction(c *cli.Context) { for _, deviceInfo := range deviceInfos { fmt.Printf(format, deviceInfo.Device.Host, + deviceinfo.MacAddress, deviceInfo.FriendlyName, deviceInfo.FirmwareVersion, deviceInfo.SerialNumber) From b8cd997fc83e161aa97ceb9cd3516bc2c55c82e7 Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 10:33:32 -0700 Subject: [PATCH 03/21] Include missing parameter for cli calls --- wemo/discover.go | 9 ++++++--- wemo/power.go | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/wemo/discover.go b/wemo/discover.go index d093298..88c7e02 100644 --- a/wemo/discover.go +++ b/wemo/discover.go @@ -10,14 +10,17 @@ import ( "time" ) +// cli.Flag requires an additional pointer argument +var giface, gip, gtimeout; + var discoverCommand = cli.Command{ Name: "discover", Usage: "find devices in the local network", Description: "search for devices in the local network", Flags: []cli.Flag{ - cli.StringFlag{"interface", "", "search by interface", ""}, - cli.StringFlag{"ip", "", "discovery wemo by ip", ""}, - cli.IntFlag{"timeout", 3, "timeout", ""}, + cli.StringFlag{"interface", "", "search by interface", "", &piface}, + cli.StringFlag{"ip", "", "discovery wemo by ip", "", &pip}, + cli.IntFlag{"timeout", 3, "timeout", "", &ptimeout}, }, Action: commandAction, } diff --git a/wemo/power.go b/wemo/power.go index 9227d40..adb0550 100644 --- a/wemo/power.go +++ b/wemo/power.go @@ -5,10 +5,12 @@ import ( "github.com/savaki/go.wemo" ) +var phost; + var onCommand = cli.Command{ Name: "on", Flags: []cli.Flag{ - cli.StringFlag{"host", "", "device host and ip e.g. 10.0.1.2:49128", ""}, + cli.StringFlag{"host", "", "device host and ip e.g. 10.0.1.2:49128", "", &phost}, }, Action: onAction, } @@ -24,7 +26,7 @@ func onAction(c *cli.Context) { var offCommand = cli.Command{ Name: "off", Flags: []cli.Flag{ - cli.StringFlag{"host", "", "device host and ip e.g. 10.0.1.2:49128", ""}, + cli.StringFlag{"host", "", "device host and ip e.g. 10.0.1.2:49128", "", &phost}, }, Action: offAction, } @@ -40,7 +42,7 @@ func offAction(c *cli.Context) { var toggleCommand = cli.Command{ Name: "toggle", Flags: []cli.Flag{ - cli.StringFlag{"host", "", "device host and ip e.g. 10.0.1.2:49128", ""}, + cli.StringFlag{"host", "", "device host and ip e.g. 10.0.1.2:49128", "", &phost}, }, Action: toggleAction, } From f258fbcaaea4f21f7ac73f73d7ba6038c773ae47 Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 10:35:02 -0700 Subject: [PATCH 04/21] Enable testing using go get in localized fork --- README.md | 8 ++++---- wemo/discover.go | 2 +- wemo/power.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2cc582b..6cb1e52 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ go.wemo ======= -[![GoDoc](http://godoc.org/github.com/savaki/go.wemo?status.png)](http://godoc.org/github.com/savaki/go.wemo) +[![GoDoc](http://godoc.org/github.com/andrewpurkett/go.wemo?status.png)](http://godoc.org/github.com/andrewpurkett/go.wemo) [![Build Status](https://snap-ci.com/savaki/go.wemo/branch/master/build_image)](https://snap-ci.com/savaki/go.wemo/branch/master) Simple package to interface with Belkin wemo devices. @@ -13,7 +13,7 @@ package main import ( "fmt" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" "time" ) @@ -33,7 +33,7 @@ package main import ( "fmt" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" ) func main() { @@ -61,7 +61,7 @@ As a convenience method, you can control lights through a more generic interface package main import ( - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" "time" ) diff --git a/wemo/discover.go b/wemo/discover.go index 88c7e02..b068639 100644 --- a/wemo/discover.go +++ b/wemo/discover.go @@ -4,7 +4,7 @@ import ( "code.google.com/p/go.net/context" "fmt" "github.com/codegangsta/cli" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" "log" "sort" "time" diff --git a/wemo/power.go b/wemo/power.go index adb0550..81afa80 100644 --- a/wemo/power.go +++ b/wemo/power.go @@ -2,7 +2,7 @@ package main import ( "github.com/codegangsta/cli" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" ) var phost; From f086c92aaa81d465a47bf267497535f60b89467d Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 10:56:28 -0700 Subject: [PATCH 05/21] Fixes for cli usage applied after testing in named fork --- wemo/discover.go | 20 +++++++++++++------- wemo/main.go | 2 +- wemo/power.go | 23 ++++++++++++++++++----- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/wemo/discover.go b/wemo/discover.go index 88c7e02..66929aa 100644 --- a/wemo/discover.go +++ b/wemo/discover.go @@ -10,17 +10,23 @@ import ( "time" ) -// cli.Flag requires an additional pointer argument -var giface, gip, gtimeout; - var discoverCommand = cli.Command{ Name: "discover", Usage: "find devices in the local network", Description: "search for devices in the local network", Flags: []cli.Flag{ - cli.StringFlag{"interface", "", "search by interface", "", &piface}, - cli.StringFlag{"ip", "", "discovery wemo by ip", "", &pip}, - cli.IntFlag{"timeout", 3, "timeout", "", &ptimeout}, + cli.StringFlag{ + Name: "interface", + Value: "", + Usage: "search by interface", + EnvVar: "WEMO_IFACE", + }, + cli.IntFlag{ + Name: "timeout", + Value: 3, + Usage: "timeout period in seconds", + EnvVar: "WEMO_TIMEOUT_DISCOVERY", + }, }, Action: commandAction, } @@ -68,7 +74,7 @@ func commandAction(c *cli.Context) { for _, deviceInfo := range deviceInfos { fmt.Printf(format, deviceInfo.Device.Host, - deviceinfo.MacAddress, + deviceInfo.MacAddress, deviceInfo.FriendlyName, deviceInfo.FirmwareVersion, deviceInfo.SerialNumber) diff --git a/wemo/main.go b/wemo/main.go index ffbea44..9e4853b 100644 --- a/wemo/main.go +++ b/wemo/main.go @@ -22,7 +22,7 @@ func main() { app := cli.NewApp() app.Name = "wemo" app.Usage = "command line interface wemo" - app.Version = "0.1" + app.Version = "0.2" app.Commands = []cli.Command{ discoverCommand, onCommand, diff --git a/wemo/power.go b/wemo/power.go index adb0550..15489a3 100644 --- a/wemo/power.go +++ b/wemo/power.go @@ -5,12 +5,15 @@ import ( "github.com/savaki/go.wemo" ) -var phost; - var onCommand = cli.Command{ Name: "on", Flags: []cli.Flag{ - cli.StringFlag{"host", "", "device host and ip e.g. 10.0.1.2:49128", "", &phost}, + cli.StringFlag{ + Name: "host", + Value: "", + Usage: "device host and ip e.g. 10.0.1.2:49128", + EnvVar: "WEMO_POWER_HOST", + }, }, Action: onAction, } @@ -26,7 +29,12 @@ func onAction(c *cli.Context) { var offCommand = cli.Command{ Name: "off", Flags: []cli.Flag{ - cli.StringFlag{"host", "", "device host and ip e.g. 10.0.1.2:49128", "", &phost}, + cli.StringFlag{ + Name: "host", + Value: "", + Usage: "device host and ip e.g. 10.0.1.2:49128", + EnvVar: "WEMO_POWER_HOST", + }, }, Action: offAction, } @@ -42,7 +50,12 @@ func offAction(c *cli.Context) { var toggleCommand = cli.Command{ Name: "toggle", Flags: []cli.Flag{ - cli.StringFlag{"host", "", "device host and ip e.g. 10.0.1.2:49128", "", &phost}, + cli.StringFlag{ + Name: "host", + Value: "", + Usage: "device host and ip e.g. 10.0.1.2:49128", + EnvVar: "WEMO_POWER_HOST", + }, }, Action: toggleAction, } From 44f658f379a12fac92c506f73e02090e9e01fb79 Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 10:35:02 -0700 Subject: [PATCH 06/21] Enable testing using go get in localized fork --- README.md | 8 ++++---- wemo/discover.go | 2 +- wemo/power.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2cc582b..6cb1e52 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ go.wemo ======= -[![GoDoc](http://godoc.org/github.com/savaki/go.wemo?status.png)](http://godoc.org/github.com/savaki/go.wemo) +[![GoDoc](http://godoc.org/github.com/andrewpurkett/go.wemo?status.png)](http://godoc.org/github.com/andrewpurkett/go.wemo) [![Build Status](https://snap-ci.com/savaki/go.wemo/branch/master/build_image)](https://snap-ci.com/savaki/go.wemo/branch/master) Simple package to interface with Belkin wemo devices. @@ -13,7 +13,7 @@ package main import ( "fmt" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" "time" ) @@ -33,7 +33,7 @@ package main import ( "fmt" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" ) func main() { @@ -61,7 +61,7 @@ As a convenience method, you can control lights through a more generic interface package main import ( - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" "time" ) diff --git a/wemo/discover.go b/wemo/discover.go index 66929aa..67c7cad 100644 --- a/wemo/discover.go +++ b/wemo/discover.go @@ -4,7 +4,7 @@ import ( "code.google.com/p/go.net/context" "fmt" "github.com/codegangsta/cli" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" "log" "sort" "time" diff --git a/wemo/power.go b/wemo/power.go index 15489a3..531c4b4 100644 --- a/wemo/power.go +++ b/wemo/power.go @@ -2,7 +2,7 @@ package main import ( "github.com/codegangsta/cli" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" ) var onCommand = cli.Command{ From c61e14434ca5d0fc94bc50e996ca4f4ad69bdfc7 Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 11:03:46 -0700 Subject: [PATCH 07/21] Enable shorthand notation --- wemo/discover.go | 2 ++ wemo/power.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/wemo/discover.go b/wemo/discover.go index 66929aa..16662a3 100644 --- a/wemo/discover.go +++ b/wemo/discover.go @@ -17,12 +17,14 @@ var discoverCommand = cli.Command{ Flags: []cli.Flag{ cli.StringFlag{ Name: "interface", + Aliases: []string{"i"}, Value: "", Usage: "search by interface", EnvVar: "WEMO_IFACE", }, cli.IntFlag{ Name: "timeout", + Aliases: []string{"t"}, Value: 3, Usage: "timeout period in seconds", EnvVar: "WEMO_TIMEOUT_DISCOVERY", diff --git a/wemo/power.go b/wemo/power.go index 15489a3..bc2deae 100644 --- a/wemo/power.go +++ b/wemo/power.go @@ -10,6 +10,7 @@ var onCommand = cli.Command{ Flags: []cli.Flag{ cli.StringFlag{ Name: "host", + Aliases: []string{"h"}, Value: "", Usage: "device host and ip e.g. 10.0.1.2:49128", EnvVar: "WEMO_POWER_HOST", @@ -31,6 +32,7 @@ var offCommand = cli.Command{ Flags: []cli.Flag{ cli.StringFlag{ Name: "host", + Aliases: []string{"h"}, Value: "", Usage: "device host and ip e.g. 10.0.1.2:49128", EnvVar: "WEMO_POWER_HOST", @@ -52,6 +54,7 @@ var toggleCommand = cli.Command{ Flags: []cli.Flag{ cli.StringFlag{ Name: "host", + Aliases: []string{"h"}, Value: "", Usage: "device host and ip e.g. 10.0.1.2:49128", EnvVar: "WEMO_POWER_HOST", From 8eecbfb94ee48b757426b6f55aad9e338cdb60ed Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 11:06:31 -0700 Subject: [PATCH 08/21] Revert "Enable shorthand notation" Shorthand notation does not appear to work on flags in the cli library This reverts commit c61e14434ca5d0fc94bc50e996ca4f4ad69bdfc7. --- wemo/discover.go | 2 -- wemo/power.go | 3 --- 2 files changed, 5 deletions(-) diff --git a/wemo/discover.go b/wemo/discover.go index 16662a3..66929aa 100644 --- a/wemo/discover.go +++ b/wemo/discover.go @@ -17,14 +17,12 @@ var discoverCommand = cli.Command{ Flags: []cli.Flag{ cli.StringFlag{ Name: "interface", - Aliases: []string{"i"}, Value: "", Usage: "search by interface", EnvVar: "WEMO_IFACE", }, cli.IntFlag{ Name: "timeout", - Aliases: []string{"t"}, Value: 3, Usage: "timeout period in seconds", EnvVar: "WEMO_TIMEOUT_DISCOVERY", diff --git a/wemo/power.go b/wemo/power.go index bc2deae..15489a3 100644 --- a/wemo/power.go +++ b/wemo/power.go @@ -10,7 +10,6 @@ var onCommand = cli.Command{ Flags: []cli.Flag{ cli.StringFlag{ Name: "host", - Aliases: []string{"h"}, Value: "", Usage: "device host and ip e.g. 10.0.1.2:49128", EnvVar: "WEMO_POWER_HOST", @@ -32,7 +31,6 @@ var offCommand = cli.Command{ Flags: []cli.Flag{ cli.StringFlag{ Name: "host", - Aliases: []string{"h"}, Value: "", Usage: "device host and ip e.g. 10.0.1.2:49128", EnvVar: "WEMO_POWER_HOST", @@ -54,7 +52,6 @@ var toggleCommand = cli.Command{ Flags: []cli.Flag{ cli.StringFlag{ Name: "host", - Aliases: []string{"h"}, Value: "", Usage: "device host and ip e.g. 10.0.1.2:49128", EnvVar: "WEMO_POWER_HOST", From b0ab2b8530e0bbf53ad84a5b314793d0b9124fc4 Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 12:02:55 -0700 Subject: [PATCH 09/21] Discovery interface cleanup --- wemo/discover.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/wemo/discover.go b/wemo/discover.go index 66929aa..5a3e650 100644 --- a/wemo/discover.go +++ b/wemo/discover.go @@ -45,20 +45,20 @@ func commandAction(c *cli.Context) { log.Fatal(err) } - format := "%-20s %-20s %-20s %-21s %-20s\n" + format := "%-22s %-13s %-15s %-31s %-35s\n" fmt.Printf(format, "Host", "Mac Address", + "Serial Number", "Friendly Name", "Firmware Version", - "Serial Number", ) fmt.Printf(format, - "----------------", - "----------------", - "----------------", - "----------------", - "----------------", + "---------------------", + "------------", + "--------------", + "------------------------------", + "-----------------------------------", ) deviceInfos := wemo.DeviceInfos{} @@ -75,8 +75,8 @@ func commandAction(c *cli.Context) { fmt.Printf(format, deviceInfo.Device.Host, deviceInfo.MacAddress, + deviceInfo.SerialNumber, deviceInfo.FriendlyName, - deviceInfo.FirmwareVersion, - deviceInfo.SerialNumber) + deviceInfo.FirmwareVersion) } } From cc7d477e5457bbc01ec009be870a8cf45a27bf85 Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 13:22:00 -0700 Subject: [PATCH 10/21] Add function to correct offset mac addresses and break test intentionally so someone will implement the function call at the appropriate line --- device.go | 8 ++++++++ device_test.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/device.go b/device.go index 10cb4cf..91c9aa7 100644 --- a/device.go +++ b/device.go @@ -24,6 +24,7 @@ import ( "net/http" "regexp" "strconv" + "math/big" ) type Device struct { @@ -82,6 +83,13 @@ func (d *Device) FetchDeviceInfo(ctx context.Context) (*DeviceInfo, error) { return deviceInfo, nil } +func IncrementMacAddress(inputMac string) (string) { + p1:=big.NewInt(0) + p1.SetString(inputMac, 16) + p1 = big.NewInt(0).Add(p1, big.NewInt(1)) + return fmt.Sprintf("%0x", p1) +} + func (d *Device) GetBinaryState() int { message := newGetBinaryStateMessage() response, err := post(d.Host, "GetBinaryState", message) diff --git a/device_test.go b/device_test.go index 77ccd19..22ce555 100644 --- a/device_test.go +++ b/device_test.go @@ -46,7 +46,7 @@ func TestParseResponseXML(t *testing.T) { 221248K0102C92 uuid:Socket-1_0-221248K0102C92 123456789 - EC1A5974B1EC + EC1A5974B1EB WeMo_US_2.00.2769.PVT 0|49153 1 From 303ec040172d63c4f0494dbfde4bfaf2f2d0e837 Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 13:56:33 -0700 Subject: [PATCH 11/21] Fix intentionally failing test --- device.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/device.go b/device.go index 91c9aa7..a193acd 100644 --- a/device.go +++ b/device.go @@ -61,6 +61,7 @@ func unmarshalDeviceInfo(data []byte) (*DeviceInfo, error) { if err != nil { return nil, err } + resp.DeviceInfo.MacAddress = IncrementMacAddress(resp.DeviceInfo.MacAddress) return &resp.DeviceInfo, nil } @@ -87,7 +88,7 @@ func IncrementMacAddress(inputMac string) (string) { p1:=big.NewInt(0) p1.SetString(inputMac, 16) p1 = big.NewInt(0).Add(p1, big.NewInt(1)) - return fmt.Sprintf("%0x", p1) + return fmt.Sprintf("%0X", p1) } func (d *Device) GetBinaryState() int { From 3043e1fc4b63e7adc08f91fb0f8797b7fa6e45fe Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 15:00:06 -0700 Subject: [PATCH 12/21] Show mac address column --- wemo/discover.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wemo/discover.go b/wemo/discover.go index 5a3e650..8b1d5d1 100644 --- a/wemo/discover.go +++ b/wemo/discover.go @@ -45,7 +45,7 @@ func commandAction(c *cli.Context) { log.Fatal(err) } - format := "%-22s %-13s %-15s %-31s %-35s\n" + format := "%-22s %-18s %-15s %-26s %-35s\n" fmt.Printf(format, "Host", "Mac Address", @@ -55,9 +55,9 @@ func commandAction(c *cli.Context) { ) fmt.Printf(format, "---------------------", - "------------", + "-----------------", "--------------", - "------------------------------", + "-------------------------", "-----------------------------------", ) @@ -74,7 +74,7 @@ func commandAction(c *cli.Context) { for _, deviceInfo := range deviceInfos { fmt.Printf(format, deviceInfo.Device.Host, - deviceInfo.MacAddress, + fmt.Sprintf("%s:%s:%s:%s:%s:%s", deviceInfo.MacAddress[0:2], deviceInfo.MacAddress[2:4], deviceInfo.MacAddress[4:6], deviceInfo.MacAddress[6:8], deviceInfo.MacAddress[8:10], deviceInfo.MacAddress[10:12]), deviceInfo.SerialNumber, deviceInfo.FriendlyName, deviceInfo.FirmwareVersion) From 670b9aecd85b520490212f7c523bdcc112cc0471 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 5 Jan 2016 16:02:59 -0700 Subject: [PATCH 13/21] Update README to include new golang user guide --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index 2cc582b..02866e2 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,42 @@ go.wemo Simple package to interface with Belkin wemo devices. +## Standalone Usage Guide + +Install the go library and configure it as needed, ensuring `~/bin/src/` is in your `GOPATH` environment variable. + +Run the following command from `~/bin/src/`: + +`go get https://github.com/savaki/go.wemo` + +navigate into the new directory: + +`cd ~/bin/src/github.com/savaki/go.wemo` + +Run `go get` to retrieve dependencies + +navigate into the example usage directory: + +`cd ~/bin/src/github.com/savaki/go.wemo/wemo` + +Run `go get` again to retrieve dependencies for the example usage directory + +Build the example usage tool: + +`go build` + +Then refer to the command line tool to see sample usage: + +`~/bin/src/github.com/savaki/go.wemo/wemo/wemo` + +`~/bin/src/github.com/savaki/go.wemo/wemo/wemo discover -h` + +If you were unable to build the CLI tool, run `go test` (in both `~/bin/src/github.com/savaki/go.wemo/wemo` and `~/bin/src/github.com/savaki/go.wemo/`), check your `GOPATH`, `GOROOT`, and repeat any other golang setup steps required. + +## Utilizing the library in projects + +Here is some example usage of the various functionality incorporated in this go repository: + ### Example - Device discovery ``` From f37d37db867621a87983e0701d0554dc1f03df46 Mon Sep 17 00:00:00 2001 From: Andrew Purkett Date: Tue, 5 Jan 2016 10:35:02 -0700 Subject: [PATCH 14/21] Enable testing using go get in localized fork --- README.md | 8 ++++---- wemo/discover.go | 2 +- wemo/power.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 02866e2..d46cd34 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ go.wemo ======= -[![GoDoc](http://godoc.org/github.com/savaki/go.wemo?status.png)](http://godoc.org/github.com/savaki/go.wemo) +[![GoDoc](http://godoc.org/github.com/andrewpurkett/go.wemo?status.png)](http://godoc.org/github.com/andrewpurkett/go.wemo) [![Build Status](https://snap-ci.com/savaki/go.wemo/branch/master/build_image)](https://snap-ci.com/savaki/go.wemo/branch/master) Simple package to interface with Belkin wemo devices. @@ -49,7 +49,7 @@ package main import ( "fmt" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" "time" ) @@ -69,7 +69,7 @@ package main import ( "fmt" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" ) func main() { @@ -97,7 +97,7 @@ As a convenience method, you can control lights through a more generic interface package main import ( - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" "time" ) diff --git a/wemo/discover.go b/wemo/discover.go index 8b1d5d1..b7e892a 100644 --- a/wemo/discover.go +++ b/wemo/discover.go @@ -4,7 +4,7 @@ import ( "code.google.com/p/go.net/context" "fmt" "github.com/codegangsta/cli" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" "log" "sort" "time" diff --git a/wemo/power.go b/wemo/power.go index 15489a3..531c4b4 100644 --- a/wemo/power.go +++ b/wemo/power.go @@ -2,7 +2,7 @@ package main import ( "github.com/codegangsta/cli" - "github.com/savaki/go.wemo" + "github.com/andrewpurkett/go.wemo" ) var onCommand = cli.Command{ From d3d64a17c666bc609bba70a52121d7ddb8328a1f Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 5 Jan 2016 16:20:36 -0700 Subject: [PATCH 15/21] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d46cd34..df3ac8e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ go.wemo ======= [![GoDoc](http://godoc.org/github.com/andrewpurkett/go.wemo?status.png)](http://godoc.org/github.com/andrewpurkett/go.wemo) -[![Build Status](https://snap-ci.com/savaki/go.wemo/branch/master/build_image)](https://snap-ci.com/savaki/go.wemo/branch/master) +[![Build Status](https://snap-ci.com/andrewpurkett/go.wemo/branch/master/build_image)](https://snap-ci.com/andrewpurkett/go.wemo/branch/master) Simple package to interface with Belkin wemo devices. @@ -12,17 +12,17 @@ Install the go library and configure it as needed, ensuring `~/bin/src/` is in y Run the following command from `~/bin/src/`: -`go get https://github.com/savaki/go.wemo` +`go get https://github.com/andrewpurkett/go.wemo` navigate into the new directory: -`cd ~/bin/src/github.com/savaki/go.wemo` +`cd ~/bin/src/github.com/andrewpurkett/go.wemo` Run `go get` to retrieve dependencies navigate into the example usage directory: -`cd ~/bin/src/github.com/savaki/go.wemo/wemo` +`cd ~/bin/src/github.com/andrewpurkett/go.wemo/wemo` Run `go get` again to retrieve dependencies for the example usage directory @@ -32,11 +32,11 @@ Build the example usage tool: Then refer to the command line tool to see sample usage: -`~/bin/src/github.com/savaki/go.wemo/wemo/wemo` +`~/bin/src/github.com/andrewpurkett/go.wemo/wemo/wemo` -`~/bin/src/github.com/savaki/go.wemo/wemo/wemo discover -h` +`~/bin/src/github.com/andrewpurkett/go.wemo/wemo/wemo discover -h` -If you were unable to build the CLI tool, run `go test` (in both `~/bin/src/github.com/savaki/go.wemo/wemo` and `~/bin/src/github.com/savaki/go.wemo/`), check your `GOPATH`, `GOROOT`, and repeat any other golang setup steps required. +If you were unable to build the CLI tool, run `go test` (in both `~/bin/src/github.com/andrewpurkett/go.wemo/wemo` and `~/bin/src/github.com/andrewpurkett/go.wemo/`), check your `GOPATH`, `GOROOT`, and repeat any other golang setup steps required. ## Utilizing the library in projects From 00eacc503f5fe6dfc31205458a6cc86c5d4d49f0 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 5 Jan 2016 16:22:37 -0700 Subject: [PATCH 16/21] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index df3ac8e..4b477a2 100644 --- a/README.md +++ b/README.md @@ -8,21 +8,21 @@ Simple package to interface with Belkin wemo devices. ## Standalone Usage Guide -Install the go library and configure it as needed, ensuring `~/bin/src/` is in your `GOPATH` environment variable. +Install the go library and configure it as needed, ensuring `~/bin/go/src/` is in your `GOPATH` environment variable. -Run the following command from `~/bin/src/`: +Run the following command from `~/bin/go/src/`: `go get https://github.com/andrewpurkett/go.wemo` navigate into the new directory: -`cd ~/bin/src/github.com/andrewpurkett/go.wemo` +`cd ~/bin/go/src/github.com/andrewpurkett/go.wemo` Run `go get` to retrieve dependencies navigate into the example usage directory: -`cd ~/bin/src/github.com/andrewpurkett/go.wemo/wemo` +`cd ~/bin/go/src/github.com/andrewpurkett/go.wemo/wemo` Run `go get` again to retrieve dependencies for the example usage directory @@ -32,11 +32,11 @@ Build the example usage tool: Then refer to the command line tool to see sample usage: -`~/bin/src/github.com/andrewpurkett/go.wemo/wemo/wemo` +`~/bin/go/src/github.com/andrewpurkett/go.wemo/wemo/wemo` -`~/bin/src/github.com/andrewpurkett/go.wemo/wemo/wemo discover -h` +`~/bin/go/src/github.com/andrewpurkett/go.wemo/wemo/wemo discover -h` -If you were unable to build the CLI tool, run `go test` (in both `~/bin/src/github.com/andrewpurkett/go.wemo/wemo` and `~/bin/src/github.com/andrewpurkett/go.wemo/`), check your `GOPATH`, `GOROOT`, and repeat any other golang setup steps required. +If you were unable to build the CLI tool, run `go test` (in both `~/bin/go/src/github.com/andrewpurkett/go.wemo/wemo` and `~/bin/go/src/github.com/andrewpurkett/go.wemo/`), check your `GOPATH`, `GOROOT`, and repeat any other golang setup steps required. ## Utilizing the library in projects From da21c622c306f0fd24fa06122849e2f2cc2444ad Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 5 Jan 2016 16:23:46 -0700 Subject: [PATCH 17/21] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 4b477a2..a3a8b3a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ go.wemo ======= [![GoDoc](http://godoc.org/github.com/andrewpurkett/go.wemo?status.png)](http://godoc.org/github.com/andrewpurkett/go.wemo) -[![Build Status](https://snap-ci.com/andrewpurkett/go.wemo/branch/master/build_image)](https://snap-ci.com/andrewpurkett/go.wemo/branch/master) Simple package to interface with Belkin wemo devices. From 31347cdad73d75bc5e30e27994d9c165789ffd34 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 5 Jan 2016 16:36:21 -0700 Subject: [PATCH 18/21] Add example screenshot --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a3a8b3a..04bb12d 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ Then refer to the command line tool to see sample usage: `~/bin/go/src/github.com/andrewpurkett/go.wemo/wemo/wemo discover -h` +![Example usage](https://i.imgur.com/UYI2E4F.png) + If you were unable to build the CLI tool, run `go test` (in both `~/bin/go/src/github.com/andrewpurkett/go.wemo/wemo` and `~/bin/go/src/github.com/andrewpurkett/go.wemo/`), check your `GOPATH`, `GOROOT`, and repeat any other golang setup steps required. ## Utilizing the library in projects From 2824f7274de8faca8f0d4268e58fc4c6ec7291be Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 5 Jan 2016 16:37:24 -0700 Subject: [PATCH 19/21] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 04bb12d..9c515e4 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ navigate into the new directory: `cd ~/bin/go/src/github.com/andrewpurkett/go.wemo` +To use this fork, run `git checkout forktest`, now, to avoid any conflicts. + Run `go get` to retrieve dependencies navigate into the example usage directory: From 1ef0dee23c7e1bb2b4d4b47e40971a53b1db0109 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 5 Jan 2016 16:42:44 -0700 Subject: [PATCH 20/21] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9c515e4..795ef80 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ go.wemo Simple package to interface with Belkin wemo devices. +Please utilize the branch [forktest](https://github.com/andrewpurkett/go.wemo/tree/forktest) until a pull request has been submitted for the changes to this library, due to the nature of how go imports libraries. + ## Standalone Usage Guide Install the go library and configure it as needed, ensuring `~/bin/go/src/` is in your `GOPATH` environment variable. From e88edabcf9f072f487c6b05a6017f0460c2965f9 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 5 Jan 2016 16:43:14 -0700 Subject: [PATCH 21/21] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 795ef80..9c515e4 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ go.wemo Simple package to interface with Belkin wemo devices. -Please utilize the branch [forktest](https://github.com/andrewpurkett/go.wemo/tree/forktest) until a pull request has been submitted for the changes to this library, due to the nature of how go imports libraries. - ## Standalone Usage Guide Install the go library and configure it as needed, ensuring `~/bin/go/src/` is in your `GOPATH` environment variable.