@@ -27,10 +27,9 @@ definition(
27
27
28
28
preferences {
29
29
page(name : " selectButton" )
30
- page(name : " configureButton1" )
31
- page(name : " configureButton2" )
32
- page(name : " configureButton3" )
33
- page(name : " configureButton4" )
30
+ for (def i= 1 ; i<= 8 ; i++ ) {
31
+ page(name : " configureButton$i " )
32
+ }
34
33
35
34
page(name : " timeIntervalInput" , title : " Only during a certain time" ) {
36
35
section {
@@ -60,22 +59,45 @@ def selectButton() {
60
59
}
61
60
}
62
61
62
+ def createPage (pageNum ) {
63
+ if ((state. numButton == pageNum) || (pageNum == 8 ))
64
+ state. installCondition = true
65
+ dynamicPage(name : " configureButton$pageNum " , title : " Set up button $pageNum here" ,
66
+ nextPage : " configureButton${ pageNum+1} " , install : state. installCondition, uninstall : configured(), getButtonSections(pageNum))
67
+ }
68
+
63
69
def configureButton1 () {
64
- dynamicPage(name : " configureButton1" , title : " Now let's decide how to use the first button" ,
65
- nextPage : " configureButton2" , uninstall : configured(), getButtonSections(1 ))
70
+ state. numButton = buttonDevice. currentState(" numberOfButtons" )?. longValue ?: 4
71
+ log. debug " state variable numButton: ${ state.numButton} "
72
+ state. installCondition = false
73
+ createPage(1 )
66
74
}
67
75
def configureButton2 () {
68
- dynamicPage(name : " configureButton2" , title : " If you have a second button, set it up here" ,
69
- nextPage : " configureButton3" , uninstall : configured(), getButtonSections(2 ))
76
+ createPage(2 )
70
77
}
71
78
72
79
def configureButton3 () {
73
- dynamicPage(name : " configureButton3" , title : " If you have a third button, you can do even more here" ,
74
- nextPage : " configureButton4" , uninstall : configured(), getButtonSections(3 ))
80
+ createPage(3 )
75
81
}
82
+
76
83
def configureButton4 () {
77
- dynamicPage(name : " configureButton4" , title : " If you have a fourth button, you rule, and can set it up here" ,
78
- install : true , uninstall : true , getButtonSections(4 ))
84
+ createPage(4 )
85
+ }
86
+
87
+ def configureButton5 () {
88
+ createPage(5 )
89
+ }
90
+
91
+ def configureButton6 () {
92
+ createPage(6 )
93
+ }
94
+
95
+ def configureButton7 () {
96
+ createPage(7 )
97
+ }
98
+
99
+ def configureButton8 () {
100
+ createPage(8 )
79
101
}
80
102
81
103
def getButtonSections (buttonNumber ) {
0 commit comments