tasmor_lib 0.6.0

Rust library to control Tasmota devices via MQTT and HTTP
Documentation
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
// SPDX-License-Identifier: MPL-2.0
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Device capabilities detection and configuration.
//!
//! This module provides types for representing and detecting the capabilities
//! of Tasmota devices. Capabilities can be auto-detected from device status
//! or manually configured.
//!
//! # Auto-Detection
//!
//! When connecting to a device, capabilities can be automatically detected
//! by querying the device status and analyzing the response.
//!
//! # Manual Configuration
//!
//! For faster startup or when auto-detection is not desired, capabilities
//! can be manually specified using the builder pattern.

use crate::response::StatusResponse;

/// Capabilities of a Tasmota device.
///
/// Describes what features a device supports, such as power control,
/// dimming, color temperature, RGB colors, and energy monitoring.
///
/// # Examples
///
/// ```
/// use tasmor_lib::Capabilities;
///
/// // Default capabilities (single relay, no extras)
/// let basic = Capabilities::default();
/// assert_eq!(basic.power_channels(), 1);
/// assert!(!basic.supports_dimmer_control());
///
/// // RGB light bulb capabilities using builder
/// let rgb_bulb = tasmor_lib::CapabilitiesBuilder::new()
///     .with_dimmer_control()
///     .with_color_temperature_control()
///     .with_rgb_control()
///     .build();
///
/// // Neo Coolcam smart plug
/// let neo_coolcam = Capabilities::neo_coolcam();
/// assert!(neo_coolcam.supports_energy_monitoring());
/// ```
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
// Each boolean represents an independent device feature flag that cannot be
// meaningfully combined into an enum or state machine.
#[allow(clippy::struct_excessive_bools)]
pub struct Capabilities {
    /// Number of power relay channels (1-8).
    power_channels: u8,

    /// Supports dimmer/brightness control.
    dimmer_control: bool,

    /// Supports color temperature (CCT) control.
    color_temperature_control: bool,

    /// Supports RGB/HSB color control.
    rgb_control: bool,

    /// Supports energy monitoring (voltage, current, power).
    energy_monitoring: bool,
}

impl Capabilities {
    /// Returns the number of power relay channels (1-8).
    #[must_use]
    pub const fn power_channels(&self) -> u8 {
        self.power_channels
    }

    /// Returns whether the device supports dimmer/brightness control.
    #[must_use]
    pub const fn supports_dimmer_control(&self) -> bool {
        self.dimmer_control
    }

    /// Returns whether the device supports color temperature (CCT) control.
    #[must_use]
    pub const fn supports_color_temperature_control(&self) -> bool {
        self.color_temperature_control
    }

    /// Returns whether the device supports RGB/HSB color control.
    #[must_use]
    pub const fn supports_rgb_control(&self) -> bool {
        self.rgb_control
    }

    /// Returns whether the device supports energy monitoring.
    #[must_use]
    pub const fn supports_energy_monitoring(&self) -> bool {
        self.energy_monitoring
    }

    /// Returns an iterator over the names of enabled features.
    ///
    /// This is useful for introspection and debugging. The returned names
    /// are: `dimmer_control`, `color_temperature_control`, `rgb_control`, `energy_monitoring`.
    ///
    /// # Examples
    ///
    /// ```
    /// use tasmor_lib::Capabilities;
    ///
    /// let caps = Capabilities::rgbcct_light();
    /// let features: Vec<_> = caps.features().collect();
    /// assert!(features.contains(&"dimmer_control"));
    /// assert!(features.contains(&"color_temperature_control"));
    /// assert!(features.contains(&"rgb_control"));
    /// assert!(!features.contains(&"energy_monitoring"));
    /// ```
    pub fn features(&self) -> impl Iterator<Item = &'static str> {
        [
            self.dimmer_control.then_some("dimmer_control"),
            self.color_temperature_control
                .then_some("color_temperature_control"),
            self.rgb_control.then_some("rgb_control"),
            self.energy_monitoring.then_some("energy_monitoring"),
        ]
        .into_iter()
        .flatten()
    }
}

impl Default for Capabilities {
    fn default() -> Self {
        Self {
            power_channels: 1,
            dimmer_control: false,
            color_temperature_control: false,
            rgb_control: false,
            energy_monitoring: false,
        }
    }
}

