Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed run time null checks #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions devices/fibaro-dimmer-2/fibaro-dimmer-2.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,14 @@ def dimmerEvent(physicalgraph.zwave.Command cmd) {
// Store last active level, which is needed for nightmode functionality:
if (levelValue > 0) state.lastActiveLevel = levelValue

// Restore pending level if dimmer has been switched on after nightmode has been disabled:
// Restore pending level if dimmer has been switched on after nightmode has been disabled:
if (!state.nightmodeActive & (state.nightmodePendingLevel > 0) & switchEvent.isStateChange & switchValue == "on") {
logger("dimmerEvent(): Applying Pending Level: ${state.nightmodePendingLevel}","debug")
result << response(secure(zwave.basicV1.basicSet(value: Math.round(state.nightmodePendingLevel.toInteger() * 99 / 100 ))))
state.nightmodePendingLevel = 0
}
// Else if Proactive Reporting is enabled, and the level has changed, request a meter report:
else if (state.proactiveReports & levelEvent.isStateChange) {
else if (state.proactiveReports != null & state.proactiveReports & levelEvent.isStateChange) {
result << response(["delay 5000", secure(zwave.meterV3.meterGet(scale: 2)),"delay 10000", secure(zwave.meterV3.meterGet(scale: 2))])
// Meter request is delayed for 5s, although sometimes this isn't long enough, so make a second request after another 10 seconds.
}
Expand Down Expand Up @@ -1705,8 +1705,8 @@ def updated() {
state.updatedLastRanAt = now()

// Update internal state:
state.loggingLevelIDE = settings.configLoggingLevelIDE.toInteger()
state.loggingLevelDevice = settings.configLoggingLevelDevice.toInteger()
state.loggingLevelIDE = settings.configLoggingLevelIDE?.toInteger()
state.loggingLevelDevice = settings.configLoggingLevelDevice?.toInteger()
state.syncAll = ("true" == settings.configSyncAll)
state.proactiveReports = ("true" == settings.configProactiveReports)

Expand Down Expand Up @@ -1743,8 +1743,8 @@ def updated() {
}

// Update Protection target values:
state.protectLocalTarget = settings.configProtectLocal.toInteger()
state.protectRFTarget = settings.configProtectRF.toInteger()
state.protectLocalTarget = settings.configProtectLocal?.toInteger()
state.protectRFTarget = settings.configProtectRF?.toInteger()

// Sync configuration with phyiscal device:
sync(state.syncAll)
Expand Down Expand Up @@ -2490,4 +2490,4 @@ private getAssocGroupsMd() {
[id: 5, maxNodes: 8, name: "Dimmer (S2)",
description : "Sends dim/brighten commands to associated devices when S2 is pressed (SWITCH_MULTILEVEL_SET)."]
]
}
}