My apologizes for the delay. I tweaked the code a bit, UI is slightly different than above) but then iFTT started causing some headaches. It show receipt of the webhook trigger but the applets were significantly delayed, by hours at times. I eventually dumped it all and re-tried rest980. Good news is that it is working for local control only.
Regardless, the final version before I dumped iFTT is below, youâll noticed that I bypassed webCore and and am using a http get command to send the webhook directly. Each user will have to create iFTT applets (webHooksâ>iRobot) for start, stop, pause, and dock. Those webhooks and the userâs webhook key is entered into the DH settings.
Additionally, for the feedback mechanisms, three iRobotâ>SmartThings applets will be needed. Turn on the device switch when iRobot starts, lock the device upon mission complete, and sound alarm (strobe) when error occurs. These feedback mechanisms should still occur even if iRobot is started by other means so you can check status in smartThings at any time.
It is time consuming to setup the iFTT portion but it was working before iFTT decided to be a pain. I even contacted help on both ends, iFTT and iRobot. They blamed each otherâŚ
Other notes: I added a motion secondary control to the multi-attribute tile. This is purely simulated and indicates active cleaning vs docked. Due to the nature of the ânewâ app, I chose motion and a vid of generic-sensor. You cannot control iRobot via the new app but you can see if motion is active aka cleaning.
/**
*/
preferences {
section(âWebHook Command Inputâ){
input âstart_commandâ, âtextâ, title: âStart Commandâ, required: false
input âpause_commandâ, âtextâ, title: âPause Commandâ, required: false
input âstop_commandâ, âtextâ, title: âStop Commandâ, required: false
input âdock_commandâ, âtextâ, title: âDock Commandâ, required: false
input âkeyâ, âpasswordâ, title: âiFTT Maker Keyâ, required: true
}
}
metadata {
definition (name: âRoomba Control via iFTTâ, namespace: âSmartThingsDHsâ, author: âfieldsjmâ, mnmn: âSmartThingsâ, vid: âgeneric-sensorâ) {
capability âActuatorâ
capability âAlarmâ
capability âButtonâ
capability âLockâ
capability âSensorâ
capability âSwitchâ
capability âmotionSensorâ
capability âHealth Checkâ
command "push1"
command "push2"
command "push3"
command "push4"
command "push5"
}
simulator {
}
tiles (scale: 2){
/Status tile based on intended action/
multiAttributeTile(name:âstatusâ, type: âgenericâ, width: 6, height: 4){
tileAttribute (âdevice.statusâ, key: âPRIMARY_CONTROLâ) {
attributeState (âReadyâ, label: âReadyâ, icon:âst.samsung.da.RC_ic_rcâ, backgroundColor:â#8CFC03â)
attributeState (âRunningâ, label: âIn-Processâ, icon:âst.Health & Wellness.health7â, backgroundColor:â#078bf7â)
attributeState (âPausedâ, label: âPausedâ, icon:âhttp://cdn.device-icons.smartthings.com/sonos/pause-icon@2x.pngâ, backgroundColor:â#FC030Fâ)
attributeState (âDockingâ, label: âDockingâ, icon:âst.presence.house.unlockedâ, backgroundColor:â#5F07F7â)
attributeState (âDockedâ, label: âDockedâ, icon:âst.presence.house.securedâ, backgroundColor:â#5F07F7â)
attributeState (âStoppedâ, label: âStoppedâ, icon:âhttps://raw.githubusercontent.com/fieldsjm/Resources/master/stop.pngâ, backgroundColor:â#FC030Fâ)
attributeState (âEndedâ, label: âCompleteâ, icon:âst.samsung.da.RC_ic_rcâ, backgroundColor:â#8CFC03â)
attributeState (âErrorâ, label: âErrorâ, icon:âhttps://raw.githubusercontent.com/fieldsjm/Resources/master/warning.pngâ, backgroundColor:â#FC030Fâ)
}
tileAttribute(âdevice.motionâ, key: âSECONDARY_CONTROLâ) {
attributeState (âactiveâ, label: âCleaningâ)
attributeState (âinactiveâ, label: âDockedâ)
}
}
/Start/
standardTile(âpush1â, âdevice.buttonâ, width: 3, height: 2, decoration: âflatâ) {
state âdefaultâ, label: âStartâ, icon:âst.samsung.da.RC_ic_rcâ, backgroundColor: â#ffffffâ, action: âpush1â
}
/Pause/
standardTile(âpush2â, âdevice.buttonâ, width: 3, height: 2, decoration: âflatâ) {
state âdefaultâ, label: ââ, icon:âst.sonos.pause-btnâ, backgroundColor: â#ffffffâ, action: âpush2â
}
/Dock/
standardTile(âpush3â, âdevice.buttonâ, width: 3, height: 2, decoration: âflatâ) {
state âdefaultâ, label: âDockâ, icon:âst.nest.nest-homeâ, backgroundColor: â#ffffffâ, action: âpush3â
}
/Stop/
standardTile(âpush4â, âdevice.buttonâ, width: 3, height: 2, decoration: âflatâ) {
state âdefaultâ, label: ââ, icon:âst.sonos.stop-btnâ, backgroundColor: â#ffffffâ, action: âpush4â
}
/Reset/
standardTile(âpush5â, âdevice.buttonâ, width: 6, height: 2, decoration: âflatâ) {
state âdefaultâ, label: âResetâ, icon:âst.secondary.refresh-iconâ, backgroundColor: â#ffffffâ, action: âpush5â
}
/Switch for IFTT feedback of Started - Hidden by default/
standardTile(âswitchâ, âdevice.switchâ, inactiveLabel: false, width: 6, height: 2, decoration: âflatâ){
state(âoffâ, label: âReadyâ, action: âswitch.onâ, backgroundColor: â#ffffffâ, nextState: âonâ, defaultState: âtrueâ)
state(âonâ, label: âCleaningâ, action: âswitch.offâ, backgroundColor: â#00a0dcâ, nextState: âoffâ)
}
/Alarm for IFTT feedback of Error - Hidden by default/
standardTile(âalarmâ, âdevice.alarmâ, inactiveLabel: false, width: 6, height: 2, decoration: âflatâ) {
state(âoffâ, label:âReady / Pendingâ, action:âalarm.strobeâ, icon:âst.alarm.alarm.alarmâ, backgroundColor:â#ffffffâ, nextState: âstrobeâ, defaultState: âtrueâ)
state(âstrobeâ, label:âErrorâ, action:âalarm.offâ, icon:âst.alarm.alarm.alarmâ, backgroundColor:â#e86d13â, nextState: âoffâ)
}
/Lock for IFTT feedback of mission complete - Hidden by default/
standardTile(âlockâ, âdevice.lockâ, inactiveLabel: false, width: 6, height: 2, decoration: âflatâ){
state(âunlockedâ, label: âReady / Pendingâ, action: âlock.lockâ, backgroundColor: â#ffffffâ, nextState: âlockedâ, defaultState: âtrueâ)
state(âlockedâ, label: âMission Completeâ, action: âlock.unlockâ, backgroundColor: â#00a0dcâ, nextState: âunlockedâ)
}
main "status"
details(["status","push1","push2","push3","push4","push5", /*"switch","alarm","lock"*/])
}
}
def parse(String description) {
}
/Start - Sends iFTT Webhook - if Roomba starts successfully, iFTT will turn on switch/
def push1() {
push(1)
def cmd = "https://maker.ifttt.com/trigger/${settings.start_command}/with/key/${settings.key}";
log.debug "Sending request cmd[${cmd}]"
httpGet(cmd) {resp ->
if (resp.data) {
log.info "${resp.data}"
}
}
sendHubCommand(result)
log.debug âExecuting push1â
log.debug result
}
/Pause - Sends iFTT Webhook - no feedback available/
def push2() {
push(2)
sendEvent(name: âstatusâ, value: âPausedâ)
sendEvent(name: âmotionâ, value: âactiveâ)
def cmd = "https://maker.ifttt.com/trigger/${settings.pause_command}/with/key/${settings.key}";
log.debug "Sending request cmd[${cmd}]"
httpGet(cmd) {resp ->
if (resp.data) {
log.info "${resp.data}"
}
}
sendHubCommand(result)
log.debug âExecuting push1â
log.debug result
}
/Dock - Sends iFTT Webhook - minimal feedback available, once docked iFTT will also send docking mission complete (fail safe of conversational delay to Docked then Ready Status)/
def push3() {
push(3)
sendEvent(name: âstatusâ, value: âDockingâ)
sendEvent(name: âmotionâ, value: âactiveâ)
runIn(60, docked)
def cmd = "https://maker.ifttt.com/trigger/${settings.dock_command}/with/key/${settings.key}";
log.debug "Sending request cmd[${cmd}]"
httpGet(cmd) {resp ->
if (resp.data) {
log.info "${resp.data}"
}
}
sendHubCommand(result)
log.debug âExecuting push1â
log.debug result
}
def docked() {
sendEvent(name: âstatusâ, value: âDockedâ)
sendEvent(name: âmotionâ, value: âinactiveâ)
runIn(10, push5)
}
/Stop - Sends iFTT Webhook - no feedback available/
def push4() {
push(4)
sendEvent(name: âstatusâ, value: âStoppedâ)
sendEvent(name: âmotionâ, value: âactiveâ)
def cmd = "https://maker.ifttt.com/trigger/${settings.stop_command}/with/key/${settings.key}";
log.debug "Sending request cmd[${cmd}]"
httpGet(cmd) {resp ->
if (resp.data) {
log.info "${resp.data}"
}
}
sendHubCommand(result)
log.debug âExecuting push1â
log.debug result
}
/Status Reset/
def push5() {
push(5)
unlock()
off()
sendEvent(name: âstatusâ, value: âReadyâ)
sendEvent(name: âmotionâ, value: âinactiveâ)
}
private push(button) {
log.debug â$device.displayName button $button was pushedâ
sendEvent(name: âbuttonâ, value: âpushedâ, data: [buttonNumber: button], descriptionText: â$device.displayName button $button was pushedâ, isStateChange: true)
}
/Feedback Mechanisms/
/Started - iFTT turns on if Roomba starts successfully/
def on(){
sendEvent(name: âswitchâ, value: âonâ)
sendEvent(name: âstatusâ, value: âRunningâ)
sendEvent(name: âmotionâ, value: âactiveâ)
log.debug â$device.displayName (iFTT) has reported startingâ
}
def off(){
sendEvent(name: âswitchâ, value: âoffâ)
sendEvent(name: âalarmâ, value: âoffâ)
sendEvent(name: âstatusâ, value: âReadyâ)
sendEvent(name: âmotionâ, value: âinactiveâ)
}
/Misson Complete - iFTT turns on if Roomba completes task/
def lock() {
sendEvent(name: âlockâ, value: âlockedâ)
sendEvent(name: âstatusâ, value: âEndedâ)
sendEvent(name: âmotionâ, value: âinactiveâ)
log.debug â$device.displayName (iFTT) has reported misson completeâ
}
def unlock() {
sendEvent(name: âlockâ, value: âunlockedâ)
sendEvent(name: âstatusâ, value: âReadyâ)
sendEvent(name: âmotionâ, value: âinactiveâ)
}
/Error - iFTT turns on if Roomba encounters an error (stuck, low battery, etc)/
def strobe() {
sendEvent(name: âalarmâ, value: âstrobeâ)
sendEvent(name: âstatusâ, value: âErrorâ)
sendEvent(name: âmotionâ, value: âactiveâ)
log.debug â$device.displayName (iFTT) has reported an errorâ
}
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
sendEvent(name: ânumberOfButtonsâ, value: 5)
sendEvent(name: âstatusâ, value: âReadyâ)
sendEvent(name: âmotionâ, value: âinactiveâ)
sendEvent(name: âhealthStatusâ, value: âonlineâ)
}