impl Capabilities {
    /// Creates capabilities for a basic single-relay device.
    #[must_use]
    pub const fn basic() -> Self {
        Self {
            power_channels: 1,
            dimmer_control: false,
            color_temperature_control: false,
            rgb_control: false,
            energy_monitoring: false,
        }
    }

    /// Creates capabilities for a Neo Coolcam smart plug (Module 49).
    ///
    /// - Single relay
    /// - Energy monitoring
    #[must_use]
    pub const fn neo_coolcam() -> Self {
        Self {
            power_channels: 1,
            dimmer_control: false,
            color_temperature_control: false,
            rgb_control: false,
            energy_monitoring: true,
        }
    }

    /// Creates capabilities for an RGB light bulb.
    ///
    /// - Single "relay" (light on/off)
    /// - Dimmer
    /// - RGB color control
    #[must_use]
    pub const fn rgb_light() -> Self {
        Self {
            power_channels: 1,
            dimmer_control: true,
            color_temperature_control: false,
            rgb_control: true,
            energy_monitoring: false,
        }
    }

    /// Creates capabilities for an RGBCCT light bulb (like Athom bulbs).
    ///
    /// - Single "relay" (light on/off)
    /// - Dimmer
    /// - Color temperature
    /// - RGB color control
    #[must_use]
    pub const fn rgbcct_light() -> Self {
        Self {
            power_channels: 1,
            dimmer_control: true,
            color_temperature_control: true,
            rgb_control: true,
            energy_monitoring: false,
        }
    }

    /// Creates capabilities for a CCT-only light (warm/cool white).
    #[must_use]
    pub const fn cct_light() -> Self {
        Self {
            power_channels: 1,
            dimmer_control: true,
            color_temperature_control: true,
            rgb_control: false,
            energy_monitoring: false,
        }
    }

    /// Attempts to detect capabilities from a status response.
    ///
    /// This method analyzes the status response to determine:
    /// - Number of power channels from POWER fields
    /// - Dimmer support from Dimmer field in `StatusSTS`
    /// - Color support from `HSBColor`/CT fields in `StatusSTS`
    /// - Energy support from ENERGY block in `StatusSNS` or `StatusSTS`
    ///
    /// # Arguments
    ///
    /// * `status` - The full status response from Status 0
    #[must_use]
    pub fn from_status(status: &StatusResponse) -> Self {
        let mut caps = Self::default();

        // Detect power channels from status
        if let Some(ref device) = status.status {
            // Module ID can give hints
            if device.module == 49 {
                // Neo Coolcam - has energy monitoring
                caps.energy_monitoring = true;
            }

            // Count friendly names as a proxy for relay count
            if !device.friendly_name.is_empty() {
                // Safe: we clamp to max 8, which fits in u8
                #[allow(clippy::cast_possible_truncation)]
                let count = device.friendly_name.len().min(8) as u8;
                caps.power_channels = count;
            }
        }

        // Check for light capabilities in StatusSTS (Status 11 - runtime state)
        // This is where Tasmota reports Dimmer, CT, HSBColor, Color, etc.
        if let Some(ref state) = status.sensor_status {
            if state.get("Dimmer").is_some() {
                caps.dimmer_control = true;
            }
            if state.get("CT").is_some() {
                caps.color_temperature_control = true;
            }
            if state.get("HSBColor").is_some() {
                caps.rgb_control = true;
            }
            // Also check for ENERGY in StatusSTS
            if state.get("ENERGY").is_some() {
                caps.energy_monitoring = true;
            }
        }

        // Also check for ENERGY in StatusSNS (Status 10 - sensor data)
        // Some devices report energy data here
        if status
            .sensors
            .as_ref()
            .is_some_and(|s| s.get("ENERGY").is_some())
        {
            caps.energy_monitoring = true;
        }

        caps
    }

    /// Returns whether this device supports any light control features.
    #[must_use]
    pub const fn is_light(&self) -> bool {
        self.dimmer_control || self.color_temperature_control || self.rgb_control
    }

    /// Returns whether this device supports energy monitoring.
    #[must_use]
    pub const fn has_energy_monitoring(&self) -> bool {
        self.energy_monitoring
    }

    /// Returns whether this device has multiple relays.
    #[must_use]
    pub const fn is_multi_relay(&self) -> bool {
        self.power_channels > 1
    }
}

