Skip to content

Instantly share code, notes, and snippets.

@hdurdle
Created January 19, 2017 19:52
Show Gist options
  • Save hdurdle/d11eb215f154fdbd51d8fa17b811a65e to your computer and use it in GitHub Desktop.
Save hdurdle/d11eb215f154fdbd51d8fa17b811a65e to your computer and use it in GitHub Desktop.
/*
* Activate selected Fibaro pattern or preset colour on switch activation
*
* Author: Howard Durdle
* Based on the Pattern Trigger by Michael Hudson
* Based on the Turn-on-Police-Light-When-Switch-Is-On.groovy smartapp by twack
* https://github.com/twack/smarthings-apps/blob/master/Turn-on-Police-Light-When-Switch-Is-On.groovy
*
*/
definition(
name: "Fibaro pattern and colour trigger",
namespace: "hdurdle",
author: "Howard Durdle",
description: "Trigger Fibaro Controller to activate selected pattern when a switch, real or virtual, is turned on.",
category: "My Apps",
iconUrl: "http://cdn.device-icons.smartthings.com/Lighting/light11-icn.png",
iconX2Url: "http://cdn.device-icons.smartthings.com/Lighting/light11-icn@2x.png"
)
preferences {
section("When a Switch is turned on...") {
input "switch1", "capability.switch", title: "Which switch?"
}
section("Activate this/these Fibaro Light(s)...") {
input "switches", "device.fibaroRGBWController", title: "Which Target(s)?", multiple: true
}
// note - added warmwhite to the enum - can add any of the other presets from the device handler
section("Set pattern to the following...") {
input "pattern1", "enum", title: "Which pattern?", description: "Select the pattern to use", options: ["warmwhite", "fireplace", "storm", "deepfade", "litefade", "police"], multiple: false, required: true
}
}
def installed() {
subscribe(switch1, "switch.on", switchOnHandler)
subscribe(switch1, "switch.off", switchOffHandler)
}
def updated() {
unsubscribe()
subscribe(switch1, "switch.on", switchOnHandler)
subscribe(switch1, "switch.off", switchOffHandler)
}
def switchOnHandler(evt) {
log.trace "Turning on switches: $switches"
switches."$pattern1" ()
}
def switchOffHandler(evt) {
log.trace "Turning on switches: $switches"
switches.off()
}
@chaseparker
Copy link

What do I do if there are “no devices of this type” listed under “which targets?” I am using the “Fibaro RGBW 3 beta” device handler by
Twack. Thanks!
cad943f5-0eda-49e8-a7c7-d5d014eb49c2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment