Google+ Followers

Friday, 27 July 2018

Amazon Dash Button Cheerlight Controller

I needed a way to control the cheerlights that could be useful for friends who didnt have or understand twitter.  Whilst to most of us sending the colour or a sentence with a colour included along with the hashtag cheerlights was the norm, I needed to simplify the process.

Firstly obtain an Amazon Dash Button, they are a fiver in uk money, but order the product that the button is for e.g. duracell order batteries, then you get your fiver back making it free.

next was to follow the instructions that come with the dash button, order those batteries (or whatever you chose the dash button to be) then delete the button before re installing it.  when you get to the point of choosing your product again just exit and turn off dash button notification as you dont want to be ordering more product everytime the button is pressed.

next was to write the code, I needed (and failed quite a few times to begin with) code that could look for the mac address of the amazon dash button on my network, after several tries and googling each bit of code that gave me errors I found and edited some lines and bingo the hello world message I had been looking for telling me the button had been pressed and the ip address of the router.

I then tried to incorporate a way that this could be tweeted and colour and went for a random message option where I had a dozen ready made sentences with a different colour mentioned in each followed by the hashtag.  I ended up using tweepy which is easily installed with a apt-get install python-tweepy and went to an old blog I had about a twitter camera I built for my wedding and hacked away at the code taking all the bits i needed and writing it to just tweet once when code was run and it worked.

Next was to merge both scripts into one and run it, bingo it worked and didnt send tons of messages either which was a main worry. 

Future work on this code will be to introduce a way to detect you are not tweeting the colour already in use and also not to tweet a previous colour as twitter doesnt like this.

My code can be found on git hub at