# Yeelight rainbow mode

**URL:** <https://discourse.nodered.org/t/yeelight-rainbow-mode/8585>\
**Category:** General\
**Created:** [4 March 2019 07:14 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585 "2019-03-04T07:14:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![shafirin](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@shafirin](https://discourse.nodered.org/u/shafirin)\
**Post date:** [4 March 2019 07:14 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585/1 "2019-03-04T07:14:45Z")

</div>

Hi guys I bought Yeelight and raspberry pi 3. Im using nodered node ,  
What I want is there somewhere to see how to make rainbow mode and I wish to use but how to? Btw this is my for my final year project.

I use [https://flows.nodered.org/node/node-red-contrib-yeelight-compat-hue](https://flows.nodered.org/node/node-red-contrib-yeelight-compat-hue) as my flow.  
Thanks in advance for your help, I really need it 🙂  
Shafirin

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 March 2019 09:29 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585/2 "2019-03-04T09:29:21Z")

</div>

Well since it is your final project, you must have already tried some things, so show us your flow (read [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/3)) tell what you have tried and what problems you are having.

I'm sure you will find lots of people here that will ask you questions that will help you figure this out yourself.

After all if someone else give you the answer, what would you have learned.

---

<div class="post-metadata">

**Author:** ![shafirin](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@shafirin](https://discourse.nodered.org/u/shafirin)\
**Post date:** [4 March 2019 10:19 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585/3 "2019-03-04T10:19:31Z")

</div>

Actually im not know well about the node-red and other programming. also, Im not familiar with these command. so, I tried to figure out myself before this, and I failed. that's why im asking the forum to find someone that can help me 🙂

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 March 2019 10:22 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585/4 "2019-03-04T10:22:49Z")

</div>

once again, what have you tried? Show us your current flow and explain what problem you have.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [4 March 2019 11:20 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585/5 "2019-03-04T11:20:15Z")

</div>

I've completed my final year project many years ago.  
We can help you, but it's you that need to complete your project.

So what have you tried? Even if it didn't work, we can suggest where you are going wrong.

---

<div class="post-metadata">

**Author:** ![shafirin](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@shafirin](https://discourse.nodered.org/u/shafirin)\
**Post date:** [5 March 2019 07:14 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585/6 "2019-03-05T07:14:37Z")

</div>

Okay, this is my 1st mode, that is rainbow effect (not complete). im don't know how to make the rainbow mode after that.

- I do some research, more of them using rgb code to make the rainbow. im using hex code color. when I tried to change hex to rgb, it show command error

```auto
[{"id":"c095d2b3.b127a","type":"function","z":"ab1042c8.676e2","name":"mode colours","func":"for(i=0;i<5;i++){\n\n var randomColor = Math.floor(Math.random()*16777215).toString(16);\n msg.payload='{\"on\": true, \"hex\": \"#'+randomColor+'\", \"sat\":0}' \n return msg\n}\n","outputs":1,"noerr":0,"x":740,"y":500,"wires":[["d83faa77.40a228"]]},{"id":"f546c651.0c1348","type":"ui_button","z":"ab1042c8.676e2","name":"","group":"d9540242.7d89d","order":5,"width":"6","height":"1","passthru":false,"label":"Rainbow Effect","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"str","topic":"","x":480,"y":500,"wires":[["c095d2b3.b127a"]]},{"id":"d83faa77.40a228","type":"delay","z":"ab1042c8.676e2","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":920,"y":500,"wires":[["f6776d0.4c63a9","915a6d66.fd89"]]},{"id":"f6776d0.4c63a9","type":"debug","z":"ab1042c8.676e2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1130,"y":500,"wires":[]},{"id":"fcae1b8e.804e98","type":"inject","z":"ab1042c8.676e2","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":540,"y":580,"wires":[["c095d2b3.b127a"]]},{"id":"d9540242.7d89d","type":"ui_group","z":"","name":"Easy Light Control","tab":"ac25b9b2.3319c8","order":1,"disp":true,"width":"6","collapse":false},{"id":"ac25b9b2.3319c8","type":"ui_tab","z":"","name":"Yeelight","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [5 March 2019 13:12 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585/7 "2019-03-05T13:12:07Z")

</div>

please read this [thread](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506) and then edit your latest post and fix it - your flow currently can not be imported

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [5 March 2019 13:18 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585/8 "2019-03-05T13:18:45Z")

</div>

It would also be useful if you can describe what you mean by rainbow effect as I would have thought randomly generating a colour was what you are after.

---

<div class="post-metadata">

**Author:** ![shafirin](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@shafirin](https://discourse.nodered.org/u/shafirin)\
**Post date:** [5 March 2019 13:42 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585/9 "2019-03-05T13:42:24Z")

</div>

for the rainbow effect, I mean something like this  
= [https://www.youtube.com/watch?v=gbjEqXABnas&t=31s](https://www.youtube.com/watch?v=gbjEqXABnas&t=31s)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [5 March 2019 14:27 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585/10 "2019-03-05T14:27:53Z")

</div>

Have you gone to the site referenced in the explaination of that video and looked at his code to see if you can use something like it with node-red-contrib-yeelight-compat-hue?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [5 March 2019 17:16 UTC](https://discourse.nodered.org/t/yeelight-rainbow-mode/8585/11 "2019-03-05T17:16:39Z")

</div>

You also create your msg.payload to be a string. Where I assume you want it to be an object?

`msg.payload='{"on": true, "hex": "#'+randomColor+'", "sat":0}'`

should be `msg.payload={"on": true, "hex": "#'+randomColor+'", "sat":0}`

But theres also a problem with the hex part of your msg.payload. Try googling  
"append to string variable javascript" and you should find the answer...
