[RELEASE] Cheerlights Driver

So I am not a programmer, I don't even play one on TV. Ultimately this might end up as an app but for now this Device driver pulls the color and sets the hue and sat value for https://cheerlights.com/
I then take this data into RM variables and set different lights to these values.

Cheerlights can be a fun way to get help you feel connected when the world has been so isolated.

metadata {
    definition(name: "Cheerlights Color Sensor", namespace: "community", author: "Hasty") {
        capability "Sensor"
	    capability "Polling"
        attribute "color", "string"
        attribute "hue", "number"
        attribute "sat", "number"
    }
}

preferences {
    section("URIs") {
	    input name: 'updateSec', type: 'enum', description: "Select the update frequency", title: "Update frequency n0 is disabled", defaultValue: '15', options: ['0', '15', '30', '45','60'], required: true
        input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true
    }
}

def logsOff() {
    log.warn "debug logging disabled..."
    device.updateSetting("logEnable", [value: "false", type: "bool"])
}

def updated() {
    unschedule()
    log.info "updated..."
    log.warn "debug logging is: ${logEnable == true}"
    if (logEnable) runIn(1800, logsOff)
    if(updateSec != "0") {
        schedule("0/${updateSec} * * * * ? *", poll)
    }
    
}

def parse(String description) {
    if (logEnable) log.debug(description)
}

def poll() {
    if (logEnable) log.debug "polling..."
    String url = "http://api.thingspeak.com/channels/1417/field/1/last.txt"
    try {
       
        httpGet(url) { response ->
            String body = "${response.data}"
            if (logEnable) log.debug "${body}"
            sendEvent(name: "color", value: "${body}");
            switch ("${body}") {
                case "red": 
                    sendEvent(name: "hue", value: 0);
                    sendEvent(name: "sat", value: 100);
                    break;
               case "green": 
                    sendEvent(name: "hue", value: 30);
                    sendEvent(name: "sat", value: 100);
                    break;
                case "blue": 
                    sendEvent(name: "hue", value: 65);
                    sendEvent(name: "sat", value: 100);
                    break;
                case "cyan": 
                    sendEvent(name: "hue", value: 40);
                    sendEvent(name: "sat", value: 100);
                    break;
                case "white": 
                    sendEvent(name: "hue", value: 0);
                    sendEvent(name: "sat", value: 1);
                    break;
                case "oldlace": 
                    sendEvent(name: "hue", value: 9);
                    sendEvent(name: "sat", value: 60);
                    break;
                case "warmwhite": 
                    sendEvent(name: "hue", value: 9);
                    sendEvent(name: "sat", value: 60);
                    break;
                case "purple": 
                    sendEvent(name: "hue", value: 70);
                    sendEvent(name: "sat", value: 100);
                    break;
                case "magenta": 
                    sendEvent(name: "hue", value: 80);
                    sendEvent(name: "sat", value: 100);
                    break;
                case "yellow": 
                    sendEvent(name: "hue", value: 15);
                    sendEvent(name: "sat", value: 100);
                    break;
                case "orange": 
                    sendEvent(name: "hue", value: 7);
                    sendEvent(name: "sat", value: 100);
                    break;
                case "pink": 
                    sendEvent(name: "hue", value: 90);
                    sendEvent(name: "sat", value: 70);
                    break;
            }
            }
            
    } catch(Exception e) {
    	log.debug "error occured calling httpget ${e}"
    }
}

I welcome any feedback!

1 Like

I like the idea behind this if it's at all active on tweeter, but for this to be actually useful, it should be an app for sure with the possibility to select more than one color bulb.

Surprised no one else after 7 days showed interest in this idea!?

I did point out its existence to Hans (who created CheerLights).

I am a big fan of cheerlights and have been using them for years. They get really active at the end of November and then slow down in January.

If someone who has more skill can make this an app, or even show me some code that is similar in function to what I need. I would happy to help test/code it

Kind of swamped right now on another app and other stuff in my life, but if no one steps up, I might give it a try in a week or so. Should not be that hard, but then again never done anything that interacts with colored bulbs.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.