/// Builder for creating custom capabilities.
#[derive(Debug, Default)]
pub struct CapabilitiesBuilder {
    inner: Capabilities,
}

impl CapabilitiesBuilder {
    /// Creates a new builder with default capabilities.
    #[must_use]
    pub fn new() -> Self {
        Self::default()
    }

    /// Sets the number of power channels.
    #[must_use]
    pub fn power_channels(mut self, count: u8) -> Self {
        self.inner.power_channels = count.clamp(1, 8);
        self
    }

    /// Enables dimmer control support.
    #[must_use]
    pub fn with_dimmer_control(mut self) -> Self {
        self.inner.dimmer_control = true;
        self
    }

    /// Enables color temperature control support.
    #[must_use]
    pub fn with_color_temperature_control(mut self) -> Self {
        self.inner.color_temperature_control = true;
        self
    }

    /// Enables RGB control support.
    #[must_use]
    pub fn with_rgb_control(mut self) -> Self {
        self.inner.rgb_control = true;
        self
    }

    /// Enables energy monitoring support.
    #[must_use]
    pub fn with_energy_monitoring(mut self) -> Self {
        self.inner.energy_monitoring = true;
        self
    }

    /// Builds the capabilities.
    #[must_use]
    pub fn build(self) -> Capabilities {
        self.inner
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::response::StatusResponse;

    #[test]
    fn default_capabilities() {
        let caps = Capabilities::default();
        assert_eq!(caps.power_channels, 1);
        assert!(!caps.dimmer_control);
        assert!(!caps.color_temperature_control);
        assert!(!caps.rgb_control);
        assert!(!caps.energy_monitoring);
    }

    #[test]
    fn neo_coolcam_capabilities() {
        let caps = Capabilities::neo_coolcam();
        assert_eq!(caps.power_channels, 1);
        assert!(!caps.dimmer_control);
        assert!(caps.energy_monitoring);
    }

    #[test]
    fn rgbcct_light_capabilities() {
        let caps = Capabilities::rgbcct_light();
        assert!(caps.dimmer_control);
        assert!(caps.color_temperature_control);
        assert!(caps.rgb_control);
        assert!(!caps.energy_monitoring);
        assert!(caps.is_light());
    }

    #[test]
    fn builder_pattern() {
        let caps = CapabilitiesBuilder::new()
            .power_channels(2)
            .with_dimmer_control()
            .with_energy_monitoring()
            .build();

        assert_eq!(caps.power_channels, 2);
        assert!(caps.dimmer_control);
        assert!(caps.energy_monitoring);
        assert!(!caps.rgb_control);
    }

    #[test]
    fn capability_checks() {
        let light = Capabilities::rgb_light();
        assert!(light.is_light());
        assert!(!light.has_energy_monitoring());
        assert!(!light.is_multi_relay());

        let plug = Capabilities::neo_coolcam();
        assert!(!plug.is_light());
        assert!(plug.has_energy_monitoring());

        let multi = CapabilitiesBuilder::new().power_channels(4).build();
        assert!(multi.is_multi_relay());
    }

    #[test]
    fn features_iterator() {
        // No features enabled
        let basic = Capabilities::basic();
        assert_eq!(basic.features().count(), 0);

        // Some features enabled
        let rgb = Capabilities::rgb_light();
        let features: Vec<_> = rgb.features().collect();
        assert_eq!(features.len(), 2);
        assert!(features.contains(&"dimmer_control"));
        assert!(features.contains(&"rgb_control"));

        // All features enabled
        let full = CapabilitiesBuilder::new()
            .with_dimmer_control()
            .with_color_temperature_control()
            .with_rgb_control()
            .with_energy_monitoring()
            .build();
        let all_features: Vec<_> = full.features().collect();
        assert_eq!(all_features.len(), 4);
        assert!(all_features.contains(&"dimmer_control"));
        assert!(all_features.contains(&"color_temperature_control"));
        assert!(all_features.contains(&"rgb_control"));
        assert!(all_features.contains(&"energy_monitoring"));
    }

    // ========================================================================
    // Tests for Capabilities::from_status() based on real Tasmota responses
    // Reference: https://tasmota.github.io/docs/JSON-Status-Responses/
    // ========================================================================

    #[test]
    fn from_status_detects_neo_coolcam_by_module_id() {
        // Neo Coolcam Power Plug has Module ID 49
        // Reference: https://tasmota.github.io/docs/Commands/#management
        let json = r#"{
            "Status": {
                "Module": 49,
                "DeviceName": "Neo Coolcam Plug",
                "FriendlyName": ["Plug"],
                "Topic": "tasmota_plug",
                "Power": 1
            }
        }"#;

        let status: StatusResponse = serde_json::from_str(json).unwrap();
        let caps = Capabilities::from_status(&status);

        assert!(
            caps.energy_monitoring,
            "Neo Coolcam (Module 49) should have energy monitoring"
        );
        assert_eq!(caps.power_channels, 1);
    }

