Can someone please tell me why my code keeps throwing me this error?
2018-02-16 15:10:37.918:errorNo signature of method: app15188154212101659971614.$() is applicable for argument types: (app15188154212101659971614$_motionHandler_closure2) values: [app15188154212101659971614$_motionHandler_closure2@173d2fda] Possible solutions: is(java.lang.Object), run(), run(), any(), any(groovy.lang.Closure), use([Ljava.lang.Object;) on line null
/**
- 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.
- Smart Nightlight
- Author: SmartThings
*/
definition(
name: "HAMBridge motion Controller",
namespace: "HAMBridge",
author: "jprosiak",
description: "Sends one HAMBridge command when it's dark and motion is detected. Sends another when it becomes light or some time after motion ceases.",
category: "Convenience",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet-luminance.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet-luminance@2x.png"
)preferences {
section("Which Motion Sensors..."){
input "motionSensor", "capability.motionSensor", title: "Where?", multiple: true, required: true
}
section("And then off when it's light or there's been no movement for..."){
input "delayMinutes", "number", title: "Minutes?"
}
section("HAMBridge Information:"){
input "server", "text", title: "Server IP", description: "Your HAM Bridger Server IP", required: true
input "port", "number", title: "Port", description: "Port Number", required: true
input "HAMBcommandMotionActive", "text", title: "Command to send when motion starts", required: true
input "HAMBcommandMotionInactive", "text", title: "Command to send when motion stops (optional)", required: false
}
section("Using either on this light sensor (optional)"){
input "lightSensor", "capability.illuminanceMeasurement", required: false
}
section("Set mode restrictions"){
input (
name : "modes"
,type : "mode"
,title : "Set for specific mode(s)"
,multiple : true
,required : false
)
}
}def installed() {
initialize()
}def updated() {
unsubscribe()
unschedule()
initialize()
}def initialize() {
subscribe(motionSensor, "motion", motionHandler)
if (lightSensor) {
subscribe(lightSensor, "illuminance", illuminanceHandler, [filterEvents: false])
}
}def motionHandler(evt) {
log.debug "$evt.name: $evt.value"
if (evt.value == "active") {
//if (enabled()) {
def crntLux = lightSensor.currentValue("illuminance").toInteger()
log.debug "Lux Level is ${crntLux}"
if (!modes || modes.contains(location.mode)) and (${crntLux} < 200) {
def HAMBcommand = settings.HAMBcommandMotionActive
sendHttp()
}
//}
state.motionStopTime = null
}
else {
state.motionStopTime = now()
if(delayMinutes) {
runIn(delayMinutes*60, turnOffMotionAfterDelay, [overwrite: true])
} else {
turnOffMotionAfterDelay()
}
}
}def illuminanceHandler(evt) {
log.debug "$evt.name: $evt.value, lastStatus: $state.lastStatus, motionStopTime: $state.motionStopTime"
//def lastStatus = state.lastStatus
def crntLux = lightSensor.currentValue("illuminance").toInteger()
if (${crntLux} > 200) {
def HAMBcommand = settings.HAMBcommandMotionInactive
sendHttp()
}
else if (state.motionStopTime) {
def elapsed = now() - state.motionStopTime
if (elapsed >= ((delayMinutes ?: 0) * 60000L) - 2000) {
def HAMBcommand = settings.HAMBcommandMotionInactive
sendHttp()
}
}
}def turnOffMotionAfterDelay() {
log.trace "In turnOffMotionAfterDelay, state.motionStopTime = $state.motionStopTime, state.lastStatus = $state.lastStatus"
if (state.motionStopTime) {
def elapsed = now() - state.motionStopTime
log.trace "elapsed = $elapsed"
if (elapsed >= ((delayMinutes ?: 0) * 60000L) - 2000) {
def HAMBcommand = settings.HAMBcommandMotionInactive
sendHttp()
}
}
}def scheduleCheck() {
log.debug "In scheduleCheck - skipping"
//turnOffMotionAfterDelay()
}//private enabled() {
// def result
// if (lightSensor) {
// result = lightSensor.currentIlluminance?.toInteger() < 200
// }
// else {
// def t = now()
// result = t < state.riseTime || t > state.setTime
// }
// result
//}def sendHttp() {
def ip = "${settings.server}:${settings.port}"
log.debug "${ip}"
log.debug "sending ${HAMBcommand} to HAMBridge on ${ip}"
//sendHubCommand(new hubitat.device.HubAction("""GET /?${settings.HAMBcommand} HTTP/1.1\r\nHOST: $ip\r\n\r\n""", hubitat.device.Protocol.LAN))
sendHubCommand(new hubitat.device.HubAction("""GET /?${HAMBcommand} HTTP/1.1\r\nHOST: $ip\r\n\r\n""", hubitat.device.Protocol.LAN))
}