I have a hacked together driver based on a device driver by Justin Wurth. Here is my bastardized version that is working for me.
// Copyright (c) <year>, <copyright holder>
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the <organization> nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
// * Redistribution of this software in source or binary forms shall be free
// of all charges or fees to the recipient of this software.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/**
* Spark Core
*
* Author: Justin Wurth
* Date: 2014-09-19
/**
*
*
*
*/
preferences {
input("deviceId", "text", title: "Device ID")
input("token", "text", title: "Access Token")
}
metadata {
definition (name: "Spark/Photon WS2812b", namespace: "jjhtpc", author: "Justin Wurth")
{capability "Switch Level"
capability "Color Control"
capability "Color Temperature"
capability "Switch"
capability "Refresh"
capability "Polling"
attribute "colorName", "string"
}
}
// tile definitions
command "Red"
command "Green"
command "Brown"
command "Gigem"
command "Broncos"
command "effect6"
tiles {
standardTile("switch", "device.switch", width: 1, height: 1, canChangeIcon: false) {
state "off", label: '${name}', action: "switch.on", icon: "st.Seasonal Winter.seasonal-winter-011", backgroundColor: "#ffffff"
state "on", label: '${name}', action: "switch.off", icon: "st.Seasonal Winter.seasonal-winter-011", backgroundColor: "#79b821", iconColor: "#ffffff"
}
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
}
standardTile("Red", "device.Red") {
state "Red", label: '${name}', action: "Red", icon: "st.Seasonal Winter.seasonal-winter-011", backgroundColor: "#d3ffd3", iconColor: "#ffffff"
}
standardTile("Green", "device.Green") {
state "Green", label: '${name}', action: "Green", icon: "st.Seasonal Winter.seasonal-winter-011", backgroundColor: "#d3ffd3", iconColor: "#ffffff"
}
standardTile("Brown", "device.Brown") {
state "Brown", label: '${name}', action: "Brown", icon: "st.Seasonal Winter.seasonal-winter-011", backgroundColor: "#d3ffd3", iconColor: "#ffffff"
}
standardTile("Gigem", "device.gigem") {
state "Gigem", label: '${name}', action: "Gigem", icon: "st.Seasonal Winter.seasonal-winter-011", backgroundColor: "#d3ffd3", iconColor: "#ffffff"
}
standardTile("Broncos", "device.Broncos") {
state "Broncos", label: '${name}', action: "Broncos", icon: "st.Seasonal Winter.seasonal-winter-011", backgroundColor: "#d3ffd3", iconColor: "#ffffff"
}
standardTile("effect6", "device.effect6") {
state "effect6", label: '${name}', action: "effect6", icon: "st.Seasonal Winter.seasonal-winter-011", backgroundColor: "#d3ffd3", iconColor: "#ffffff"
}
//standardTile("color", "device.color") {
//state "alert", label: '${name}', action: "tvdim", icon: "st.Lighting.light13", backgroundColor: "#ff0000", iconColor: "#ffffff"
//state "tvdim", label: '${name}', action: "moviedim", icon: "st.Lighting.light13", backgroundColor: "#d3d3d3", iconColor: "#ffffff"
//state "moviedim", label: '${name}', action: "alerts", icon: "st.Lighting.light13", backgroundColor: "#ffffff", iconColor: "#ffffff"
//}
controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 1, inactiveLabel: false, range:"(0..100)") {
state "level", action:"switch level.setLevel"
}
controlTile("rgbSelector", "device.color", "color", height: 3, width: 3, inactiveLabel: false) {
state "color", action:"setColor"
}
main(["switch"])
details(["switch", "Red", "Green", "Brown", "Gigem", "Broncos", "effect6","levelSliderControl", "refresh", "rgbSelector"])
}
def parse(String description) {
log.debug "This device does not support incoming events"
return null
}
def off(){
put '0'
sendEvent(name: "switch", value: "off" )
log.debug "switch is off"
}
def on() {
put '1'
sendEvent(name: "switch", value: "on" )
log.debug "switch is on"
}
def Red() {
put '2'
sendEvent(name: "switch", value: "on" )
log.debug "this device is on Red"
}
def Green() {
put '3'
sendEvent(name: "switch", value: "on" )
log.debug "this device is on Green"
}
def Brown() {
put '4'
sendEvent(name: "switch", value: "on" )
log.debug "this device is on Brown"
}
def Gigem() {
put '5'
sendEvent(name: "switch", value: "on" )
log.debug "this device is on Gigem"
}
def Broncos() {
put '6'
sendEvent(name: "switch", value: "on" )
log.debug "this device is on Broncos"
}
def effect6() {
put '7'
sendEvent(name: "switch", value: "on" )
log.debug "this device is on effect6"
}
def setColor(value) {
log.debug "setColor: ${value.hue} and setSaturation: ${value.saturation}"
def rgb = rgbToShieldRgb(value.red, value.green, value.blue);
}
def rgbToShieldRgb(r,g,b){
r = r
b = b
g = g
put "$r,$g,$b"
log.debug "Switch set to $r,$g,$b"
}
def setLevel(value){
call "$value"
log.debug "$value"
}
def poll() {
log.debug "Executing 'poll'"
checkStatus ()
}
def refresh() {
log.debug "executing 'refresh'"
checkStatus()
}
def checkStatus(){
httpGet(uri: "https://api.particle.io/v1/devices/${deviceId}/checkStatus1?access_token=${token}",
contentType: 'application/json',)
{resp ->
log.debug "resp data: ${resp.data}"
log.debug "result: ${resp.data.result}"
sendEvent(name: "switch", value: "${resp.data.result}" )
}
}
private put(led) {
//Spark Core API Call
httpPost(
uri: "https://api.particle.io/v1/devices/${deviceId}/led",
body: [access_token: token, command: led],
)
}
private call(dim) {
//Spark Core API Call
httpPost(
uri: "https://api.particle.io/v1/devices/${deviceId}/dim",
body: [access_token: token, command: dim],
)
}