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

[ICP-13444] Delete child switches on Flush Relay 1/1D #40329

Merged
merged 4 commits into from
Aug 19, 2020
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ metadata {
def installed() {
if (zwaveInfo?.model.equals("0051")) {
state.numberOfSwitches = 2
} else {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line shouldn't be here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed :)

} else if (zwaveInfo?.model.equals("0052") && zwaveInfo?.model.equals("0053")){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you've meant to put || between those conditions. Also there should be space before curly bracket

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PKacprowiczS thanks! Fixed

state.numberOfSwitches = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'd still need to add an explicit else here I think to avoid an NPE (just in case)

Also this doesn't really alter any of the behavior of the device, since these two models would have been defaulting to 1 in the first place, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Please add back a default case here (or remove the model checks you added).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

if (!childDevices) {
if (!childDevices && state.numberOfSwitches > 1) {
addChildSwitches(state.numberOfSwitches)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was happening before with for (def endpoint : 2..numberOfSwitches) { when numberOfSwitches was 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was still adding two children switches

}
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
Expand All @@ -93,12 +94,12 @@ def installed() {
}
// Preferences template end
response([
refresh((1..state.numberOfSwitches).toList())
refresh((1..state.numberOfSwitches).toList())
])
}

def updated() {
if (!childDevices) {
if (!childDevices && state.numberOfSwitches > 1) {
addChildSwitches(state.numberOfSwitches)
}
// Preferences template begin
Expand Down