diff --git a/README.md b/README.md index c1f0dbd..7731718 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,10 @@ Multiple commands can be used. Turn on a globe, set the color to RGB value #9400 `yeelight.exe -ip 10.1.1.15 -power on -rgb 9400d3 -brightness 100` +Set colour using CSS named colours. See [here](https://css-tricks.com/snippets/css/named-colors-and-hex-equivalents/) for a list of valid values. + +`yeelight.exe -ip 10.1.1.15 -css royalblue` + Linux example showing HSV usage `./yeelight-linux --ip=10.250.1.117 --hsvHue=120 --hsvSat=100 --effect=sudden` @@ -43,4 +47,4 @@ Linux example showing HSV usage - Initial release `1.1` -- Added CSS Named colour flag (`-css`). See [here](https://css-tricks.com/snippets/css/named-colors-and-hex-equivalents/) for a list of valid colours. \ No newline at end of file +- Added CSS Named colour flag (`-css`). \ No newline at end of file diff --git a/src/main.go b/src/main.go index 1577c16..3b3a2bd 100644 --- a/src/main.go +++ b/src/main.go @@ -7,6 +7,7 @@ import ( "net" "os" "strconv" + "strings" ) //go:generate go run scripts/includejson.go @@ -111,9 +112,10 @@ func main() { } css := cssInt.(map[string]interface{}) + colour := strings.ToLower(*cssPtr) - if css[*cssPtr] != nil { - var rgbValue string = css[*cssPtr].(string) + if css[colour] != nil { + var rgbValue string = css[colour].(string) var rgbDecimal string = hexToDec(rgbValue) message := "{\"id\":1,\"method\":\"set_rgb\",\"params\":[" + rgbDecimal + ",\"" + *effectPtr + "\"," + strconv.Itoa(*durationPtr) + "]}" send_message(*ipPtr, message)