Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random color not working #167

Closed
parasaurolophus opened this issue Apr 30, 2020 · 4 comments
Closed

Random color not working #167

parasaurolophus opened this issue Apr 30, 2020 · 4 comments
Labels

Comments

@parasaurolophus
Copy link

Describe the bug
Passing "random" as the value for "color" to a light node often fails. A few clicks on the inject node in the supplied flow shows that this long-standing bug is still present in 2.7.0.

Flow to Reproduce

[{"id":"c6b31d5b.017bb","type":"inject","z":"e483373d.aebfb8","name":"","topic":"","payload":"{\"on\":true,\"color\":\"random\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":320,"wires":[["c9bfe00e.6ec4f"]]},{"id":"c9bfe00e.6ec4f","type":"hue-light","z":"e483373d.aebfb8","name":"Floor Lamp","bridge":"d75a339d.b8a97","lightid":"9","colornamer":true,"skipevents":false,"x":310,"y":320,"wires":[[]]},{"id":"d75a339d.b8a97","type":"hue-bridge","z":"","name":"Hue Chez Nous","bridge":"192.168.86.21","key":"V7BxU8fI9bL2Pz7Mun4hBLG3g4CBTeaorkAc1uAH","interval":"3000","disableupdates":false}]

Expected behavior
Passing "random" as the value for "color" should work reliably.

Screenshots
random-color-bug

Please complete the following information:

  • NodeRED version: 1.0.6
  • NodeJS version: 12.16.3
  • Device running NodeRED: Raspberry Pi 3B+ (Raspbian buster)

Additional context
In case it jogs any thoughts about a fix, here is the jsonata expression I use as a work-around for this bug:

(
   $r:=$floor($random()*256);
   $g:=$floor($random()*256);
   $b:=$floor($random()*256);
   $l:=$floor(0.2126*$r + 0.7152*$g + 0.0722*$b);
   {
       "on":true,
       "rgb":[$r,$g,$b],
       "brightnessLevel":$l
   }
)
@Foddy
Copy link
Owner

Foddy commented Apr 30, 2020

Do you have the same issues with “any” instead of “random” for the parameter?

@parasaurolophus
Copy link
Author

parasaurolophus commented Apr 30, 2020

Correction: the same problem occurs with both "any" and "random"

Disregard:

Apparently not. :-) I didn't know "any" was a supported option. I was simply going by the documentation in the description pane where it indicates "random" is a valid value for "color"

Foddy pushed a commit that referenced this issue Jun 14, 2020
* Fixed a problem with "0" as topic in Hue Group nodes ([#166](#166))
* Fixed an issue with the active property on Hue Motion nodes ([#172](#172))
* Fixed a problem with "random" as a color command on Hue Group & Light nodes ([#167](#167))
* Dependency & readme updates
Foddy pushed a commit that referenced this issue Jun 14, 2020
* Fixed a problem with "0" as topic in Hue Group nodes ([#166](#166))
* Fixed an issue with the active property on Hue Motion nodes ([#172](#172))
* Fixed a problem with "random" as a color command on Hue Group & Light nodes ([#167](#167))
* Dependency & readme updates
@Foddy
Copy link
Owner

Foddy commented Jun 14, 2020

This weird error is finally fixed with the latest release. You can use "random" as well as "any" or "whatever" now as a color name to get a random color.

@Foddy Foddy closed this as completed Jun 14, 2020
@parasaurolophus
Copy link
Author

This error still occurs in 2.8.1

[
    {
        "id": "a3b87cd4.e67e9",
        "type": "inject",
        "z": "93ed4ec.16204b",
        "name": "8:{\"on\":true,\"color\":\"any\",\"brightness\":100}",
        "topic": "8",
        "payload": "{\"on\":true,\"color\":\"any\",\"brightness\":100}",
        "payloadType": "json",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 200,
        "y": 240,
        "wires": [
            [
                "cf7c76e6.8b8c48"
            ]
        ]
    },
    {
        "id": "cf7c76e6.8b8c48",
        "type": "hue-group",
        "z": "93ed4ec.16204b",
        "name": "",
        "bridge": "5a3e3ef6.ce10a",
        "groupid": "",
        "colornamer": true,
        "skipevents": false,
        "x": 450,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "5a3e3ef6.ce10a",
        "type": "hue-bridge",
        "z": "",
        "name": "Hue Chez Nous",
        "bridge": "192.168.86.21",
        "key": "vq9C66nmN2hrToNOMMgaxi90G8ExsyEHKDymxDKR",
        "interval": "3000",
        "disableupdates": false
    }
]

huemagic-any-bug
huemagic-version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants