I have the LEDBorg setup with the CheerLights project with the python script from I think it would be cool if I have a line of five or six pumpkins but I really don't want them all to show the same color. Is there anyway to edit this script to pull the 2nd, 3rd, 4th, and 5th from latest color? I would put the pumpkins in order so when the color changes the right most pumpkin will change to the latest color, and the 2nd to last color on the second pumpkin and so on. Any info would be appreciated. Have a great day everyone!!!

piborg's picture

Yes there is, it is actually fairly simple to change the script to get previous colours :)

First you need to change where the script looks for the colour. Find this line:

cheerlightsUrl = ''

and change it for this one:

cheerlightsUrl = ''

This will now grab a list of the colours which have been set instead of just the last colour name.

Next change the line which reads the data from

colourName =


colourData =

as it is more than just a single colour name.

The values held in colourData will look something like this:

2017-09-06 04:56:14 UTC,392704,cyan,#00FFFF
2017-09-06 05:00:28 UTC,392705,oldlace,#FDF5E6
2017-09-06 05:06:06 UTC,392706,oldlace,#FDF5E6
2017-09-06 05:07:18 UTC,392707,oldlace,#FDF5E6
2017-09-06 05:10:32 UTC,392708,red,#FF0000
2017-09-06 05:13:56 UTC,392709,red,#FF0000
2017-09-06 05:16:58 UTC,392710,red,#FF0000
2017-09-06 05:20:59 UTC,392711,pink,#FFC0CB
2017-09-06 05:23:49 UTC,392712,pink,#FFC0CB
2017-09-06 05:26:30 UTC,392713,pink,#FFC0CB
2017-09-06 05:31:29 UTC,392714,oldlace,#FDF5E6

The last thing to do is pick out the colour we want. Add these lines just before the if line:

colourChoice = colourData.split('\n')[1]
colourName = colourChoice.split(',')[2]

The first line of code takes the colourData value and gets a single line of text from it. The headings are line 0, the last colour set is line 1, the previous colour is line 2 and so on. Change the 1 for a larger value to get an older colour selection :)

The second line of code takes the chosen line of text and grabs the third column, the field1 value. This contains the same names the script already uses. It then puts this value into colourName, which is where the rest of the script expects to find it.

That should be all you need to get any number of colours you like. You can repeat the last two lines added to grab several colour names in the same script as well. For example:

colourChoice1 = colourData.split('\n')[1]
colourName1 = colourChoice.split(',')[2]
colourChoice2 = colourData.split('\n')[2]
colourName2 = colourChoice.split(',')[2]

would grab the last colour and the previous colour names as colourName1 and colourName2 respectively.

Subscribe to Comments for "CheerBorg"