24
24
import org .eclipse .jdt .annotation .Nullable ;
25
25
import org .openhab .core .i18n .LocalizedKey ;
26
26
import org .openhab .core .library .CoreItemFactory ;
27
+ import org .openhab .core .semantics .model .DefaultSemanticTags .Point ;
28
+ import org .openhab .core .semantics .model .DefaultSemanticTags .Property ;
27
29
import org .openhab .core .thing .i18n .ChannelTypeI18nLocalizationService ;
28
30
import org .openhab .core .thing .type .ChannelType ;
29
31
import org .openhab .core .thing .type .ChannelTypeBuilder ;
50
52
* @author Christoph Weitkamp - Added support for translation
51
53
* @author Stefan Triller - Added more system channels
52
54
* @author Christoph Weitkamp - factored out common i18n aspects into ThingTypeI18nLocalizationService
55
+ * @author Andrew Fiddian-Green - Added system Point and Property tags
53
56
*/
54
57
@ NonNullByDefault
55
58
@ Component
@@ -121,7 +124,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
121
124
new StateOption ("2" , "average" ), new StateOption ("3" , "good" ),
122
125
new StateOption ("4" , "excellent" )))
123
126
.build ())
124
- .withTags (List . of ( "Measurement" , "Level" ) ).build ();
127
+ .withTags (Point . MEASUREMENT , Property . SIGNAL_STRENGTH ).build ();
125
128
126
129
/**
127
130
* Low battery default system wide {@link ChannelType}. Represents a low battery warning with possible values
@@ -132,7 +135,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
132
135
.withDescription ("Low battery warning with possible values on (low battery) and off (battery ok)" )
133
136
.withCategory ("LowBattery" )
134
137
.withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ().withReadOnly (true ).build ())
135
- .withTags (List . of ( "LowBattery" , "Energy" ) ).build ();
138
+ .withTags (Point . ALARM , Property . LOW_BATTERY ).build ();
136
139
137
140
/**
138
141
* Battery level default system wide {@link ChannelType}. Represents the battery level as a percentage.
@@ -143,7 +146,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
143
146
.withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ().withMinimum (BigDecimal .ZERO )
144
147
.withMaximum (new BigDecimal (100 )).withStep (BigDecimal .ONE ).withReadOnly (true ).withPattern ("%.0f %%" )
145
148
.build ())
146
- .withTags (List . of ( "Measurement" , "Energy" ) ).build ();
149
+ .withTags (Point . MEASUREMENT , Property . ENERGY ).build ();
147
150
148
151
/**
149
152
* System wide trigger {@link ChannelType} without event options.
@@ -188,7 +191,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
188
191
public static final ChannelType SYSTEM_POWER = ChannelTypeBuilder
189
192
.state (SYSTEM_CHANNEL_TYPE_UID_POWER , "Power" , CoreItemFactory .SWITCH )
190
193
.withDescription ("Device is operable when channel has state ON" ).withCategory ("Switch" )
191
- .withTags (List . of ( "Switch" , "Power" ) ).build ();
194
+ .withTags (Point . SWITCH , Property . POWER ).build ();
192
195
193
196
/**
194
197
* Location: default system wide {@link ChannelType} which displays a location
@@ -198,7 +201,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
198
201
.withDescription ("Location in lat./lon./height coordinates" )
199
202
.withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ().withReadOnly (true )
200
203
.withPattern ("%2$s°N %3$s°E %1$sm" ).build ())
201
- .withTag ( "Measurement" ).build ();
204
+ .withTags ( Point . MEASUREMENT , Property . GEO_LOCATION ).build ();
202
205
203
206
/**
204
207
* Motion: default system wide {@link ChannelType} which indications whether motion was detected (state ON)
@@ -207,7 +210,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
207
210
.state (SYSTEM_CHANNEL_TYPE_UID_MOTION , "Motion" , CoreItemFactory .SWITCH )
208
211
.withDescription ("Motion detected by the device" ).withCategory ("Motion" )
209
212
.withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ().withReadOnly (true ).build ())
210
- .withTags (List . of ( "Status" , "Presence" ) ).build ();
213
+ .withTags (Point . STATUS , Property . PRESENCE ).build ();
211
214
212
215
/**
213
216
* Brightness: default system wide {@link ChannelType} which allows changing the brightness from 0-100%
@@ -217,15 +220,15 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
217
220
.withDescription ("Controls the brightness and switches the light on and off" ).withCategory ("Light" )
218
221
.withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ().withMinimum (BigDecimal .ZERO )
219
222
.withMaximum (new BigDecimal (100 )).withPattern ("%d %%" ).build ())
220
- .withTags (List . of ( "Control" , "Light" ) ).build ();
223
+ .withTags (Point . CONTROL , Property . BRIGHTNESS ).build ();
221
224
222
225
/**
223
226
* Color: default system wide {@link ChannelType} which allows changing the color
224
227
*/
225
228
public static final ChannelType SYSTEM_COLOR = ChannelTypeBuilder
226
229
.state (SYSTEM_CHANNEL_TYPE_UID_COLOR , "Color" , CoreItemFactory .COLOR )
227
230
.withDescription ("Controls the color of the light" ).withCategory ("ColorLight" )
228
- .withTags (List . of ( "Control" , "Light" ) ).build ();
231
+ .withTags (Point . CONTROL , Property . COLOR ).build ();
229
232
230
233
/**
231
234
* Color-temperature: default system wide {@link ChannelType} which allows changing the color temperature in percent
@@ -236,7 +239,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
236
239
.withCategory ("ColorLight" )
237
240
.withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ().withMinimum (BigDecimal .ZERO )
238
241
.withMaximum (new BigDecimal (100 )).withPattern ("%.0f" ).build ())
239
- .withTags (List . of ( "Control" , "ColorTemperature" ) ).build ();
242
+ .withTags (Point . CONTROL , Property . COLOR_TEMPERATURE ).build ();
240
243
241
244
/**
242
245
* Color-temperature: default system wide {@link ChannelType} which allows changing the color temperature in Kelvin
@@ -247,7 +250,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
247
250
.withCategory ("ColorLight" ).isAdvanced (true )
248
251
.withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ().withMinimum (new BigDecimal (1000 ))
249
252
.withMaximum (new BigDecimal (10000 )).withPattern ("%.0f K" ).build ())
250
- .withTags (List . of ( "Control" , "ColorTemperature" ) ).build ();
253
+ .withTags (Point . CONTROL , Property . COLOR_TEMPERATURE ).build ();
251
254
252
255
// media channels
253
256
@@ -259,22 +262,22 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
259
262
.withDescription ("Change the sound volume of a device" )
260
263
.withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ().withMinimum (BigDecimal .ZERO )
261
264
.withMaximum (new BigDecimal (100 )).withPattern ("%d %%" ).build ())
262
- .withCategory ("SoundVolume" ).withTags (List . of ( "Control" , "SoundVolume" ) ).build ();
265
+ .withCategory ("SoundVolume" ).withTags (Point . CONTROL , Property . SOUND_VOLUME ).build ();
263
266
264
267
/**
265
268
* Mute: default system wide {@link ChannelType} which allows muting and un-muting audio
266
269
*/
267
270
public static final ChannelType SYSTEM_MUTE = ChannelTypeBuilder
268
271
.state (SYSTEM_CHANNEL_TYPE_UID_MUTE , "Mute" , CoreItemFactory .SWITCH )
269
272
.withDescription ("Mute audio of the device" ).withCategory ("SoundVolume_Mute" )
270
- .withTags (List . of ( "Switch" , "SoundVolume" ) ).build ();
273
+ .withTags (Point . SWITCH , Property . SOUND_VOLUME ).build ();
271
274
272
275
/**
273
276
* Media-control: system wide {@link ChannelType} which controls a media player
274
277
*/
275
278
public static final ChannelType SYSTEM_MEDIA_CONTROL = ChannelTypeBuilder
276
279
.state (SYSTEM_CHANNEL_TYPE_UID_MEDIA_CONTROL , "Media Control" , CoreItemFactory .PLAYER )
277
- .withCategory ("MediaControl" ).withTag ( "Control" ).build ();
280
+ .withCategory ("MediaControl" ).withTags ( Point . CONTROL , Property . MEDIA_CONTROL ).build ();
278
281
279
282
/**
280
283
* Media-title: default system wide {@link ChannelType} which displays the title of a (played) song
@@ -283,7 +286,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
283
286
.state (SYSTEM_CHANNEL_TYPE_UID_MEDIA_TITLE , "Media Title" , CoreItemFactory .STRING )
284
287
.withDescription ("Title of a (played) media file" )
285
288
.withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ().withReadOnly (true ).build ())
286
- .withTag ( "Status" ).build ();
289
+ .withTags ( Point . STATUS ).build ();
287
290
288
291
/**
289
292
* Media-artist: default system wide {@link ChannelType} which displays the artist of a (played) song
@@ -292,7 +295,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
292
295
.state (SYSTEM_CHANNEL_TYPE_UID_MEDIA_ARTIST , "Media Artist" , CoreItemFactory .STRING )
293
296
.withDescription ("Artist of a (played) media file" )
294
297
.withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ().withReadOnly (true ).build ())
295
- .withTag ( "Status" ).build ();
298
+ .withTags ( Point . STATUS ).build ();
296
299
297
300
// weather channels
298
301
@@ -304,7 +307,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
304
307
.withDescription ("Current wind direction expressed as an angle" ).withCategory ("Wind" )
305
308
.withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ().withMinimum (BigDecimal .ZERO )
306
309
.withMaximum (new BigDecimal (360 )).withReadOnly (true ).withPattern ("%.0f %unit%" ).build ())
307
- .withTags (List . of ( "Measurement" , "Wind" ) ).build ();
310
+ .withTags (Point . MEASUREMENT , Property . WIND ).build ();
308
311
309
312
/**
310
313
* Wind-speed: system wide {@link ChannelType} which shows the wind speed
@@ -314,7 +317,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
314
317
.withDescription ("Current wind speed" ).withCategory ("Wind" )
315
318
.withStateDescriptionFragment (
316
319
StateDescriptionFragmentBuilder .create ().withReadOnly (true ).withPattern ("%.1f %unit%" ).build ())
317
- .withTags (List . of ( "Measurement" , "Wind" ) ).build ();
320
+ .withTags (Point . MEASUREMENT , Property . WIND ).build ();
318
321
319
322
/**
320
323
* Outdoor-temperature: system wide {@link ChannelType} which shows the outdoor temperature
@@ -324,7 +327,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
324
327
.withDescription ("Current outdoor temperature" ).withCategory ("Temperature" )
325
328
.withStateDescriptionFragment (
326
329
StateDescriptionFragmentBuilder .create ().withReadOnly (true ).withPattern ("%.1f %unit%" ).build ())
327
- .withTags (List . of ( "Measurement" , "Temperature" ) ).build ();
330
+ .withTags (Point . MEASUREMENT , Property . TEMPERATURE ).build ();
328
331
329
332
/**
330
333
* Indoor-temperature: system wide {@link ChannelType} which shows the indoor temperature
@@ -334,7 +337,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
334
337
.withDescription ("Current indoor temperature" ).withCategory ("Temperature" )
335
338
.withStateDescriptionFragment (
336
339
StateDescriptionFragmentBuilder .create ().withReadOnly (true ).withPattern ("%.1f %unit%" ).build ())
337
- .withTags (List . of ( "Measurement" , "Temperature" ) ).build ();
340
+ .withTags (Point . MEASUREMENT , Property . TEMPERATURE ).build ();
338
341
339
342
/**
340
343
* Atmospheric-humidity: system wide {@link ChannelType} which shows the atmospheric humidity
@@ -344,7 +347,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
344
347
.withUnitHint ("%" ).withDescription ("Current atmospheric relative humidity" ).withCategory ("Humidity" )
345
348
.withStateDescriptionFragment (
346
349
StateDescriptionFragmentBuilder .create ().withReadOnly (true ).withPattern ("%.0f %%" ).build ())
347
- .withTags (List . of ( "Measurement" , "Humidity" ) ).build ();
350
+ .withTags (Point . MEASUREMENT , Property . HUMIDITY ).build ();
348
351
349
352
/**
350
353
* Barometric-pressure: system wide {@link ChannelType} which shows the barometric pressure
@@ -354,7 +357,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
354
357
.withDescription ("Current barometric pressure" ).withCategory ("Pressure" )
355
358
.withStateDescriptionFragment (
356
359
StateDescriptionFragmentBuilder .create ().withReadOnly (true ).withPattern ("%.3f %unit%" ).build ())
357
- .withTags (List . of ( "Measurement" , "Pressure" ) ).build ();
360
+ .withTags (Point . MEASUREMENT , Property . PRESSURE ).build ();
358
361
359
362
// Energy
360
363
@@ -366,7 +369,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
366
369
.withDescription ("Current electric power" ).withCategory ("Energy" )
367
370
.withStateDescriptionFragment (
368
371
StateDescriptionFragmentBuilder .create ().withReadOnly (true ).withPattern ("%.1f %unit%" ).build ())
369
- .withTags (List . of ( "Measurement" , "Power" ) ).build ();
372
+ .withTags (Point . MEASUREMENT , Property . POWER ).build ();
370
373
371
374
/**
372
375
* Electric-current: system wide {@link ChannelType} which shows the electric current
@@ -376,7 +379,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
376
379
.withDescription ("Current electric current" ).withCategory ("Energy" )
377
380
.withStateDescriptionFragment (
378
381
StateDescriptionFragmentBuilder .create ().withReadOnly (true ).withPattern ("%.1f %unit%" ).build ())
379
- .withTags (List . of ( "Measurement" , "Current" ) ).build ();
382
+ .withTags (Point . MEASUREMENT , Property . CURRENT ).build ();
380
383
381
384
/**
382
385
* Electric-voltage: system wide {@link ChannelType} which shows the electric voltage
@@ -386,7 +389,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
386
389
.withDescription ("Current electric voltage" ).withCategory ("Energy" )
387
390
.withStateDescriptionFragment (
388
391
StateDescriptionFragmentBuilder .create ().withReadOnly (true ).withPattern ("%.1f %unit%" ).build ())
389
- .withTags (List . of ( "Measurement" , "Voltage" ) ).build ();
392
+ .withTags (Point . MEASUREMENT , Property . VOLTAGE ).build ();
390
393
391
394
/**
392
395
* Electrical-energy: system wide {@link ChannelType} which shows the electrical energy
@@ -396,7 +399,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
396
399
.withDescription ("Current electric energy" ).withCategory ("Energy" )
397
400
.withStateDescriptionFragment (
398
401
StateDescriptionFragmentBuilder .create ().withReadOnly (true ).withPattern ("%.1f %unit%" ).build ())
399
- .withTags (List . of ( "Measurement" , "Energy" ) ).build ();
402
+ .withTags (Point . MEASUREMENT , Property . ENERGY ).build ();
400
403
401
404
/**
402
405
* UV Index: system wide {@link ChannelType} which shows the UV Index
@@ -405,7 +408,7 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
405
408
.state (SYSTEM_CHANNEL_TYPE_UID_UV_INDEX , "UV Index" , CoreItemFactory .NUMBER )
406
409
.withDescription ("Current UV index" ).withStateDescriptionFragment (StateDescriptionFragmentBuilder .create ()
407
410
.withReadOnly (true ).withPattern ("%d" ).withMinimum (BigDecimal .ONE ).build ())
408
- .withTags (List . of ( "Measurement" , "Ultraviolet" ) ).build ();
411
+ .withTags (Point . MEASUREMENT , Property . ULTRAVIOLET ).build ();
409
412
410
413
private static final Collection <ChannelType > CHANNEL_TYPES = List .of (SYSTEM_CHANNEL_SIGNAL_STRENGTH ,
411
414
SYSTEM_CHANNEL_LOW_BATTERY , SYSTEM_CHANNEL_BATTERY_LEVEL , SYSTEM_TRIGGER , SYSTEM_RAWBUTTON , SYSTEM_BUTTON ,
0 commit comments