-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestApp.groovy
137 lines (125 loc) · 4.03 KB
/
TestApp.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import com.hubitat.app.DeviceWrapper as DeviceWrapper
import com.hubitat.app.DeviceWrapperList as DeviceWrapperList
import com.hubitat.hub.domain.Event as Event
import com.hubitat.hub.domain.Hub as Hub
// Design Notes
// - Hubitat DOES NOT allow applications to leverages HTML tables for
// input() layout.
// - The "width" argument in input() allows for a 1..12 value that scales
// the space allotted to each input.
// - Accept adequate. Pretty is likely not an option.
definition(
name: "TestApp",
namespace: "hubitat",
author: "WesleyMC",
description: "",
category: "",
iconUrl: "",
iconX2Url: ""
)
preferences {
page(name: "TestPage")
}
void deviceSceneInputs(DeviceWrapper d, List<String> scenes) {
scenes.collect{scene, index ->
input(
name: "${d.id}:${scene}",
type: 'integer',
width: 1,
title: ${index == 1 ? d.displayName : ''},
defaultValue: 0
)
}
}
String roomHtml(LinkedHashMap room) {
return """<table>
${roomHeadingsHtml(room.scenes)}
${roomRowHtml(settings.devices[0], room.scenes)}
</table>"""
/*
return """<table>
<td>Device Name</td>${roomHeadingsHtml(room.scenes)}
${room.nonLutronId.collect{ d -> roomRowHtml(d, room.scenes) }}
${room.mainRepId.collect{ d -> roomRowHtml(d, room.scenes) }}
</table>"""
*/
}
Map TestPage() {
return dynamicPage(
name: "TestPage",
title: "TestApp",
install: false,
uninstall: false
) {
// Get actual non-Lutron devices.
section {
paragraph "settings keys are >${settings.keySet()}<"
input (
name: 'devices',
type: 'capability.switch',
title: 'Select Non-Lutron Switches',
submitOnChange: true,
required: true,
multiple: true
)
input (
name: 'repeaters',
type: 'device.LutronKeypad',
title: 'Select Lutron Main Repeaters',
submitOnChange: true,
required: true,
multiple: true
)
if (settings.devices && settings.repeaters) {
// Leverag types for coding.
List<String> scenes = ['alpha', 'beta', 'gamma']
Map<Integer, String> devices = settings.devices
Map<Integer, String> repeaters = settings.repeaters
Map<String, Integer> deviceValues = [:]
Map<String, Integer> repeaterValues = [:]
// Preserve room state
state.room = [:]
state.room.scenes = scenes
state.room.devices = devices
state.room.repeaters = repeaters
state.room.deviceValues = deviceValues
state.room.repeaterValues = repeaterValues
// Isolation test of roomCellHtml(...)
/* paragraph """
<table>
<tr>
${roomCellHtml(settings.devices[0], "BIRDY")}
</tr>
</table
""" */
// Isolation test of roomRowHtml(...)
/* */ paragraph """
<table>
${roomHeadingsHtml(room.scenes)}
${roomRowHtml(settings.devices[0], room.scenes)}
</table>
"""
input(name: "5672:alpha", type: "integer", width: 1, defaultValue: 0)
input(name: "5672:alpha", type: "integer", width: 1, defaultValue: 0)
input(name: "5672:alpha", type: "integer", width: 1, defaultValue: 0)
}
}
}
}
// ------------------------------------------------------------------------
// Per https://community.hubitat.com/t/lutron-integrators/658/3
// You need to add your main repeater to your Lutron Integration as a
// keypad. It has integration id 1. Then it will become available for
// selection in the app.
// - capability.momentary
// - capability.pushableButton
// - capability.releasableButton
// ------------------------------------------------------------------------
// No signature of method: user_app_hubitat_TestApp_323.devicesAsHtml()
// is applicable for argument types: (java.util.LinkedHashMap)
// values: [
// [
// scenes:[alpha, beta, gamma],
// devices:[Bev Station (63), Dining Table (09), ...], ..
// ]
// ] on line 79 (method TestPage)