App has been running fine… I have a few instances running and they seem flawless.
I have noticed some errors in the logs though, and I am not sure what they are from. Any ideas what would be triggering these:
error: com.netflix.hystrix.exception.HystrixRuntimeException: C*-IsaState-Update short-circuited and fallback disabled.
error: physicalgraph.exception.UncheckedException: com.netflix.astyanax.connectionpool.exceptions.NoAvailableHostsException: NoAvailableHostsException: [host=None(0.0.0.0):0, latency=0(0), attempts=0]No hosts to borrow from
I have two instances of this code running in once room on different switches, and the errors only appear in one of the instances… if that lends to figuring out why this is happening.
Its definitely happening directly after motionActiveHandler runs else… so I don’t know what could be causing an error since all I do is log.debug in that section.
Here is the current code I am running:
preferences {
section(“When there is movement here:”) {
input “motion1”, “capability.motionSensor”, title: “Where?”, multiple: true
}
section(“Turn ON These Dimmers”){
input “Dimswitches”, “capability.switchLevel”, multiple: true, required: false
input “BrightLevel”, “number”, title: “Dimmer Level %1-99 (OPTIONAL) Zero for no dimming”, required: false, defaultValue: “0”
}
section(“Turn ON Switches”){
input “switches”, “capability.switch”, multiple: true, required: false
}
section(“Unless there has been movement within the past”){
input “minutes1”, “number”, title: “Minutes?”
}
section(“And it is dark (OPTIONAL)”) {
input “LightMeter”, “capability.illuminanceMeasurement”, title: “Where?”, required: false
input “luminanceLevel”, “number”, title: “1-1000”, defaultValue: “250”, required: false
}
}
def installed() {
subscribe(motion1, “motion.active”, motionActiveHandler)
subscribe(motion1, “motion.inactive”, motionInactiveHandler)
subscribe(LightMeter, “illuminance”, handleLuxChange)
initialize()
}
def updated() {
unsubscribe()
subscribe(motion1, “motion.active”, motionActiveHandler)
subscribe(motion1, “motion.inactive”, motionInactiveHandler)
subscribe(LightMeter, “illuminance”, handleLuxChange)
initialize()
}
def initialize() {
ResetClock()
ActivityClock()
state.BrightLevel = BrightLevel as Integer
if (state.BrightLevel >= 100) {
state.BrightLevel = 99
}
if (state.BrightLevel <= 0) {
state.BrightLevel = 0
}
state.luminanceLevel = luminanceLevel as Integer
if (state.luminanceLevel <= 0) {
state.luminanceLevel = 0
}
if (state.luminanceLevel >= 1000) {
state.luminanceLevel = 1000
}
log.info “Brightness: $state.BrightLevel Luminance: $state.luminanceLevel”
}
def ActivityClock() {
//log.debug “ActivityClock”
state.threshold = 1000 * 60 * minutes1
state.elapsed = now() - state.motionEvent
//state.threshold = minutes1
//state.elapsed = (now() - state.motionEvent) / 60000
state.elapsedMinutes = (now() - state.motionEvent) / 60000
state.roundElapsed = Math.round(state.elapsedMinutes)
//log.debug “ActivityClock: $state.threshold ms Threshold is $minutes1 Minute(s)”
//log.debug “ActivityClock: $state.elapsed ms Elapsed”
log.info “ActivityClock: $state.roundElapsed Minutes Elapsed: Threshold is $minutes1 Minute(s)”
}
def ResetClock() {
state.motionEvent = now()
log.trace “ResetClock”
}
def motionActiveHandler(evt) {
log.info “$evt.name: $evt.value”
ActivityClock()
if (state.elapsed >= state.threshold) {
log.debug “motionActiveHandler: $state.elapsedMinutes Minutes >= $minutes1 Minute(s) Check Light Sensor”
checkLuminance()
//ResetClock()
} else {
//ResetClock()
log.debug “motionActiveHandler: Not enough time has elapsed, do nothing”
}
}
def motionInactiveHandler(evt) {
log.info “$evt.name: $evt.value”
ResetClock()
//ActivityClock()
}
def handleLuxChange(evt){
if (LightMeter){
def lightSensorState = LightMeter.currentIlluminance
log.info “handleLuxChange: SENSOR = $lightSensorState”
} else {
log.debug “handleLuxChange: SENSOR = No Light Meter”
}
}
def checkLuminance() {
log.debug “checkLuminance”
if (LightMeter){
def lightSensorState = LightMeter.currentIlluminance
log.debug “checkLuminance: SENSOR = $lightSensorState”
if (lightSensorState != null && lightSensorState <= state.luminanceLevel) {
log.debug “checkLuminance: SENSOR = $lightSensorState is <= $state.luminanceLevel: Turn On Lights”
TurnOnLights()
} else {
log.debug “checkLuminance: SENSOR = $lightSensorState is >= $state.luminanceLevel: Do Not Turn On Lights”
}
} else {
log.debug “checkLuminance: SENSOR = No Light Meter: TURN ON LIGHTS”
TurnOnLights()
}
}
def TurnOnLights() {
log.debug"TurnOnLights"
if (switches) {
log.trace “TurnOnLights: Switches ON”
switches.on()
}
if (Dimswitches) {
if (BrightLevel) {
log.trace “TurnOnLights: User set Dim Level $BrightLevel set to Light ON at $state.BrightLevel %”
Dimswitches?.setLevel(state.BrightLevel)
} else {
log.trace “TurnOnLights: Not set to Dimmer Level: Dimmer Light ON”
Dimswitches.on()
}
}
}