    #[test]
    fn from_status_detects_multi_relay_from_friendly_names() {
        // Tasmota uses FriendlyName array to indicate multiple relays
        // Reference: https://tasmota.github.io/docs/JSON-Status-Responses/
        // Status response example: {"Status": {"FriendlyName": ["Relay1", "Relay2", "Relay3", "Relay4"]}}
        let json = r#"{
            "Status": {
                "Module": 18,
                "DeviceName": "4CH Pro",
                "FriendlyName": ["Relay 1", "Relay 2", "Relay 3", "Relay 4"],
                "Topic": "tasmota_4ch"
            }
        }"#;

        let status: StatusResponse = serde_json::from_str(json).unwrap();
        let caps = Capabilities::from_status(&status);

        assert_eq!(caps.power_channels, 4);
        assert!(caps.is_multi_relay());
    }

    #[test]
    fn from_status_detects_energy_from_status_sns() {
        // Energy data appears in StatusSNS (Status 10) with ENERGY object
        // Reference: https://tasmota.github.io/docs/JSON-Status-Responses/
        // Example: "ENERGY": {"Total": 3.185, "Yesterday": 3.058, "Today": 0.127, "Power": 45, "Voltage": 230}
        let json = r#"{
            "Status": {
                "Module": 18,
                "DeviceName": "Smart Plug",
                "FriendlyName": ["Plug"]
            },
            "StatusSTS": {
                "POWER": "ON",
                "ENERGY": {
                    "Total": 3.185,
                    "Yesterday": 3.058,
                    "Today": 0.127,
                    "Power": 45,
                    "Factor": 0.95,
                    "Voltage": 230,
                    "Current": 0.195
                }
            }
        }"#;

        let status: StatusResponse = serde_json::from_str(json).unwrap();
        let caps = Capabilities::from_status(&status);

        assert!(
            caps.energy_monitoring,
            "Device with ENERGY in StatusSTS should have energy monitoring"
        );
    }

    #[test]
    fn from_status_detects_dimmer_capability() {
        // Light devices report Dimmer in StatusSTS (Status 11 - runtime state)
        // Reference: https://tasmota.github.io/docs/Lights/
        // Dimmer range: 0-100%
        let json = r#"{
            "Status": {
                "Module": 18,
                "DeviceName": "Dimmable Light",
                "FriendlyName": ["Light"]
            },
            "StatusSTS": {
                "Time": "2024-01-15T12:00:00",
                "POWER": "ON",
                "Dimmer": 75
            }
        }"#;

        let status: StatusResponse = serde_json::from_str(json).unwrap();
        let caps = Capabilities::from_status(&status);

        assert!(
            caps.dimmer_control,
            "Device with Dimmer in StatusSTS should have dimmer capability"
        );
        assert!(caps.is_light());
    }

    #[test]
    fn from_status_detects_color_temperature_capability() {
        // CCT lights report CT (color temperature) in mireds (153-500) in StatusSTS
        // Reference: https://tasmota.github.io/docs/Lights/
        // CT 153 = 6500K (cold white), CT 500 = 2000K (warm white)
        let json = r#"{
            "Status": {
                "Module": 18,
                "DeviceName": "CCT Bulb",
                "FriendlyName": ["Bulb"]
            },
            "StatusSTS": {
                "Time": "2024-01-15T12:00:00",
                "POWER": "ON",
                "CT": 250
            }
        }"#;

        let status: StatusResponse = serde_json::from_str(json).unwrap();
        let caps = Capabilities::from_status(&status);

        assert!(
            caps.color_temperature_control,
            "Device with CT in StatusSTS should have color temperature capability"
        );
        assert!(caps.is_light());
    }

    #[test]
    fn from_status_detects_rgb_capability() {
        // RGB lights report HSBColor as "Hue,Saturation,Brightness" in StatusSTS
        // Reference: https://tasmota.github.io/docs/Lights/
        // Example: "HSBColor": "180,100,100" (Hue=180°, Sat=100%, Bright=100%)
        let json = r#"{
            "Status": {
                "Module": 18,
                "DeviceName": "RGB Bulb",
                "FriendlyName": ["Bulb"]
            },
            "StatusSTS": {
                "Time": "2024-01-15T12:00:00",
                "POWER": "ON",
                "HSBColor": "180,100,100"
            }
        }"#;

        let status: StatusResponse = serde_json::from_str(json).unwrap();
        let caps = Capabilities::from_status(&status);

        assert!(
            caps.rgb_control,
            "Device with HSBColor in StatusSTS should have RGB capability"
        );
        assert!(caps.is_light());
    }

    #[test]
    fn from_status_detects_full_rgbcct_light() {
        // RGBCCT lights (5-channel) have Dimmer, CT, and HSBColor in StatusSTS
        // Reference: https://tasmota.github.io/docs/Lights/
        // Response format from Status 11 (StatusSTS)
        let json = r#"{
            "Status": {
                "Module": 18,
                "DeviceName": "RGBCCT Bulb",
                "FriendlyName": ["Smart Bulb"]
            },
            "StatusSTS": {
                "Time": "2024-01-15T12:00:00",
                "POWER": "ON",
                "Dimmer": 100,
                "Color": "255,128,64,200,100",
                "HSBColor": "20,75,100",
                "White": 78,
                "CT": 300,
                "Channel": [100, 50, 25, 78, 39]
            }
        }"#;

        let status: StatusResponse = serde_json::from_str(json).unwrap();
        let caps = Capabilities::from_status(&status);

        assert!(caps.dimmer_control, "RGBCCT light should have dimmer");
        assert!(
            caps.color_temperature_control,
            "RGBCCT light should have color temperature"
        );
        assert!(caps.rgb_control, "RGBCCT light should have RGB");
        assert!(caps.is_light());
    }

    #[test]
    fn from_status_basic_switch_no_special_capabilities() {
        // Basic switch/relay with no light or energy features
        let json = r#"{
            "Status": {
                "Module": 1,
                "DeviceName": "Basic Switch",
                "FriendlyName": ["Switch"],
                "Topic": "tasmota_switch",
                "Power": 0
            }
        }"#;

        let status: StatusResponse = serde_json::from_str(json).unwrap();
        let caps = Capabilities::from_status(&status);

        assert_eq!(caps.power_channels, 1);
        assert!(!caps.dimmer_control);
        assert!(!caps.color_temperature_control);
        assert!(!caps.rgb_control);
        assert!(!caps.energy_monitoring);
        assert!(!caps.is_light());
    }

    #[test]
    fn from_status_power_channels_clamped_to_8() {
        // Tasmota supports max 8 relays (POWER1-POWER8)
        // Reference: https://tasmota.github.io/docs/Commands/#power
        let json = r#"{
            "Status": {
                "Module": 18,
                "DeviceName": "Many Relays",
                "FriendlyName": ["R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10"]
            }
        }"#;

        let status: StatusResponse = serde_json::from_str(json).unwrap();
        let caps = Capabilities::from_status(&status);

        assert_eq!(
            caps.power_channels, 8,
            "Power channels should be clamped to max 8"
        );
    }

    #[test]
    fn from_status_empty_response() {
        // Handle gracefully when status response has no data
        let json = r#"{}"#;

        let status: StatusResponse = serde_json::from_str(json).unwrap();
        let caps = Capabilities::from_status(&status);

        // Should return defaults
        assert_eq!(caps.power_channels, 1);
        assert!(!caps.dimmer_control);
        assert!(!caps.color_temperature_control);
        assert!(!caps.rgb_control);
        assert!(!caps.energy_monitoring);
    }

    #[test]
    fn builder_with_color_temperature_control() {
        let caps = CapabilitiesBuilder::new()
            .with_color_temperature_control()
            .build();

        assert!(caps.color_temperature_control);
        assert!(caps.is_light());
    }

    #[test]
    fn builder_with_rgb_control() {
        let caps = CapabilitiesBuilder::new().with_rgb_control().build();

        assert!(caps.rgb_control);
        assert!(caps.is_light());
    }
}