MSA-1277: I'd like to submit significant capability updates to 2 device handlers widely used in UK (and EU): Fibaro Dimmer 1 and Fibaro Dimmer 2. There are 2 main additions to the original code developed by SmartThings team:

1)Addition of "scene" attribute to enable dimmer devices to emit scene activations to SmartThings hub, which can be listened upon by and reacted to by smartapps. This is a significant capability, which was omitted in the existing device handlers because it allows the use of double and triple clicks, secondary switch single/double/triple clicks to perform additional actions. A good example, when in a bedroom normal clicks to turn on/off lights would control main bedroom lights, while double clicks or clicks of the secondary switch S2 could control small table lights which are connected to SmartThings hub. Other examples can be activating Good Night or Good Morning routines, etc.

2)I also added the full list of hardware parameters for both switches to be controllable directly in the SmartThings App UI - settings of the device. This allows users with no coding skills to modify hardware parameters of Fibaro Dimmers without having to fiddle with any code changes. This also makes it possible to have different configurations for different dimmers by using just one device handler, as opposed to creating multiple copies of it depending on the set of parameters that one needs to set.

In addition to extensions of the device handlers I am also submitting a demo smartapp that can be used to subscribe to scene activations of Fibaro Dimmers. Its a very simple app, but one that is necessary to be able to take advantage of newly added functionality of Fibaro Dimmers on SmartThings platform.
This commit is contained in:
Elnar Hajiyev
2016-05-12 02:52:47 -05:00
parent a5da182bf4
commit 970e5404ac
3 changed files with 1331 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
/**
* Copyright 2015 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*/
definition(
name: "Fibaro Dimmer Scenes",
namespace: "My Apps",
author: "Elnar Hajiyev",
description: "Smart app that allows to control switches with changes of Fibaro Dimmer Scenes.",
category: "Convenience",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png"
)
preferences {
section("Listen to scenes from this Fibaro Dimmer devices...") {
input "fibaroDevicesSet", "capability.switch", title: "Fibaro Dimmers?", multiple: true, required: true
}
section("When any of these scenes are activated...") {
input "scenesSet1", "enum", title: "Fibaro Dimmer scenes (set 1)?", multiple: true, required: false,
options: ["10","11","12","13", "14", "15", "16", "17", "18", "20", "21", "22", "23", "24", "25", "26"]
}
section("Turn on all of these switches") {
input "switchesSet1", "capability.switch", multiple: true, required: false
}
section("When any of these scenes are activated...") {
input "scenesSet2", "enum", title: "Fibaro Dimmer scenes (set 2)?", multiple: true, required: false,
options: ["10","11","12","13", "14", "15", "16", "17", "18", "20", "21", "22", "23", "24", "25", "26"]
}
section("Turn off all of these switches") {
input "switchesSet2", "capability.switch", multiple: true, required: false
}
section("When any of these scenes are activated...") {
input "scenesSet3", "enum", title: "Fibaro Dimmer scenes (set 3)?", multiple: true, required: false,
options: ["10","11","12","13", "14", "15", "16", "17", "18", "20", "21", "22", "23", "24", "25", "26"]
}
section("Toggle all of these switches") {
input "switchesSet3", "capability.switch", multiple: true, required: false
}
}
def installed()
{
subscribe(fibaroDevicesSet, "scene", sceneHandler, [filterEvents: false])
}
def updated()
{
unsubscribe()
subscribe(fibaroDevicesSet, "scene", sceneHandler, [filterEvents: false])
}
def sceneHandler(evt) {
log.debug evt.value
log.debug evt.data
if(scenesSet1 && scenesSet1.contains(evt.value)) {
switchesSet1.on()
}
else if(scenesSet2 && scenesSet2.contains(evt.value)) {
switchesSet2.off()
}
else if(scenesSet3 && scenesSet3.contains(evt.value)) {
toggle(switchesSet3)
}
}
def toggle(devices) {
log.debug "toggle: $devices = ${devices*.currentValue('switch')}"
if (devices*.currentValue('switch').contains('off')) {
devices.on()
}
else if (devices*.currentValue('switch').contains('on')) {
devices.off()
}
else {
devices.on()
}
}