Code by Scott שאול בן ישוע
Unverified Commit 90bf0930 authored by Stephan Hackett's avatar Stephan Hackett Committed by GitHub
Browse files

Update ABC_Child_Creator.groovy

05/18/19 
- Speech notifications now allow random messages to be sent (Use ; to separate options)
- cycleFan modified to no longer use numeric setSpeed values as trhis may be deprectated by HE for future fan devices
parent 669e46e7
......@@ -7,8 +7,11 @@
*
* Author: SmartThings, modified by Bruce Ravenel, Dale Coffing, Stephan Hackett
*
* 05/18/19 - Speech notifications now allow random messages to be sent (Use ; to separate options)
* - cycleFan modified to no longer use numeric setSpeed values as trhis may be deprectated by HE for future fan devices
*
* 04/29/19 - fixed small UI bug handling '0' level values
* - updated adjustFans method
*
* 02/19/19 - rules api bug squashed
*
......@@ -86,7 +89,7 @@
import hubitat.helper.RMUtils
def version(){"v0.2.190429"}
def version(){"v0.2.190518"}
definition(
name: "ABC Button Mapping",
......@@ -408,7 +411,7 @@ def getPrefDetails(){
[id:'cycleScenes_', sOrder:25, desc:'Cycle', comm:cycle, type:"normal", secLabel: getFormat("section", "Scenes (Cycle)"), cap: "device.SceneActivator", mul: true, isCycle: true],
[id:"shadeAdjust_", sOrder:26,desc:'Adjust', comm:adjustShade, type:"normal", secLabel: getFormat("section", "Shades (Up/Down/Stop)"), cap: "capability.doorControl", mul: true],
[id:'sirens_', sOrder:27, desc:'Toggle', comm:toggle, type:"normal", secLabel: getFormat("section", "Sirens (Toggle)"), cap: "capability.alarm", mul: true],
[id:"speechDevice_", sOrder:28, desc:'Send Msg To', comm:speechHandle, type:"normal", secLabel: getFormat("section", "Notifications (Speech):"), sub:"speechTxt", cap: "capability.speechSynthesis", subType:"text", sTitle: "Message To Speak:", sDesc:"Enter message to speak", mul: true],///set type to normal instead of sub so message text is not displayed
[id:"speechDevice_", sOrder:28, desc:'Send Msg To', comm:speechHandle, type:"normal", secLabel: getFormat("section", "Notifications (Speech):"), sub:"speechTxt", cap: "capability.speechSynthesis", subType:"text", sTitle: "Message To Speak:", sDesc:"Enter message to speak (Random messages: Use ; to separate choices)", mul: true],///set type to normal instead of sub so message text is not displayed
[id:"notifications_", desc:'Send Push Notification', comm:messageHandle, sub:"valNotify", type:"bool"],
[id:"phone_", desc:'Send SMS', comm:smsHandle, sub:"notifications_", type:"normal"],
......@@ -468,9 +471,16 @@ def buttonEvent(evt) {
}
def speechHandle(devices, msg){
log.info "Sending ${msg} to ${device}"
devices.speak(msg)
log.info "Sending ${msg} to ${devices}"
if(msg.contains(";")) {
def myPool = msg.split(";")
def poolSize = myPool.size()
def randomItem = Math.abs(new Random().nextInt() % poolSize)
devices.speak(myPool[randomItem-1])
}
else{
devices.speak(msg)
}
}
def turnOn(devices) {
......@@ -637,12 +647,12 @@ def changeMode(mode) {
def cycleFan(devices) { //all fans will sync speeds with fisrt fan in the list
log.info "Cycling: $devices"
def mySpeed = devices.currentSpeed
if(mySpeed[0] == "off") devices.setSpeed(1)
if(mySpeed[0] == "low") devices.setSpeed(2)
if(mySpeed[0] == "medium-low") devices.setSpeed(3)
if(mySpeed[0] == "medium") devices.setSpeed(4)
if(mySpeed[0] == "high") devices.setSpeed(0)
def mySpeed = devices[0].currentSpeed
if(mySpeed == "off") devices.setSpeed("low")
if(mySpeed == "low") devices.setSpeed("medium-low")
if(mySpeed == "medium-low") devices.setSpeed("medium")
if(mySpeed == "medium") devices.setSpeed("high")
if(mySpeed == "high") devices.setSpeed("off")
}
def cycle(devices, devIndex) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment