Commit 2ec7616
committed
[shelly] Consolidate light API component handling into ShellyApiLightUtil with type-safe enum
Replace scattered profile.device.profile string-equality checks
(SHELLY2_PROFILE_CCTX2.equals(...) etc.) and RPC-method-name
comparisons with static isColorComponent/isRgbComponent/
isRgbwComponent/isCctComponent/isLightComponent(tag) helpers backed
by the settings.lights[i].apiComponent tag rather than the whole-
profile string. Add profile.isProRgbwwPm to replace the local
isProRgbwwPmProfile() duplicate, and add profile.isCctComponent(idx)
alongside the existing isColorComponent(idx). Also collapse
ShellyUtils.buildControlGroupName/buildWhiteGroupName into
profile.getControlGroup(), removing the now-redundant duplicate group
resolution logic.
The tag itself moves from a raw String ("rgb"/"rgbw"/"cct"/"light")
to a ShellyLightApiComponent enum, making an invalid tag a
compile-time impossibility instead of a silent runtime fallback to
the LIGHT RPC methods in Shelly2ApiRpc.lightRpcMethods(). The field
stays transient and is set only in
Shelly2ApiClient.createRgbwLightSetting() (Gen2-only, never
Gson-(de)serialized), so this is not a breaking change.
Static logic doesn't belong on a DTO class, so the helpers land in a
new ShellyApiLightUtil in the api package rather than on the
component tag holder itself. While at it, fold in the other
light-specific group/id helpers (getLightIdFromGroup,
lightChannelGroupPrefix, buildWhiteGroupName) that were sitting in
the generic ShellyUtils for the same reason, and add missing coverage
for the tag-lookup helpers and lightChannelGroupPrefix.
Also:
- Rename ShellyDeviceProfile.isColorComponent(int) to hasColorTag(int)
to resolve a name collision with the unrelated, differently-scoped
ShellyApiLightUtil.isColorComponent(ShellyLightApiComponent).
- Restore the setLightParms() fail-fast guard for non-RGBW2 profiles
and unify its RGB/RGBW/CCT/Light dispatch onto the same
lightRpcMethods() lookup already used elsewhere in this class.
- Document on ShellyLightApiComponent that each settings.lights index
is an independently addressed physical component, not a sub-channel
of one combined light - relevant for PR openhab#21286's OH Core LightModel
work, whose Pro RGBWW PM branch currently assumes one model per
whole-device profile string.
Signed-off-by: Markus Michels <markus7017@gmail.com>1 parent 5e935e7 commit 2ec7616
17 files changed
Lines changed: 519 additions & 233 deletions
File tree
- bundles/org.openhab.binding.shelly/src
- main/java/org/openhab/binding/shelly/internal
- api1
- api2
- api
- handler
- provider
- util
- test/java/org/openhab/binding/shelly/internal
- api2
- api
- handler
- util
Lines changed: 121 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
Lines changed: 15 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| 99 | + | |
| 100 | + | |
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
| |||
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
| 220 | + | |
217 | 221 | | |
218 | 222 | | |
219 | 223 | | |
| |||
366 | 370 | | |
367 | 371 | | |
368 | 372 | | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
376 | 384 | | |
377 | 385 | | |
378 | 386 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
522 | 523 | | |
523 | 524 | | |
524 | 525 | | |
525 | | - | |
526 | | - | |
| 526 | + | |
| 527 | + | |
527 | 528 | | |
528 | 529 | | |
529 | 530 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
Lines changed: 16 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
854 | 855 | | |
855 | 856 | | |
856 | 857 | | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | 858 | | |
864 | 859 | | |
865 | 860 | | |
| |||
1222 | 1217 | | |
1223 | 1218 | | |
1224 | 1219 | | |
1225 | | - | |
| 1220 | + | |
1226 | 1221 | | |
1227 | | - | |
1228 | | - | |
1229 | | - | |
1230 | | - | |
1231 | | - | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
1232 | 1231 | | |
1233 | 1232 | | |
1234 | 1233 | | |
| |||
1240 | 1239 | | |
1241 | 1240 | | |
1242 | 1241 | | |
1243 | | - | |
1244 | | - | |
| 1242 | + | |
1245 | 1243 | | |
1246 | 1244 | | |
1247 | 1245 | | |
1248 | | - | |
| 1246 | + | |
| 1247 | + | |
1249 | 1248 | | |
1250 | 1249 | | |
1251 | 1250 | | |
| |||
1304 | 1303 | | |
1305 | 1304 | | |
1306 | 1305 | | |
1307 | | - | |
| 1306 | + | |
1308 | 1307 | | |
1309 | 1308 | | |
1310 | 1309 | | |
| |||
1344 | 1343 | | |
1345 | 1344 | | |
1346 | 1345 | | |
1347 | | - | |
| 1346 | + | |
1348 | 1347 | | |
1349 | 1348 | | |
1350 | 1349 | | |
| |||
Lines changed: 0 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | 117 | | |
125 | 118 | | |
126 | 119 | | |
| |||
0 commit comments