-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbosch-camera-card.js
More file actions
2586 lines (2412 loc) · 128 KB
/
bosch-camera-card.js
File metadata and controls
2586 lines (2412 loc) · 128 KB
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
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Bosch Camera Card — Custom Lovelace Card
* ==========================================
* Displays a Bosch Smart Home camera with live streaming state,
* status indicator, event info, and stream controls.
*
* Installation:
* 1. Copy bosch-camera-card.js to /config/www/bosch-camera-card.js
* 2. In HA → Settings → Dashboards → ⋮ → Resources → Add resource:
* URL: /local/bosch-camera-card.js
* Type: JavaScript module
* 3. Hard-reload browser (Ctrl+Shift+R)
*
* Card YAML:
* type: custom:bosch-camera-card
* camera_entity: camera.bosch_garten # required
* title: Garten # optional
* # idle refresh: 60 s visible / 1800 s background (Page Visibility API)
*
* Version: 2.7.0
*
* Changes vs 2.6.0:
* - Separate light controls: Front Light, Wallwasher toggle + Intensity slider
* appear below the main Light toggle when entities exist (Outdoor camera).
* - Siren button in Services accordion — triggers acoustic alarm on the camera.
*
* Changes vs 2.4.0:
* - New "Services" accordion: grid of quick-action buttons for
* Snapshot, Zonen lesen, Privacy-Masken, Freunde, Regel erstellen, Verbindung.
* Regel erstellen uses prompt() for name/start/end.
* - Motion zone overlay now uses cloud API zones (normalized x/y/w/h 0-1)
* instead of broken RCP coordinates.
*
* Changes vs 2.3.1:
* - New "Zeitpläne & Zonen" accordion section:
* - Schedule rules list with AN/AUS toggle per rule (calls update_rule service)
* - Delete button per rule (calls delete_rule service)
* - Motion zones count display (from RCP sensor)
* - New entity: rules_entity (sensor.bosch_{cam}_schedule_rules)
* - Optimistic UI for rule toggle and delete
*
* Changes vs 2.1.0:
* - Removed dead _streamingImageLoad() method (snapshot-streaming mode removed in v2.0.0)
* - Cleaned up outdated snapshot-polling changelog entries
*
* Changes vs 1.9.4:
* - "connecting" badge state: while HLS is negotiating (startingLiveVideo=true),
* badge shows amber "connecting" instead of misleading "idle". CSS: orange dot
* with faster pulse (0.8 s). Clears to "streaming" once video plays.
* - Frame Δt in debug line: shows actual ms since last frame load
* (e.g. "fresh 14:23:05 Δ2003ms | 1920×1080") — live proof that 2 s intervals
* are now consistent. Only tracked for fresh frames (not cache restores).
* - Stream uptime counter: badge label updates to "00:47" / "1:23" while streaming,
* refreshing every frame (2 s). Proves session renewal is working — stream stays
* alive past 60 s. Resets when stream stops.
* - Retry on image error during streaming: transient snap.jpg failures (network
* glitch, proxy hiccup) now trigger one immediate retry after 500 ms instead of
* silently showing the previous frame forever.
*
* Changes vs 1.9.4:
* - "connecting" badge state while HLS negotiates (faster pulse 0.8s) → clears to "streaming"
* - Frame Δt in debug line (e.g. "Δ2003ms") — proof of consistent 2s intervals
* - Stream uptime counter in badge ("00:47") — proves session renewal working
* - Retry on snap.jpg error during streaming: immediate 500ms retry
*
* Changes vs 1.8.0:
* - Added 3 collapsible accordion sections below the quality dropdown:
* 1. Benachrichtigungs-Typen: movement/person/audio/trouble/alarm notification toggles
* 2. Erweitert: timestamp overlay, auto-follow, motion detection, record sound, privacy sound
* 3. Diagnose: WiFi signal, firmware, ambient light, movement/audio events today
* - Accordion sections auto-hide when none of their entities exist
* - All new toggle rows use existing _updateToggleBtn pattern
*
* Changes vs 1.7.6:
* - Fix: stale image shown for up to 60 s on page load. When localStorage cache
* restored an old image, _imageLoaded=true blocked the immediate fresh fetch on
* first hass assignment. Now always fetches fresh on first hass, with a subtle
* "Aktualisiere…" spinner overlay on the cached image while loading.
*
* Changes vs 1.7.4:
* - Pan row buttons now use SVG icons (double-chevron left/right, chevron left/right,
* crosshair center) matching the style of all other card buttons.
* Previously used Unicode text characters which rendered inconsistently.
*
* Changes vs 1.7.3:
* - Fix: initial image load was silently skipped because _hass is null when
* _render() fires _scheduleImageLoad(0). HA assigns hass only after setConfig.
* Without localStorage cache the spinner was visible for up to 60 s (first timer
* tick). Fixed: re-trigger _scheduleImageLoad(0) on first hass assignment when
* image hasn't loaded yet.
* - Smaller image requests: pass ?width=<display_width> on every camera proxy URL
* so HA forwards the hint to async_camera_image(). Backend already returns the
* 320×180 RCP thumbnail (~3 KB) via proxy cache, so mobile downloads 3 KB
* instead of a 150 KB 1080p snap.jpg.
* - Snapshot button first poll: 1000 ms → 500 ms (RCP refresh is ~100 ms).
*
* Changes vs 1.6.0:
* - Event-driven snapshot refresh: when sensor.last_event changes (new motion/audio
* event detected), the card automatically refreshes the image after 2.5 s,
* without waiting for the 60 s timer. Works alongside the HA integration's own
* event-driven refresh (v2.8.0) for double-redundant coverage.
*
* Changes vs 1.5.11:
* - Page Visibility API for smart refresh intervals:
* Snapshot refreshes every 60 s when the HA dashboard is visible.
* Drops to every 1800 s (30 min) when the browser tab goes to background.
* Immediately refreshes when the tab returns to foreground.
* Replaces the old configurable refresh_interval_idle (now removed).
* - HA integration (v2.7.0): async_fetch_live_snapshot tries RCP 0x099e
* (320×180 JPEG via cloud proxy) before falling back to snap.jpg.
* Faster and lower bandwidth for idle thumbnail updates.
*
* Changes vs 1.5.10:
* - Added video quality dropdown inside card (select entity):
* Qualität: Auto / Hoch (30 Mbps) / Niedrig (1.9 Mbps)
* Hidden automatically when the select entity doesn't exist or is unavailable.
* Configure with quality_entity: select.bosch_xxx_video_quality in card YAML.
*
* Changes vs 1.5.9:
* - After panning, automatically refresh snapshot after 2s (camera needs time to move)
*
* Changes vs 1.5.8:
* - Added pan controls for 360 cameras (number.bosch_{cam}_pan_position entity)
* ◀◀ ◀ ■ ▶ ▶▶ buttons with current position display; hidden for cameras without pan support
*
* Changes vs 1.5.7:
* - Added Notifications toggle (mdi:bell / mdi:bell-off) using switch.bosch_{cam}_notifications
*
* Changes vs 1.4.8:
* - localStorage (not sessionStorage) → image survives iOS app restart
* - Live stream switches to HLS <video> with audio (via HA camera/stream WS)
* - Audio (Ton) toggle mutes/unmutes the live video in real-time
* - Optimistic UI: toggles (Ton/Licht/Privat/Stream) flip instantly on tap
* - Controls always visible — no collapsible Steuerung section
*
* Changes vs 1.5.2:
* - Retry on image error: if the first load fails (backend not ready yet on startup),
* automatically retry every 3 seconds up to 5 times before giving up.
*
* Changes vs 1.5.2 (continued):
* - hls.js support for Chrome/Firefox: HLS is not natively supported in Chrome;
* hls.js is loaded on demand from CDN. Safari/iOS continue to use native HLS.
*/
class BoschCameraCard extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
this._hass = null;
this._config = null;
this._refreshTimer = null;
this._imgTimestamp = Date.now();
this._lastStreaming = null; // last known streaming state (true/false/null)
this._streamConnecting = false; // true while stream is connecting (overlay shown)
this._connectSteps = null; // setTimeout IDs for progressive overlay text
this._waitingForStream = false; // true while waiting for backend stream ready
this._lastMotionCoordKey = null; // memoization key for motion zone SVG
this._lastPrivacy = null; // last known privacy state (true/false/null)
this._imageLoaded = false; // did we ever successfully load an image?
this._loadingOverlay = false; // is the "Wird geladen" overlay active?
this._loadingTimeout = null; // safety timeout to hide overlay
this._storageKey = null; // localStorage key for cached image dataURL
this._loadRetries = 0; // retry counter for initial image load (max 5)
this._snapshotPollTimer = null; // polling timer during snapshot refresh
this._liveVideoActive = false; // true when HLS <video> is playing
this._startingLiveVideo = false; // true while _startLiveVideo() is in progress
this._hls = null; // hls.js instance for Chrome (null = native or inactive)
this._timerStreaming = false; // whether refresh timer is running at streaming interval
this._optimistic = {}; // optimistic entity states { entityId: "on"/"off" }
this._optimisticTimers = {}; // timers to auto-clear optimistic states
this._visibilityHandler = null; // bound visibilitychange listener
this._lastEventState = null; // last known last_event sensor value — for event detection
this._lastFrameTime = 0; // monotonic ms of last fresh frame — for Δt debug display
this._streamStartTime = 0; // ms when current stream session started — for uptime counter
this._awaitingFresh = false; // true while waiting for a fresh (non-cache) image
this._showMotionZones = false; // runtime toggle for motion zone overlay
this._lastRulesKey = null; // memoization key for rules list HTML
}
// ── Lifecycle ─────────────────────────────────────────────────────────────
connectedCallback() {
this._visibilityHandler = () => this._onVisibilityChange();
document.addEventListener("visibilitychange", this._visibilityHandler);
}
// ── Config ────────────────────────────────────────────────────────────────
setConfig(config) {
if (!config.camera_entity) {
throw new Error("bosch-camera-card: camera_entity is required");
}
this._config = {
camera_entity: config.camera_entity,
title: config.title || null,
refresh_interval_streaming: config.refresh_interval_streaming ?? 2,
show_motion_zones: config.show_motion_zones ?? false,
// idle refresh is handled by Page Visibility API: 60 s visible, 1800 s background
};
this._storageKey = `bosch_cam_${config.camera_entity}`;
const base = config.camera_entity.replace(/^camera\./, "");
this._entities = {
camera: config.camera_entity,
switch: config.switch_entity || `switch.${base}_live_stream`,
audio: config.audio_entity || `switch.${base}_audio`,
light: config.light_entity || `switch.${base}_camera_light`,
privacy: config.privacy_entity || `switch.${base}_privacy_mode`,
notifications: config.notifications_entity || `switch.${base}_notifications`,
intercom: config.intercom_entity || `switch.${base}_intercom`,
speaker: config.speaker_entity || `number.${base}_speaker_level`,
pan: config.pan_entity || `number.${base}_pan_position`,
quality: config.quality_entity || null,
push_status: config.push_status_entity || "sensor.bosch_camera_event_detection",
status: config.status_entity || `sensor.${base}_status`,
events_today: config.events_today_entity || `sensor.${base}_events_today`,
last_event: config.last_event_entity || `sensor.${base}_last_event`,
timestamp: config.timestamp_entity || `switch.${base}_timestamp_overlay`,
autofollow: config.autofollow_entity || `switch.${base}_auto_follow`,
motion: config.motion_entity || `switch.${base}_motion_detection`,
recordSound: config.record_sound_entity || `switch.${base}_record_sound`,
privacySound: config.privacy_sound_entity || `switch.${base}_privacy_sound`,
notifMovement: config.notif_movement_entity || `switch.${base}_movement_notifications`,
notifPerson: config.notif_person_entity || `switch.${base}_person_notifications`,
notifAudio: config.notif_audio_entity || `switch.${base}_audio_notifications`,
notifTrouble: config.notif_trouble_entity || `switch.${base}_trouble_notifications`,
notifAlarm: config.notif_alarm_entity || `switch.${base}_camera_alarm_notifications`,
wifi: config.wifi_entity || `sensor.${base}_wifi_signal`,
firmware: config.firmware_entity || `sensor.${base}_firmware_version`,
ambient: config.ambient_entity || `sensor.${base}_ambient_light`,
movementToday: config.movement_today_entity || `sensor.${base}_movement_events_today`,
audioToday: config.audio_today_entity || `sensor.${base}_audio_events_today`,
motionZones: config.motion_zones_entity || `sensor.${base}_motion_zones`,
scheduleRules: config.rules_entity || `sensor.${base}_schedule_rules`,
frontLight: config.front_light_entity || `switch.${base}_front_light`,
wallwasher: config.wallwasher_entity || `switch.${base}_wallwasher`,
frontLightIntensity: config.front_light_intensity_entity || `number.${base}_front_light_intensity`,
siren: config.siren_entity || `button.${base}_siren`,
};
this._showMotionZones = this._config.show_motion_zones;
this._render();
this._restoreCachedImage();
this._startRefreshTimer();
// Pre-load hls.js in the background so it's cached when the user starts the stream
this._loadHlsJs().catch(() => {});
}
// ── HA state updates ──────────────────────────────────────────────────────
set hass(hass) {
const firstHass = !this._hass;
this._hass = hass;
this._update();
// _render() calls _scheduleImageLoad(0) before _hass is assigned (HA sets hass
// AFTER setConfig), so the first image load silently returns early.
// Always fetch fresh on first hass — even when localStorage cache is showing an
// old image. Show a "refreshing" overlay so the user knows it's updating.
if (firstHass) {
// _awaitingFresh is already true if _restoreCachedImage found a cache.
// For the no-cache case, set it now before triggering any image loads.
this._awaitingFresh = true;
// If cache already showed the "refreshing" overlay, this is a no-op.
// If no cache, this shows the full spinner.
if (this._imageLoaded) {
this._setLoadingOverlay(true, "Aktualisiere…");
}
this._triggerFreshSnapshot();
}
}
disconnectedCallback() {
this._stopRefreshTimer();
if (this._visibilityHandler) {
document.removeEventListener("visibilitychange", this._visibilityHandler);
this._visibilityHandler = null;
}
if (this._loadingTimeout) clearTimeout(this._loadingTimeout);
if (this._snapshotPollTimer) clearTimeout(this._snapshotPollTimer);
Object.values(this._optimisticTimers).forEach(t => clearTimeout(t));
this._stopLiveVideo();
}
// ── Timer ─────────────────────────────────────────────────────────────────
_startRefreshTimer() {
this._stopRefreshTimer();
// No snapshot polling when live video (HLS) is playing or starting
if (this._liveVideoActive || this._startingLiveVideo) return;
// When streaming is active, HLS handles video — no snapshot polling needed.
if (this._isStreaming()) return;
let interval;
if (document.visibilityState === "hidden") {
interval = 1800; // 30 min — page is in background, save resources
} else {
interval = 60; // 1 min — page is visible
}
this._refreshTimer = setInterval(() => {
this._triggerFreshSnapshot();
}, interval * 1000);
}
_onVisibilityChange() {
if (document.visibilityState === "visible" && !this._liveVideoActive) {
// Page just came to foreground — trigger fresh snapshot like on page load
this._triggerFreshSnapshot();
}
// Restart timer with the correct interval (60 s or 1800 s)
this._startRefreshTimer();
}
_stopRefreshTimer() {
if (this._refreshTimer) { clearInterval(this._refreshTimer); this._refreshTimer = null; }
}
_isStreaming() {
if (!this._hass) return false;
const switchId = this._entities.switch;
// Check optimistic state first (immediate feedback after button press)
if (switchId in this._optimistic) return this._optimistic[switchId] === "on";
const sw = this._hass.states[switchId];
if (sw) return sw.state === "on";
const cam = this._hass.states[this._entities.camera];
if (cam?.attributes?.streaming_state) return cam.attributes.streaming_state === "active";
return cam?.state === "streaming";
}
_triggerFreshSnapshot() {
// Tell backend to fetch a fresh image and bypass HA's 60s frame_interval cache.
// _force_image_refresh makes frame_interval=0.1s so the next proxy request
// actually calls async_camera_image instead of returning HA's internal cache.
// Cloud API response varies (1.5–5s), so fetch at 1.5s and 4s.
this._callService("bosch_shc_camera", "trigger_snapshot", {});
this._scheduleImageLoad(1500);
this._scheduleImageLoad(4000);
}
// ── Full DOM render (once on setConfig) ───────────────────────────────────
_render() {
this.shadowRoot.innerHTML = `
<style>
:host { display: block; font-family: var(--primary-font-family, Roboto, sans-serif); }
ha-card {
overflow: hidden;
border-radius: var(--ha-card-border-radius, 12px);
background: var(--ha-card-background, var(--card-background-color, #1c1c1e));
box-shadow: var(--ha-card-box-shadow, 0 2px 8px rgba(0,0,0,.3));
}
/* Header */
.header {
display: flex; align-items: center; justify-content: space-between;
padding: 12px 14px 8px;
}
.header-left { display: flex; align-items: center; gap: 8px; }
.title {
font-size: 15px; font-weight: 600;
color: var(--primary-text-color, #e5e5ea);
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status-dot {
width: 8px; height: 8px; border-radius: 50%;
background: #636366; flex-shrink: 0; transition: background 0.3s;
}
.status-dot.online { background: #30d158; }
.status-dot.offline { background: #ff453a; }
/* Stream badge */
.stream-badge {
display: inline-flex; align-items: center; gap: 5px;
font-size: 11px; font-weight: 600; letter-spacing: .4px;
text-transform: uppercase; padding: 3px 8px; border-radius: 20px;
transition: all 0.3s; white-space: nowrap;
}
.stream-badge.idle { background: rgba(99,99,102,.25); color: #8e8e93; }
.stream-badge.streaming { background: rgba(0,122,255,.2); color: #0a84ff; box-shadow: 0 0 0 1px rgba(0,122,255,.3); }
.stream-badge.connecting { background: rgba(255,159,10,.2); color: #ff9f0a; box-shadow: 0 0 0 1px rgba(255,159,10,.3); }
.stream-badge .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.stream-badge.idle .dot { background: #636366; }
.stream-badge.streaming .dot { background: #0a84ff; animation: pulse 1.5s infinite; }
.stream-badge.connecting .dot { background: #ff9f0a; animation: pulse 0.8s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
/* Push status badge */
.push-badge {
display: inline-flex; align-items: center; gap: 4px;
font-size: 10px; font-weight: 600; letter-spacing: .3px;
text-transform: uppercase; padding: 2px 6px; border-radius: 12px;
white-space: nowrap;
}
.push-badge.fcm { background: rgba(48,209,88,.15); color: #30d158; }
.push-badge.poll { background: rgba(99,99,102,.2); color: #8e8e93; }
.push-badge .pdot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.push-badge.fcm .pdot { background: #30d158; }
.push-badge.poll .pdot { background: #636366; }
/* Connection type badge (LAN / Cloud) */
.conn-badge {
display: inline-flex; align-items: center; gap: 4px;
font-size: 10px; font-weight: 600; letter-spacing: .3px;
padding: 2px 7px; border-radius: 12px; white-space: nowrap;
}
.conn-badge.local { background: rgba(48,209,88,.15); color: #30d158; }
.conn-badge.remote { background: rgba(99,99,102,.2); color: #8e8e93; }
.conn-badge.hidden { display: none; }
/* Camera image area */
.img-wrapper { position: relative; width: 100%; background: #000; line-height: 0; aspect-ratio: 16/9; }
.cam-img {
width: 100%; height: 100%; display: block; object-fit: cover;
min-height: 160px; transition: opacity 0.3s;
}
.cam-img.hidden { opacity: 0; }
/* Live video element — absolute so it overlays the snapshot image
without layout shift. Image stays visible underneath until video
fires "playing" event, avoiding the black gap. */
.cam-video {
position: absolute; inset: 0;
width: 100%; height: 100%; display: block; object-fit: cover;
min-height: 160px; background: transparent;
}
/* Fullscreen — native API (desktop/Android) */
.img-wrapper:fullscreen,
.img-wrapper:-webkit-full-screen {
background: #000;
display: flex; align-items: center; justify-content: center;
width: 100vw; height: 100vh;
}
.img-wrapper:fullscreen .cam-img,
.img-wrapper:-webkit-full-screen .cam-img,
.img-wrapper:fullscreen .cam-video,
.img-wrapper:-webkit-full-screen .cam-video {
width: 100vw; height: 100vh;
object-fit: contain; min-height: unset;
}
/* Fullscreen — CSS fallback for iOS Safari (position:fixed overlay) */
:host(.fs-active) {
position: fixed !important; inset: 0 !important;
z-index: 9999 !important; background: #000 !important;
display: flex !important; align-items: center !important; justify-content: center !important;
}
/* Hide header, controls and other elements in fullscreen */
:host(.fs-active) .header,
:host(.fs-active) .info-row,
:host(.fs-active) .btn-row,
:host(.fs-active) .switch-rows,
:host(.fs-active) .quality-section,
:host(.fs-active) .accordion { display: none !important; }
:host(.fs-active) .img-wrapper { aspect-ratio: unset; width: 100vw; height: 100vh; }
:host(.fs-active) .cam-img,
:host(.fs-active) .cam-video { object-fit: contain; min-height: unset; }
:host(.fs-active) ha-card { width: 100vw; height: 100vh; border-radius: 0 !important; overflow: hidden; }
:host(.fs-active) .cam-img,
:host(.fs-active) .cam-video { width: 100vw; height: 100vh; object-fit: contain; min-height: unset; }
/* Motion zones SVG overlay */
.motion-zones-overlay {
position: absolute; inset: 0; z-index: 5;
width: 100%; height: 100%;
pointer-events: none; opacity: 0;
transition: opacity 0.3s;
}
.motion-zones-overlay.visible { opacity: 1; }
.motion-zones-overlay rect {
fill: rgba(0, 122, 255, 0.15);
stroke: rgba(0, 122, 255, 0.6);
stroke-width: 0.5;
}
.motion-zones-overlay rect:nth-child(2) { fill: rgba(52, 199, 89, 0.15); stroke: rgba(52, 199, 89, 0.6); }
.motion-zones-overlay rect:nth-child(3) { fill: rgba(255, 159, 10, 0.15); stroke: rgba(255, 159, 10, 0.6); }
.motion-zones-overlay rect:nth-child(4) { fill: rgba(255, 69, 58, 0.15); stroke: rgba(255, 69, 58, 0.6); }
.motion-zones-overlay rect:nth-child(5) { fill: rgba(175, 82, 222, 0.15); stroke: rgba(175, 82, 222, 0.6); }
/* Loading overlay — must be above both cam-img and cam-video */
.loading-overlay {
position: absolute; inset: 0; z-index: 10;
display: flex; flex-direction: column; align-items: center; justify-content: center;
background: rgba(0,0,0,.85);
gap: 12px;
opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.loading-overlay.visible { opacity: 1; pointer-events: auto; }
/* Semi-transparent overlay when refreshing an existing image — old image stays visible, spinner on top */
.loading-overlay.refreshing { background: rgba(0,0,0,.4); }
.spinner {
width: 36px; height: 36px;
border: 3px solid rgba(255,255,255,.2);
border-top-color: #fff;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
font-size: 13px; color: rgba(255,255,255,.75); font-weight: 500;
}
/* Image overlay (last event / events today) */
.img-overlay {
position: absolute; bottom: 0; left: 0; right: 0;
padding: 20px 12px 8px;
background: linear-gradient(transparent, rgba(0,0,0,.55));
display: flex; align-items: flex-end; justify-content: space-between;
pointer-events: none;
}
.last-event-overlay, .events-overlay { font-size: 11px; color: rgba(255,255,255,.8); }
/* Info row */
.info-row {
display: flex; align-items: center; justify-content: space-between;
padding: 8px 14px; gap: 10px;
}
.info-item { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.info-label {
font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
color: var(--secondary-text-color, #8e8e93);
}
.info-value {
font-size: 13px; color: var(--primary-text-color, #e5e5ea);
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Buttons */
.btn-row { display: flex; gap: 8px; padding: 0 12px 12px; }
.btn {
flex: 1; display: flex; align-items: center; justify-content: center;
gap: 6px; padding: 9px 10px; border-radius: 10px; border: none;
cursor: pointer; font-size: 13px; font-weight: 500; font-family: inherit;
transition: opacity 0.15s, transform 0.1s;
-webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); opacity: .8; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-snapshot { background: rgba(99,99,102,.2); color: var(--primary-text-color, #e5e5ea); }
.btn-snapshot.loading { background: rgba(99,99,102,.35); }
.btn-stream { background: rgba(10,132,255,.18); color: #0a84ff; }
.btn-stream.active { background: rgba(255,69,58,.18); color: #ff453a; }
.btn-fullscreen { background: rgba(99,99,102,.15); color: var(--secondary-text-color, #8e8e93); flex: 0 0 auto; padding: 9px 12px; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-spinner {
width: 14px; height: 14px;
border: 2px solid rgba(255,255,255,.3);
border-top-color: currentColor;
border-radius: 50%;
animation: spin 0.8s linear infinite;
flex-shrink: 0;
}
/* Switch rows — Ton / Licht / Privat */
.switch-rows { display: flex; flex-direction: column; padding: 0 12px 12px; gap: 2px; }
.sw-row {
display: flex; align-items: center; justify-content: space-between;
padding: 9px 4px; cursor: pointer; border-radius: 8px;
-webkit-tap-highlight-color: transparent;
transition: background 0.15s;
}
.sw-row:active { background: rgba(99,99,102,.12); }
.sw-left {
display: flex; align-items: center; gap: 10px;
color: var(--primary-text-color, #e5e5ea); font-size: 13px; font-weight: 500;
}
.sw-left svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--secondary-text-color, #8e8e93); }
.sw-row.on .sw-left svg { color: #0a84ff; }
.sw-row.privacy-row.on .sw-left svg { color: #ff453a; }
/* iOS-style toggle */
.sw-toggle {
width: 44px; height: 26px; border-radius: 13px;
background: rgba(99,99,102,.4); border: none; padding: 0;
position: relative; flex-shrink: 0; cursor: pointer;
transition: background 0.25s;
}
.sw-row.on .sw-toggle { background: #30d158; }
.sw-row.privacy-row.on .sw-toggle { background: #ff453a; }
.sw-thumb {
width: 22px; height: 22px; border-radius: 50%; background: #fff;
position: absolute; top: 2px; left: 2px;
box-shadow: 0 1px 4px rgba(0,0,0,.4);
transition: transform 0.25s cubic-bezier(.4,0,.2,1);
}
.sw-row.on .sw-thumb { transform: translateX(18px); }
/* Privacy placeholder — shown when no image + privacy mode is ON */
.privacy-placeholder {
position: absolute; inset: 0;
display: flex; flex-direction: column; align-items: center; justify-content: center;
background: rgba(0,0,0,.82); gap: 10px;
opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.privacy-placeholder.visible { opacity: 1; }
.privacy-placeholder svg { width: 44px; height: 44px; color: rgba(255,255,255,.35); }
.privacy-placeholder span { font-size: 13px; color: rgba(255,255,255,.45); font-weight: 500; }
/* Quality select */
.quality-section { padding: 0 12px 12px; }
.quality-row { display: flex; align-items: center; gap: 10px; }
.quality-label { font-size: 13px; color: var(--secondary-text-color, #8e8e93); flex-shrink: 0; }
.quality-select {
flex: 1; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.12);
border-radius: 8px; color: var(--primary-text-color, #e5e5ea); font-size: 13px;
padding: 6px 10px; cursor: pointer; font-family: inherit;
-webkit-appearance: none; appearance: none;
}
.quality-select:focus { outline: none; background: rgba(255,255,255,.15); }
.quality-select option { background: #2c2c2e; color: #e5e5ea; }
/* Pan controls */
.pan-section { padding: 0 12px 12px; }
.pan-row { display: flex; align-items: center; gap: 6px; }
.pan-btn {
background: rgba(128,128,128,.15); border: none; border-radius: 6px;
color: var(--primary-text-color, #333); cursor: pointer; padding: 6px 10px; flex: 1;
font-family: inherit; -webkit-tap-highlight-color: transparent;
transition: background 0.15s;
display: flex; align-items: center; justify-content: center;
}
.pan-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.pan-btn:hover { background: rgba(128,128,128,.25); }
.pan-btn:active { background: rgba(128,128,128,.35); }
.pan-pos { margin-left: auto; font-size: 12px; opacity: .7; color: var(--primary-text-color, #e5e5ea); white-space: nowrap; }
/* Accordion sections */
.accordion { border-top: 1px solid rgba(255,255,255,.06); }
.accordion-header {
display: flex; align-items: center; justify-content: space-between;
padding: 10px 14px; cursor: pointer;
-webkit-tap-highlight-color: transparent;
transition: background 0.15s;
}
.accordion-header:active { background: rgba(99,99,102,.08); }
.accordion-title {
font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
color: var(--secondary-text-color, #8e8e93);
}
.accordion-chevron {
width: 16px; height: 16px; color: var(--secondary-text-color, #8e8e93);
transition: transform 0.25s ease;
flex-shrink: 0;
}
.accordion.open .accordion-chevron { transform: rotate(180deg); }
.accordion-body {
max-height: 0; overflow: hidden;
transition: max-height 0.3s ease;
}
.accordion.open .accordion-body { max-height: 600px; }
.accordion-content { padding: 0 12px 12px; }
.accordion-content .sw-row { padding: 7px 4px; }
/* Service grid inside accordion */
.svc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px 0; }
.svc-btn { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.03); color: var(--primary-text-color, #e1e1e1); font-size: 11px; cursor: pointer; transition: background .15s; }
.svc-btn:hover { background: rgba(255,255,255,.08); }
.svc-btn:active { background: rgba(255,255,255,.12); }
.svc-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.svc-btn.running { opacity: 0.5; pointer-events: none; }
/* Rule row inside accordion */
.rule-row { display: flex; align-items: center; justify-content: space-between; padding: 5px 4px; font-size: 12px; border-bottom: 1px solid rgba(255,255,255,.04); }
.rule-row .rule-info { flex: 1; min-width: 0; }
.rule-row .rule-name { font-weight: 500; color: var(--primary-text-color, #e1e1e1); }
.rule-row .rule-time { color: #999; font-size: 11px; }
.rule-row .rule-days { color: #888; font-size: 10px; }
.rule-row .rule-toggle { cursor: pointer; padding: 2px 8px; border-radius: 4px; border: 1px solid rgba(255,255,255,.15); background: transparent; color: #999; font-size: 11px; margin-left: 6px; }
.rule-row .rule-toggle.active { background: rgba(52,199,89,.15); color: #34c759; border-color: rgba(52,199,89,.3); }
.rule-row .rule-delete { cursor: pointer; padding: 2px 6px; border-radius: 4px; border: 1px solid rgba(255,59,48,.2); background: transparent; color: #666; font-size: 11px; margin-left: 4px; }
.rule-row .rule-delete:hover { background: rgba(255,59,48,.15); color: #ff3b30; }
/* Diagnostic row inside accordion */
.diag-row {
display: flex; align-items: center; justify-content: space-between;
padding: 6px 4px;
}
.diag-label {
font-size: 13px; color: var(--secondary-text-color, #8e8e93);
display: flex; align-items: center; gap: 8px;
}
.diag-label svg { width: 16px; height: 16px; flex-shrink: 0; }
.diag-value {
font-size: 13px; color: var(--primary-text-color, #e5e5ea); font-weight: 500;
}
</style>
<ha-card>
<div class="header">
<div class="header-left">
<div class="status-dot unknown" id="status-dot"></div>
<span class="title" id="title">Bosch Camera</span>
</div>
<div style="display:flex;align-items:center;gap:6px">
<div class="push-badge poll" id="push-badge">
<div class="pdot"></div>
<span id="push-label">poll</span>
</div>
<div class="conn-badge hidden" id="conn-badge"></div>
<div class="stream-badge idle" id="stream-badge">
<div class="dot"></div>
<span id="stream-label">idle</span>
</div>
</div>
</div>
<div class="img-wrapper" id="img-wrapper">
<img class="cam-img hidden" id="cam-img" alt="Camera" style="cursor:pointer" />
<video class="cam-video" id="cam-video" autoplay playsinline style="display:none; cursor:pointer"></video>
<div class="loading-overlay visible" id="loading-overlay">
<div class="spinner"></div>
<span class="loading-text" id="loading-text">Bild wird geladen…</span>
</div>
<div class="privacy-placeholder" id="privacy-placeholder">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
<path d="M7 11V7a5 5 0 0110 0v4"/>
</svg>
<span>Privat-Modus aktiv</span>
</div>
<svg class="motion-zones-overlay" id="motion-zones-overlay" viewBox="0 0 100 100" preserveAspectRatio="none"></svg>
<div class="img-overlay">
<span class="last-event-overlay" id="last-event-overlay"></span>
<span class="events-overlay" id="events-overlay"></span>
</div>
</div>
<div class="info-row">
<div class="info-item">
<span class="info-label">Status</span>
<span class="info-value" id="info-status">—</span>
</div>
<div class="info-item">
<span class="info-label">Letztes Event</span>
<span class="info-value" id="info-last-event">—</span>
</div>
<div class="info-item" style="text-align:right">
<span class="info-label">Heute</span>
<span class="info-value" id="info-events-today">—</span>
</div>
</div>
<div class="btn-row">
<button class="btn btn-snapshot" id="btn-snapshot">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"/>
<circle cx="12" cy="13" r="4"/>
</svg>
<span id="btn-snapshot-label">Snapshot</span>
</button>
<button class="btn btn-stream" id="btn-stream">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polygon points="23 7 16 12 23 17 23 7"/>
<rect x="1" y="5" width="15" height="14" rx="2" ry="2"/>
</svg>
<span id="btn-stream-label">Live Stream</span>
</button>
<button class="btn btn-fullscreen" id="btn-fullscreen" title="Vollbild">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M8 3H5a2 2 0 00-2 2v3m18 0V5a2 2 0 00-2-2h-3m0 18h3a2 2 0 002-2v-3M3 16v3a2 2 0 002 2h3"/>
</svg>
</button>
</div>
<div class="switch-rows">
<div class="sw-row" id="btn-audio">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/>
<path d="M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07"/>
</svg>
<span>Ton / Video</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-light">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="5"/>
<line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
<line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
</svg>
<span>Licht</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<!-- Light sub-controls (front light, wallwasher, intensity) -->
<div class="light-sub-controls" id="light-sub-controls" style="display:none;padding:0 0 0 28px;border-left:2px solid rgba(255,204,0,.3);margin:0 0 0 16px">
<div class="sw-row" id="btn-front-light" style="padding:4px 4px">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:16px;height:16px">
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10"/>
</svg>
<span style="font-size:13px">Frontlicht</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-wallwasher" style="padding:4px 4px">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:16px;height:16px">
<path d="M9 18h6M10 22h4M12 2v1M4.22 4.22l.7.7M1 12h1M20.78 4.22l-.7.7M23 12h-1"/>
<path d="M18 12a6 6 0 10-12 0c0 2.21 1.34 4.1 3 5h6c1.66-.9 3-2.79 3-5z"/>
</svg>
<span style="font-size:13px">Wallwasher</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div id="intensity-row" style="display:flex;align-items:center;gap:8px;padding:4px 4px;font-size:13px">
<span style="white-space:nowrap">Helligkeit</span>
<input type="range" id="intensity-slider" min="0" max="100" step="5" style="flex:1;accent-color:#fc0;height:4px">
<span id="intensity-value" style="min-width:32px;text-align:right;color:#999">—</span>
</div>
</div>
<div class="sw-row privacy-row" id="btn-privacy">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
<path d="M7 11V7a5 5 0 0110 0v4"/>
</svg>
<span>Privat</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-notifications">
<div class="sw-left">
<svg id="notif-icon-on" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M18 8A6 6 0 006 8c0 7-3 9-3 9h18s-3-2-3-9"/>
<path d="M13.73 21a2 2 0 01-3.46 0"/>
</svg>
<svg id="notif-icon-off" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display:none">
<path d="M13.73 21a2 2 0 01-3.46 0"/>
<path d="M18.63 13A17.89 17.89 0 0118 8"/>
<path d="M6.26 6.26A5.86 5.86 0 006 8c0 7-3 9-3 9h14"/>
<path d="M18 8a6 6 0 00-9.33-5"/>
<line x1="1" y1="1" x2="23" y2="23"/>
</svg>
<span>Benachrichtigungen</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-intercom" style="display:none">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 1a3 3 0 00-3 3v8a3 3 0 006 0V4a3 3 0 00-3-3z"/>
<path d="M19 10v2a7 7 0 01-14 0v-2"/>
<line x1="12" y1="19" x2="12" y2="23"/>
<line x1="8" y1="23" x2="16" y2="23"/>
</svg>
<span>Gegensprech.</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
</div>
<div class="pan-section" id="pan-section" style="display:none">
<div class="pan-row">
<button class="pan-btn" id="pan-full-left" title="Ganz links">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="11 18 5 12 11 6"/><polyline points="18 18 12 12 18 6"/>
</svg>
</button>
<button class="pan-btn" id="pan-left" title="Links">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="15 18 9 12 15 6"/>
</svg>
</button>
<button class="pan-btn" id="pan-center" title="Mitte">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"/>
<line x1="12" y1="2" x2="12" y2="6"/><line x1="12" y1="18" x2="12" y2="22"/>
<line x1="2" y1="12" x2="6" y2="12"/><line x1="18" y1="12" x2="22" y2="12"/>
</svg>
</button>
<button class="pan-btn" id="pan-right" title="Rechts">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="9 18 15 12 9 6"/>
</svg>
</button>
<button class="pan-btn" id="pan-full-right" title="Ganz rechts">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="13 18 19 12 13 6"/><polyline points="6 18 12 12 6 6"/>
</svg>
</button>
<span class="pan-pos" id="pan-position">0°</span>
</div>
</div>
<div class="quality-section" id="quality-section" style="display:none">
<div class="quality-row">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
style="width:16px;height:16px;flex-shrink:0;color:var(--secondary-text-color,#8e8e93)">
<rect x="2" y="7" width="20" height="15" rx="2"/>
<polyline points="17 2 12 7 7 2"/>
</svg>
<span class="quality-label">Qualität</span>
<select class="quality-select" id="quality-select">
<option value="Auto">Auto</option>
<option value="Hoch (30 Mbps)">Hoch (30 Mbps)</option>
<option value="Niedrig (1.9 Mbps)">Niedrig (1.9 Mbps)</option>
</select>
</div>
</div>
<!-- Accordion: Notification Types -->
<div class="accordion" id="acc-notif-types">
<div class="accordion-header" id="acc-notif-types-header">
<span class="accordion-title">Benachrichtigungs-Typen</span>
<svg class="accordion-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="accordion-body">
<div class="accordion-content">
<div class="sw-row" id="btn-notif-movement">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"/></svg>
<span>Bewegung</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-notif-person">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
<span>Person</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-notif-audio">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 010 14.14"/></svg>
<span>Audio</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-notif-trouble">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
<span>Störung</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-notif-alarm">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
<span>Kamera-Alarm</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
</div>
</div>
</div>
<!-- Accordion: Advanced Controls -->
<div class="accordion" id="acc-advanced">
<div class="accordion-header" id="acc-advanced-header">
<span class="accordion-title">Erweitert</span>
<svg class="accordion-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="accordion-body">
<div class="accordion-content">
<div class="sw-row" id="btn-timestamp">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
<span>Zeitstempel</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-autofollow">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><circle cx="12" cy="12" r="8"/><line x1="12" y1="2" x2="12" y2="4"/><line x1="12" y1="20" x2="12" y2="22"/></svg>
<span>Auto-Follow</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-motion">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"/></svg>
<span>Bewegungserkennung</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-record-sound">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="3"/></svg>
<span>Ton aufnehmen</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
<div class="sw-row" id="btn-privacy-sound">
<div class="sw-left">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M15.54 8.46a5 5 0 010 7.07"/></svg>
<span>Privat-Ton</span>
</div>
<button class="sw-toggle" tabindex="-1"><div class="sw-thumb"></div></button>
</div>
</div>
</div>
</div>
<!-- Accordion: Diagnostics -->
<div class="accordion" id="acc-diagnostics">
<div class="accordion-header" id="acc-diagnostics-header">
<span class="accordion-title">Diagnose</span>
<svg class="accordion-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="accordion-body">
<div class="accordion-content">
<div class="diag-row" id="diag-wifi">
<span class="diag-label">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12.55a11 11 0 0114.08 0"/><path d="M1.42 9a16 16 0 0121.16 0"/><path d="M8.53 16.11a6 6 0 016.95 0"/><line x1="12" y1="20" x2="12.01" y2="20"/></svg>