• Stars
    star
    198
  • Rank 195,697 (Top 4 %)
  • Language
  • License
    MIT License
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Star this repo to add some sparkle to my tree

Smart Xmas

Sparkle Status

A simple project showing you how to easily control smart devices in your home from GitHub Actions and put a bit of ✨ into your repos.

YouTube video tutorial

Prerequisites

  • Smart power strip [UK] [US]
  • IFTTT.com account
  • Thing to power - i.e. fairy lights, the gaudier and over the top the better

(Optional) If you want to trigger sound with you lights then:

Configuration

First of all set up your smart power strip using instructions from your vendor. Lots of the inexpensive unbranded smart devices are OEM devices making using of the Tuya cloud network. (The 'Smart Life' application used by many of these is a particularly common front-end to the Tuya API). Regardless of the provider, look for compatibility with IFTTT as that is how we are going to drive it.

Nearly all the applications will allow you to configure scenes or automation that happens on a trigger or when manually triggered (i.e. 'tap to run'). I created a scene called TreeAnimate which simply switches on all the power to the power strip, waits 30 seconds and then switches it all off again. However depending on your smart device you can do a lot more if you wanted, for example adjust the color of your RGB lighting, switch on a lava lamp or confetti filled leaf-blower etc.

Smartlife Scene Configuration

If you want a sound to accompany your activity then the easiest way to do this is to hook up an inexpensive sound-board from Adafruit. It's a simple device that shows up as a mass storage device when you connect it to your computer. You upload files using a particular naming convention and then they play when the trigger pin is connected to ground.

Smartlife Scene Configuration

See the Adafruit product tutorial for more information. For our purposes we'll just wire tigger pin 0 so that it's permanently connected to ground and that way it will automatically start playing the sound as soon as there is power to the device.

If Kevin had access to these imagine what a different movie Home Alone would have been - wonder how Disney if going to address that in the reboot?.

Animated Gif of Home Alone movie

IFTTT Configuration

Next up, we need to configure IFTTT to set off our TreeAnimate scene when it recieves a webhook.

The reason we're using IFTTT is that most smart device manufacturers already integrate with it. If you are wanting to configure a Tuya.com based smart device from code directly then take a look at the tuyapi project maintained by Max Ison - however that relies on being in the same network at the device itself and we want to be able to trigger your device from GitHub's Action servers running in the cloud.

  1. Create an account with IFTTT then follow your manufacturers instructions for configuring and authenticating your smart service with IFTTT.

  2. Next, create your IFTTT workflow. For the this trigger select Webhooks, then 'recieve web request' and give your event a name. I rather unimaginative called mine do_hook

IFTTT Trigger

  1. For the that action, select your smart device vendor and then select the scene you wish to activate. In my case TreeAnimate

IFTTT Action

  1. Next you'll need the URL (with key) that we need to trigger the webhook. Go to the Maker Webhooks service and select 'Documentation' in the top right land side. IFTTT webhooks are triggered using the following URL pattern:
https://maker.ifttt.com/trigger/{EVENT}/with/key/{KEY}

In our example, the event is do_hook. We want copy the key value and store it as a repository secret in our repo.

IFTTT Action

GitHub Action Configuration

  1. The in GitHub project you want to automate, go to 'Settings', then 'Secrets' and 'Add a new secret' For the key name use IFTTT_KEY and paste the key value from IFTTT.

  2. Then in the project select 'Actions' and select 'New worfflow'.

  3. In the top right hand side, select 'Set up a workflow yourself'. Name the file something meaningful (I called mine sparkle.yml). The workflow itself is very simple. It simply uses curl to trigger the webhook when someone stars the repo in GitHub.

name: sparkle

on: [watch]

jobs:
 sparkle:

   runs-on: ubuntu-latest

   steps:
   - name: Call IFTTT to trigger lights
     run: curl -X POST https://maker.ifttt.com/trigger/do_hook/with/key/${{ secrets.IFTTT_KEY }}

Hit commit and you are ready to go.

Extensions

While I did this one for fun just because I wanted a bit of holiday sparkle to cheer up a gloomy evening, you can use the same mechanism to trigger anything. With the use of conditional workflow steps you coudld easily turn the lights red and sound an alert when the build fails. Or maybe something less stressful and turn down the lights and play some nice gentle music anytime someone leaves a sparkly heart in response to your pull request. You can easily get the scenes to trigger multiple devices all around your office.

More Repositories

1

octolamp

A 3D printed, GitHub infused, smart light
497
star
2

DasDeployer

Raspberry Pi powered manual release approval gate for Azure Pipelines. Mit viele blinkenlighten
Python
92
star
3

PumpkinPi

Spooky build status indicator
Python
74
star
4

devrel

Come help people learn how to GitHub ✨
46
star
5

csharpworkshop

Workshop content on Learning C# on Linux using .NET Core
C#
33
star
6

covid-19-projects

List for tracking covid-19 related projects
23
star
7

dotnetweb

Mona+Dotnetbot-say
C#
17
star
8

rpi-cluster

Brief instructions about the Raspberry Pi Cluster you might see in my background on calls
14
star
9

OssAwesomenessTabulator

Azure Webjob that pulls together stats about OSS Activity into a couple of handy json files.
C#
7
star
10

pideploy

Python
6
star
11

hotkeys

Personal fork of Adafruit Macropad hotkeys example
Python
4
star
12

octo64

Commodore 64 in GitHub Pages powered by Vice.js
JavaScript
4
star
13

readme

A collection of tips for creating a good ReadMe
4
star
14

hello64

A Hello World from my childhood
Assembly
3
star
15

trinkey

Trinkey examples
Python
2
star
16

snake0417

Snake demo
JavaScript
2
star
17

rizeltest

This is test repo
2
star
18

sparklepi

JavaScript
2
star
19

beastmatch

Swift
1
star
20

gitsync

Example repo showing how to mirror your GitHub repo with another service (in this example Azure Repos)
1
star
21

pourlaurent

1
star
22

martin_public

1
star
23

dotfiles

Personal dotfiles
Shell
1
star
24

GitHub-Hackathons

Tips, Tricks, and Resources for your hackathons.
1
star
25

prime

Simple .NET Core app
C#
1
star
26

snake

Basic snake game
JavaScript
1
star
27

martinwoodward

Martin Woodward's Profile
1
star
28

repo2

C#
1
star
29

PieLight

Quick hacky test code for my raspberry pi powered build light
Python
1
star
30

actions

Example action workflows
1
star
31

martin.social

My social links
JavaScript
1
star