Skip to content

Commit

Permalink
made css flag case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjx committed Oct 1, 2020
1 parent e5f7c3d commit fe7454b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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.
- Added CSS Named colour flag (`-css`).
6 changes: 4 additions & 2 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net"
"os"
"strconv"
"strings"
)

//go:generate go run scripts/includejson.go
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fe7454b

Please sign in to comment.