@camstack/addon-provider-reolink 1.2.252 → 1.2.254

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.js CHANGED
@@ -106821,7 +106821,7 @@ var ZodIssueCode = {
106821
106821
  var ZodFirstPartyTypeKind;
106822
106822
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
106823
106823
  //#endregion
106824
- //#region ../types/dist/runtime-capabilities-C0PIVXwH.mjs
106824
+ //#region ../types/dist/runtime-capabilities-CK6y0W5U.mjs
106825
106825
  /**
106826
106826
  * The audio chunk plane's byte format, and the ONE expansion from a coded
106827
106827
  * window to float samples (D455).
@@ -124491,6 +124491,650 @@ Object.freeze({
124491
124491
  }
124492
124492
  ]
124493
124493
  });
124494
+ Object.freeze({
124495
+ "air-quality-sensor": {
124496
+ "aqi": "optional",
124497
+ "co2": "optional",
124498
+ "lastFetchedAt": "required",
124499
+ "pm10": "optional",
124500
+ "pm25": "optional",
124501
+ "voc": "optional"
124502
+ },
124503
+ "alarm-panel": {
124504
+ "availableModes": "required",
124505
+ "codeRequired": "required",
124506
+ "lastChangedAt": "required",
124507
+ "state": "required",
124508
+ "targetMode": "optional"
124509
+ },
124510
+ "ambient-light-sensor": {
124511
+ "illuminance": "required",
124512
+ "lastFetchedAt": "required"
124513
+ },
124514
+ "audio-metrics": {
124515
+ "avgDbfs": "required",
124516
+ "byClass": "required",
124517
+ "current": "required",
124518
+ "level": "required",
124519
+ "peakDbfs": "required",
124520
+ "ts": "required",
124521
+ "windowSec": "required"
124522
+ },
124523
+ "automation-control": {
124524
+ "enabled": "required",
124525
+ "isRunning": "required",
124526
+ "lastChangedAt": "required",
124527
+ "lastError": "required",
124528
+ "lastTriggeredAt": "required"
124529
+ },
124530
+ "battery": {
124531
+ "binary": "optional",
124532
+ "chargeState": "optional",
124533
+ "charging": "required",
124534
+ "currentMa": "optional",
124535
+ "lastContactAt": "optional",
124536
+ "lastFullRefreshAt": "optional",
124537
+ "lastUpdated": "required",
124538
+ "level": "required",
124539
+ "sleeping": "required",
124540
+ "temperatureC": "optional",
124541
+ "voltage": "optional"
124542
+ },
124543
+ "binary": {
124544
+ "lastChangedAt": "required",
124545
+ "on": "required"
124546
+ },
124547
+ "brightness": {
124548
+ "lastChangedAt": "required",
124549
+ "level": "required"
124550
+ },
124551
+ "camera-streams": {
124552
+ "lastChangedAt": "required",
124553
+ "online": "required",
124554
+ "slotErrors": "required",
124555
+ "slotStatuses": "required"
124556
+ },
124557
+ "carbon-monoxide": {
124558
+ "detected": "required",
124559
+ "lastChangedAt": "required"
124560
+ },
124561
+ "climate-control": {
124562
+ "action": "optional",
124563
+ "availableFanModes": "required",
124564
+ "availableModes": "required",
124565
+ "availablePresets": "required",
124566
+ "currentHumidity": "required",
124567
+ "currentTemp": "required",
124568
+ "fanMode": "required",
124569
+ "lastActiveMode": "optional",
124570
+ "lastFetchedAt": "required",
124571
+ "maxTemp": "optional",
124572
+ "minTemp": "optional",
124573
+ "mode": "required",
124574
+ "preset": "required",
124575
+ "swingHorizontal": "required",
124576
+ "swingVertical": "required",
124577
+ "target": "required",
124578
+ "targetHigh": "required",
124579
+ "targetHumidity": "required",
124580
+ "targetLow": "required",
124581
+ "tempStep": "optional"
124582
+ },
124583
+ "color": {
124584
+ "colorTemperature": "optional",
124585
+ "hsv": "optional",
124586
+ "lastChangedAt": "required",
124587
+ "mode": "required",
124588
+ "rgb": "optional"
124589
+ },
124590
+ "connectivity": {
124591
+ "connected": "required",
124592
+ "lastChangedAt": "required"
124593
+ },
124594
+ "consumables": {
124595
+ "items": "required",
124596
+ "lastChangedAt": "required",
124597
+ "lastFetchedAt": "required"
124598
+ },
124599
+ "contact": {
124600
+ "entryOpen": "required",
124601
+ "lastChangedAt": "required"
124602
+ },
124603
+ "control": {
124604
+ "kind": "required",
124605
+ "lastChangedAt": "required",
124606
+ "max": "optional",
124607
+ "min": "optional",
124608
+ "options": "required",
124609
+ "step": "optional",
124610
+ "value": "required"
124611
+ },
124612
+ "cover": {
124613
+ "lastChangedAt": "required",
124614
+ "position": "required",
124615
+ "state": "required",
124616
+ "tiltPosition": "required"
124617
+ },
124618
+ "day-night": {
124619
+ "lastFetchedAt": "required",
124620
+ "mode": "required",
124621
+ "sensitivity": "optional",
124622
+ "switchDelaySec": "optional"
124623
+ },
124624
+ "device-status": {
124625
+ "lastChangedAt": "required",
124626
+ "online": "required"
124627
+ },
124628
+ "dishwasher": {
124629
+ "activeEvents": "required",
124630
+ "availability": "required",
124631
+ "availablePrograms": "required",
124632
+ "childLock": "required",
124633
+ "delayedStart": "required",
124634
+ "doorLocked": "required",
124635
+ "doorOpen": "required",
124636
+ "errorCode": "required",
124637
+ "errorLabel": "required",
124638
+ "extraDry": "required",
124639
+ "filterCleaningDue": "required",
124640
+ "halfLoad": "required",
124641
+ "hygienePlus": "required",
124642
+ "intensiveZone": "required",
124643
+ "lastFetchedAt": "required",
124644
+ "localControlActive": "required",
124645
+ "machineCareDue": "required",
124646
+ "machineCareRemainingRuns": "required",
124647
+ "operationState": "required",
124648
+ "powerOn": "required",
124649
+ "powerState": "required",
124650
+ "program": "required",
124651
+ "progress": "required",
124652
+ "remaining": "required",
124653
+ "remoteControlActive": "required",
124654
+ "remoteStartAllowed": "required",
124655
+ "selectedProgram": "required",
124656
+ "state": "required",
124657
+ "varioSpeedPlus": "required"
124658
+ },
124659
+ "do-not-disturb": {
124660
+ "enabled": "required",
124661
+ "lastChangedAt": "required"
124662
+ },
124663
+ "doorbell": {
124664
+ "lastPressedAt": "required",
124665
+ "pressCountSinceStart": "required"
124666
+ },
124667
+ "energy-system": {
124668
+ "grid": "required",
124669
+ "heatPump": "required",
124670
+ "house": "required",
124671
+ "lastFetchedAt": "required",
124672
+ "solar": "required",
124673
+ "storage": "required"
124674
+ },
124675
+ "enum-sensor": {
124676
+ "lastFetchedAt": "required",
124677
+ "timestamp": "optional",
124678
+ "value": "required"
124679
+ },
124680
+ "error": {
124681
+ "active": "required",
124682
+ "code": "required",
124683
+ "faults": "optional",
124684
+ "label": "required",
124685
+ "lastFetchedAt": "required",
124686
+ "severity": "required",
124687
+ "since": "required"
124688
+ },
124689
+ "event-emitter": {
124690
+ "eventCountSinceStart": "required",
124691
+ "eventTypes": "required",
124692
+ "lastEvent": "required",
124693
+ "vocabulary": "optional"
124694
+ },
124695
+ "fan-control": {
124696
+ "availablePresets": "required",
124697
+ "direction": "required",
124698
+ "lastChangedAt": "required",
124699
+ "oscillating": "required",
124700
+ "oscillationAxes": "optional",
124701
+ "percentageStep": "optional",
124702
+ "preset": "required",
124703
+ "speed": "required"
124704
+ },
124705
+ "feature-probe": {
124706
+ "channelCount": "required",
124707
+ "deviceType": "required",
124708
+ "flags": "required",
124709
+ "lastFetchedAt": "required",
124710
+ "lastProbedAt": "required",
124711
+ "model": "required"
124712
+ },
124713
+ "flood": {
124714
+ "flooded": "required",
124715
+ "lastChangedAt": "required"
124716
+ },
124717
+ "gas": {
124718
+ "detected": "required",
124719
+ "lastChangedAt": "required"
124720
+ },
124721
+ "group-active": {
124722
+ "active": "required",
124723
+ "lastChangedAt": "required"
124724
+ },
124725
+ "group-commands": { "results": "required" },
124726
+ "group-status": {
124727
+ "excluded": "required",
124728
+ "included": "required",
124729
+ "total": "required"
124730
+ },
124731
+ "heat-pump-status": {
124732
+ "circuits": "required",
124733
+ "energy": "required",
124734
+ "lastFetchedAt": "required",
124735
+ "power": "required",
124736
+ "starts": "required",
124737
+ "system": "required",
124738
+ "temperatures": "required",
124739
+ "waterPressureBar": "required"
124740
+ },
124741
+ "heating-valve": {
124742
+ "lastFetchedAt": "required",
124743
+ "position": "required"
124744
+ },
124745
+ "humidifier": {
124746
+ "action": "required",
124747
+ "availableModes": "required",
124748
+ "currentHumidity": "required",
124749
+ "lastChangedAt": "required",
124750
+ "maxHumidity": "required",
124751
+ "minHumidity": "required",
124752
+ "mode": "required",
124753
+ "on": "required",
124754
+ "targetHumidity": "required"
124755
+ },
124756
+ "humidity-sensor": {
124757
+ "humidity": "required",
124758
+ "lastFetchedAt": "required"
124759
+ },
124760
+ "image": {
124761
+ "lastUpdated": "required",
124762
+ "url": "required"
124763
+ },
124764
+ "image-settings": {
124765
+ "backlightMode": "optional",
124766
+ "brightness": "optional",
124767
+ "contrast": "optional",
124768
+ "exposureMode": "optional",
124769
+ "flip": "optional",
124770
+ "lastFetchedAt": "required",
124771
+ "mirror": "optional",
124772
+ "rotate": "optional",
124773
+ "saturation": "optional",
124774
+ "sharpness": "optional",
124775
+ "warmth": "optional",
124776
+ "whiteBalance": "optional"
124777
+ },
124778
+ "intercom": {
124779
+ "ability": "required",
124780
+ "lastSessionAt": "required",
124781
+ "talking": "required"
124782
+ },
124783
+ "ir-transmitter": {
124784
+ "lastFetchedAt": "required",
124785
+ "lastLearn": "required",
124786
+ "lastSend": "required"
124787
+ },
124788
+ "lawn-mower-control": {
124789
+ "activity": "required",
124790
+ "batteryLevel": "required",
124791
+ "currentCode": "required",
124792
+ "currentCodeLabel": "required",
124793
+ "lastChangedAt": "required",
124794
+ "progress": "required",
124795
+ "severity": "required"
124796
+ },
124797
+ "lock-control": {
124798
+ "codeRequired": "optional",
124799
+ "lastChangedAt": "required",
124800
+ "state": "required"
124801
+ },
124802
+ "low-power-sleep": {
124803
+ "lastContactAt": "optional",
124804
+ "lastUpdated": "required",
124805
+ "sleeping": "required"
124806
+ },
124807
+ "media-player": {
124808
+ "assumedFields": "optional",
124809
+ "availableSources": "required",
124810
+ "currentMedia": "required",
124811
+ "declaredSources": "optional",
124812
+ "duration": "required",
124813
+ "isMuted": "required",
124814
+ "lastChangedAt": "required",
124815
+ "muteReadback": "optional",
124816
+ "position": "required",
124817
+ "positionUpdatedAt": "optional",
124818
+ "repeat": "required",
124819
+ "shuffle": "required",
124820
+ "source": "required",
124821
+ "state": "required",
124822
+ "stateSource": "optional",
124823
+ "volumeLevel": "required"
124824
+ },
124825
+ "meter": {
124826
+ "lastFetchedAt": "required",
124827
+ "value": "required"
124828
+ },
124829
+ "motion": {
124830
+ "autoClearAfterMs": "required",
124831
+ "detected": "required",
124832
+ "lastDetectedAt": "required"
124833
+ },
124834
+ "motion-trigger": {
124835
+ "enabled": "required",
124836
+ "lastChangedAt": "required",
124837
+ "lastFetchedAt": "required"
124838
+ },
124839
+ "motion-zones": {
124840
+ "enabled": "required",
124841
+ "lastFetchedAt": "required",
124842
+ "regions": "required",
124843
+ "sensitivity": "required"
124844
+ },
124845
+ "native-object-detection": {
124846
+ "enabled": "required",
124847
+ "lastByClass": "required",
124848
+ "lastFetchedAt": "required",
124849
+ "supportedClasses": "required"
124850
+ },
124851
+ "navigation": {
124852
+ "flash": "required",
124853
+ "following": "required",
124854
+ "lastChangedAt": "required",
124855
+ "lastFetchedAt": "required",
124856
+ "lightLevel": "required",
124857
+ "lightMode": "required",
124858
+ "mode": "required"
124859
+ },
124860
+ "network-link": {
124861
+ "lastUpdated": "required",
124862
+ "linkUp": "optional",
124863
+ "rssi": "optional",
124864
+ "signal": "required",
124865
+ "speedKbps": "optional",
124866
+ "ssid": "optional",
124867
+ "type": "required"
124868
+ },
124869
+ "notifier": {
124870
+ "lastError": "required",
124871
+ "lastSentAt": "required",
124872
+ "queueDepth": "required",
124873
+ "supports": "required"
124874
+ },
124875
+ "numeric-sensor": {
124876
+ "lastFetchedAt": "required",
124877
+ "value": "required"
124878
+ },
124879
+ "pet-feeder": {
124880
+ "batteryPower": "required",
124881
+ "bowlFood": "required",
124882
+ "childLock": "required",
124883
+ "desiccantLeftDays": "required",
124884
+ "eating": "required",
124885
+ "error": "required",
124886
+ "errorCode": "required",
124887
+ "feeding": "required",
124888
+ "feedSound": "required",
124889
+ "food1": "required",
124890
+ "food2": "required",
124891
+ "foodLevel": "required",
124892
+ "indicatorLight": "required",
124893
+ "isDualHopper": "required",
124894
+ "lastFeedGrams": "required",
124895
+ "lastFeedHopper1": "required",
124896
+ "lastFeedHopper2": "required",
124897
+ "lastFetchedAt": "required",
124898
+ "lowFood": "required",
124899
+ "powerSource": "required",
124900
+ "status": "required",
124901
+ "supportsMarkRefilled": "required",
124902
+ "volume": "required"
124903
+ },
124904
+ "pet-fountain": {
124905
+ "empty": "required",
124906
+ "error": "required",
124907
+ "lastFetchedAt": "required",
124908
+ "pumpRunning": "required",
124909
+ "waterLevel": "required",
124910
+ "waterVolume": "required"
124911
+ },
124912
+ "power-meter": {
124913
+ "apparentPower": "optional",
124914
+ "current": "optional",
124915
+ "deliveredPower": "optional",
124916
+ "energy": "optional",
124917
+ "lastFetchedAt": "required",
124918
+ "power": "optional",
124919
+ "powerFactor": "optional",
124920
+ "voltage": "optional"
124921
+ },
124922
+ "power-source": {
124923
+ "lastFetchedAt": "required",
124924
+ "offSeconds": "required",
124925
+ "switchOn": "required"
124926
+ },
124927
+ "presence": {
124928
+ "gps": "required",
124929
+ "lastChangedAt": "required",
124930
+ "location": "required",
124931
+ "state": "required"
124932
+ },
124933
+ "pressure-sensor": {
124934
+ "lastFetchedAt": "required",
124935
+ "pressure": "required"
124936
+ },
124937
+ "privacy-mask": {
124938
+ "audioEnabled": "required",
124939
+ "enabled": "required",
124940
+ "lastFetchedAt": "required",
124941
+ "regions": "required"
124942
+ },
124943
+ "ptz-autotrack": {
124944
+ "currentSettings": "required",
124945
+ "enabled": "required",
124946
+ "lastChangedAt": "required",
124947
+ "lastFetchedAt": "required",
124948
+ "supportedTargetTypes": "required"
124949
+ },
124950
+ "pump-cycle": {
124951
+ "enabled": "required",
124952
+ "lastFetchedAt": "required",
124953
+ "offTime": "required",
124954
+ "onTime": "required"
124955
+ },
124956
+ "recording-onboard": {
124957
+ "enabled": "required",
124958
+ "lastFetchedAt": "required",
124959
+ "overwriteWhenFull": "required",
124960
+ "postRecordSec": "required",
124961
+ "preRecordSec": "required",
124962
+ "primaryTrackId": "required",
124963
+ "recordingToNowhere": "required",
124964
+ "segmentMinutes": "required",
124965
+ "storage": "required",
124966
+ "tracks": "required",
124967
+ "unreadableWindows": "required",
124968
+ "windows": "required"
124969
+ },
124970
+ "recording-signal": {
124971
+ "active": "required",
124972
+ "lastChangedAt": "required",
124973
+ "lastFetchedAt": "required",
124974
+ "reason": "required"
124975
+ },
124976
+ "running-state": {
124977
+ "lastFetchedAt": "required",
124978
+ "phase": "required",
124979
+ "running": "required",
124980
+ "since": "required",
124981
+ "source": "required"
124982
+ },
124983
+ "scene-monitor": {
124984
+ "lastFetchedAt": "required",
124985
+ "monitors": "required"
124986
+ },
124987
+ "script-runner": {
124988
+ "isRunning": "required",
124989
+ "lastChangedAt": "required",
124990
+ "lastError": "required",
124991
+ "lastRunAt": "required",
124992
+ "lastRunSuccess": "required"
124993
+ },
124994
+ "siren": {
124995
+ "active": "required",
124996
+ "activeUntil": "required",
124997
+ "activeUntilEstimated": "optional",
124998
+ "durationSeconds": "required",
124999
+ "lastFetchedAt": "required",
125000
+ "lastTriggeredAt": "required",
125001
+ "plays": "optional"
125002
+ },
125003
+ "smoke": {
125004
+ "detected": "required",
125005
+ "lastChangedAt": "required"
125006
+ },
125007
+ "stream-catalog": {
125008
+ "descriptors": "required",
125009
+ "lastFetchedAt": "required"
125010
+ },
125011
+ "stream-params": {
125012
+ "ext": "optional",
125013
+ "lastFetchedAt": "required",
125014
+ "main": "optional",
125015
+ "sub": "optional"
125016
+ },
125017
+ "stream-signals": {
125018
+ "lastFetchedAt": "required",
125019
+ "signals": "required"
125020
+ },
125021
+ "switch": {
125022
+ "lastChangedAt": "required",
125023
+ "on": "required"
125024
+ },
125025
+ "tamper": {
125026
+ "lastChangedAt": "required",
125027
+ "tampered": "required"
125028
+ },
125029
+ "temperature-sensor": {
125030
+ "lastFetchedAt": "required",
125031
+ "temperature": "required"
125032
+ },
125033
+ "timed-run": {
125034
+ "activeUntil": "required",
125035
+ "lastFetchedAt": "required",
125036
+ "quickRun": "required",
125037
+ "requestedBy": "required"
125038
+ },
125039
+ "update": {
125040
+ "availableVersion": "required",
125041
+ "currentVersion": "required",
125042
+ "inProgress": "required",
125043
+ "state": "required",
125044
+ "updatable": "required"
125045
+ },
125046
+ "vacuum-control": {
125047
+ "availableFanSpeeds": "required",
125048
+ "batteryLevel": "required",
125049
+ "errorCode": "required",
125050
+ "errorLabel": "required",
125051
+ "fanSpeed": "required",
125052
+ "lastChangedAt": "required",
125053
+ "progress": "required",
125054
+ "state": "required"
125055
+ },
125056
+ "valve": {
125057
+ "lastChangedAt": "required",
125058
+ "position": "required",
125059
+ "state": "required"
125060
+ },
125061
+ "vibration": {
125062
+ "detected": "required",
125063
+ "lastChangedAt": "required"
125064
+ },
125065
+ "water-heater": {
125066
+ "availableModes": "required",
125067
+ "away": "required",
125068
+ "currentTemp": "required",
125069
+ "lastActiveMode": "optional",
125070
+ "lastChangedAt": "required",
125071
+ "maxTemp": "required",
125072
+ "minTemp": "required",
125073
+ "operationMode": "required",
125074
+ "targetTemp": "required"
125075
+ },
125076
+ "weather": {
125077
+ "condition": "required",
125078
+ "humidity": "required",
125079
+ "lastFetchedAt": "required",
125080
+ "pressure": "required",
125081
+ "temperature": "required",
125082
+ "windBearing": "required",
125083
+ "windSpeed": "required"
125084
+ },
125085
+ "weather-station": {
125086
+ "dewPoint": "optional",
125087
+ "feelsLike": "optional",
125088
+ "humidity": "optional",
125089
+ "lastFetchedAt": "required",
125090
+ "pressure": "optional",
125091
+ "rain24h": "optional",
125092
+ "rainDaily": "optional",
125093
+ "rainEvent": "optional",
125094
+ "rainMonthly": "optional",
125095
+ "rainRate": "optional",
125096
+ "rainWeekly": "optional",
125097
+ "rainYearly": "optional",
125098
+ "solarRadiation": "optional",
125099
+ "temperature": "optional",
125100
+ "uv": "optional",
125101
+ "vpd": "optional",
125102
+ "windBearing": "optional",
125103
+ "windBearingAvg": "optional",
125104
+ "windGust": "optional",
125105
+ "windGustMax": "optional",
125106
+ "windSpeed": "optional"
125107
+ },
125108
+ "workload": {
125109
+ "addresses": "required",
125110
+ "autostart": "required",
125111
+ "hostDeviceId": "required",
125112
+ "image": "required",
125113
+ "lastFetchedAt": "required",
125114
+ "os": "required",
125115
+ "ports": "required",
125116
+ "resources": "required",
125117
+ "since": "required",
125118
+ "state": "required",
125119
+ "updateAvailable": "required",
125120
+ "version": "required"
125121
+ },
125122
+ "zone-analytics": {
125123
+ "frame": "required",
125124
+ "frameHeight": "required",
125125
+ "frameWidth": "required",
125126
+ "stationaryObjects": "optional",
125127
+ "ts": "required",
125128
+ "unzoned": "required",
125129
+ "zones": "required"
125130
+ },
125131
+ "zone-rules": {
125132
+ "detection": "required",
125133
+ "motion": "required",
125134
+ "package": "required"
125135
+ },
125136
+ "zones": { "zones": "required" }
125137
+ });
124494
125138
  Object.freeze({
124495
125139
  "actions": { "run": 363e4 },
124496
125140
  "audio-analyzer": { "classify": 3e4 },
@@ -128357,16 +129001,32 @@ var MigrationPlanSchema = object({ edits: array(discriminatedUnion("op", [
128357
129001
  }),
128358
129002
  object({
128359
129003
  op: literal("upsertRecord"),
129004
+ owner: string().min(1),
128360
129005
  kind: string().min(1),
128361
129006
  recordKey: string().min(1),
128362
- value: unknown(),
129007
+ deviceId: number$1().int().positive().optional(),
129008
+ at: number$1().int().nonnegative().optional(),
129009
+ value: record(string(), unknown()),
128363
129010
  precondition: PreconditionSchema
128364
129011
  }),
128365
129012
  object({
128366
129013
  op: literal("deleteRecord"),
129014
+ owner: string().min(1),
128367
129015
  kind: string().min(1),
128368
129016
  recordKey: string().min(1),
128369
129017
  precondition: PreconditionSchema
129018
+ }),
129019
+ object({
129020
+ op: literal("rekeyDevice"),
129021
+ deviceId: number$1().int().positive(),
129022
+ addonId: string().min(1),
129023
+ stableId: string().min(1),
129024
+ precondition: PreconditionSchema
129025
+ }),
129026
+ object({
129027
+ op: literal("tombstoneDevice"),
129028
+ deviceId: number$1().int().positive(),
129029
+ precondition: PreconditionSchema
128370
129030
  })
128371
129031
  ])) });
128372
129032
  /** `JSON.stringify` with object keys sorted, so equal values spell the same. */
@@ -162053,7 +162713,7 @@ var mediaPlayerCapability = {
162053
162713
  ]
162054
162714
  }
162055
162715
  };
162056
- DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter, DeviceType.Climate, DeviceType.Climate, DeviceType.Camera, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.WeatherStation, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Workload, DeviceType.Camera, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Gateway, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.PetFeeder, DeviceType.MediaPlayer, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation;
162716
+ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter, DeviceType.Climate, DeviceType.Climate, DeviceType.Camera, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.WeatherStation, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Workload, DeviceType.Camera, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.HeatPump, DeviceType.HeatPump, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Workload, DeviceType.Gateway, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.PetFeeder, DeviceType.MediaPlayer, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation;
162057
162717
  var NUMBER = {
162058
162718
  kind: "fixed",
162059
162719
  result: ["number"]
@@ -170476,6 +171136,43 @@ function heatPumpInstantCop(power) {
170476
171136
  if (thermalW === null || electricalW === null || electricalW <= 0) return null;
170477
171137
  return thermalW / electricalW;
170478
171138
  }
171139
+ var HEAT_PUMP_CUSTOMIZE_DEVICE_TYPES = [DeviceType.HeatPump];
171140
+ /** One electrical reading the operator may take from a device they pick, unit checked. */
171141
+ function electricalTarget(id, path, unit) {
171142
+ return {
171143
+ id,
171144
+ cardinality: "scalar",
171145
+ vocabulary: { cap: "heat-pump-status" },
171146
+ deviceTypes: HEAT_PUMP_CUSTOMIZE_DEVICE_TYPES,
171147
+ apply: "replace",
171148
+ path,
171149
+ sources: [{
171150
+ kind: "numeric",
171151
+ requiredUnit: unit,
171152
+ transforms: [{ kind: "identity" }]
171153
+ }],
171154
+ sourceReport: { status: "assignment-status" }
171155
+ };
171156
+ }
171157
+ var HEAT_PUMP_TARGETS = [electricalTarget("electrical-power", "power.electricalW", "W"), electricalTarget("electrical-energy", "energy.electricalKwh", "kWh")];
171158
+ /**
171159
+ * Customize (D984, #476): a gateway that reports no instantaneous electrical
171160
+ * power (the cloud ones) or whose energy meter the operator trusts less than a
171161
+ * dedicated one lets the OPERATOR pick a device for `power.electricalW` and
171162
+ * `energy.electricalKwh` — a `replace` over a field listed in `overridable`,
171163
+ * nothing else. The replaced value IS the cap field, so the instant COP, the
171164
+ * hero pills and the history use it; nothing is linked by itself (D356), the
171165
+ * unit is checked, and a source that does not answer releases the field back to
171166
+ * the native reading (never a 0, D393).
171167
+ */
171168
+ var heatPumpStatusCustomize = {
171169
+ version: 1,
171170
+ overridable: HEAT_PUMP_TARGETS.map((target) => ({
171171
+ path: target.path,
171172
+ by: target.id
171173
+ })),
171174
+ targets: HEAT_PUMP_TARGETS
171175
+ };
170479
171176
  var heatPumpStatusCapability = {
170480
171177
  name: "heat-pump-status",
170481
171178
  scope: "device",
@@ -170494,6 +171191,7 @@ var heatPumpStatusCapability = {
170494
171191
  * (the series are recorded). See `RuntimeStateDurability`.
170495
171192
  */
170496
171193
  durability: "session",
171194
+ customize: heatPumpStatusCustomize,
170497
171195
  /**
170498
171196
  * History (D850, D917): `circuits[]` is a keyed array — one series per circuit and
170499
171197
  * field, named by the circuit's label. The mode is a state (D896); the energy
@@ -172285,6 +172983,8 @@ var IntegrationInstanceKindSchema = object({
172285
172983
  role: IntegrationInstanceRoleSchema.optional(),
172286
172984
  /** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
172287
172985
  canTest: boolean().optional(),
172986
+ /** `false`: Add never offers this kind (the system creates its one instance, e.g. a default integration). Absent = creatable. */
172987
+ creatable: boolean().optional(),
172288
172988
  /** The kind signs in through a server-held interactive session. */
172289
172989
  signIn: object({
172290
172990
  basePath: string().min(1),
@@ -186836,6 +187536,7 @@ var HardwareClassIdSchema = _enum([
186836
187536
  "apple-m-base",
186837
187537
  "apple-m-pro",
186838
187538
  "amd-phoenix",
187539
+ "nvidia-gpu",
186839
187540
  "unknown"
186840
187541
  ]);
186841
187542
  var AcceleratorKindSchema = _enum([
@@ -186843,6 +187544,7 @@ var AcceleratorKindSchema = _enum([
186843
187544
  "intel-igpu",
186844
187545
  "amd-igpu",
186845
187546
  "amd-npu",
187547
+ "nvidia-gpu",
186846
187548
  "x86-cpu",
186847
187549
  "arm-cpu",
186848
187550
  "apple-ane",
@@ -222016,6 +222718,19 @@ object({
222016
222718
  delay: number$1().nonnegative().optional(),
222017
222719
  commands: record(string(), unknown())
222018
222720
  });
222721
+ /** The `instance-select` field of a link, keyed like the body field it fills. */
222722
+ function linkFieldDescriptor(key, target, labels) {
222723
+ return {
222724
+ type: "instance-select",
222725
+ key,
222726
+ label: labels.label,
222727
+ ...labels.description !== void 0 ? { description: labels.description } : {},
222728
+ required: labels.required ?? true,
222729
+ ...labels.noneLabel !== void 0 ? { noneLabel: labels.noneLabel } : {},
222730
+ functionCap: target.cap,
222731
+ ...target.kind !== void 0 ? { kind: target.kind } : {}
222732
+ };
222733
+ }
222019
222734
  //#endregion
222020
222735
  //#region src/clips/clip-prefetch.ts
222021
222736
  /** The longest a device may stay quiet after refusals, whatever its interval. */
@@ -222515,6 +223230,11 @@ var reolinkCameraSchema = object({
222515
223230
  /** Empty for a camera adopted from an NVR / Home Hub: it borrows its integration's session. */
222516
223231
  password: string().default("").describe("Password").meta({ secret: true }),
222517
223232
  /**
223233
+ * The SMTP password last written to the camera on the Email tab (or by Auto-configure email
223234
+ * push). A keychain secret: the form shows set / not set, never the value.
223235
+ */
223236
+ emailPassword: string().default("").describe("Camera SMTP password").meta({ secret: true }),
223237
+ /**
222518
223238
  * Transport mode resolved at creation time by autodetect (Slice 15).
222519
223239
  * - `tcp` : standard TCP-based Baichuan (regular cameras, NVR/Hub)
222520
223240
  * - `udp` : BCUDP-based Baichuan (battery cams, UDP-only models like
@@ -222842,6 +223562,17 @@ var reolinkCameraSchema = object({
222842
223562
  supported: boolean().optional()
222843
223563
  }).optional(),
222844
223564
  /**
223565
+ * The power source of a battery camera (`getPowerSource`): `adapter`,
223566
+ * `battery`, or `unknown` when the read failed or the firmware is
223567
+ * silent. Drives the Advanced tab's "Power source" setting; `unknown`
223568
+ * hides it.
223569
+ */
223570
+ powerSourceSnapshot: object({ source: _enum([
223571
+ "adapter",
223572
+ "battery",
223573
+ "unknown"
223574
+ ]) }).optional(),
223575
+ /**
222845
223576
  * Snapshot of the camera's auto-reboot schedule from
222846
223577
  * `getAutoReboot` (cmd_id 101). Drives the "Auto reboot" section
222847
223578
  * defaults on the Advanced tab. `weekDay` is the lib's `DayOfWeek`
@@ -229123,6 +229854,17 @@ function deriveReolinkCameraFeatures(inputs) {
229123
229854
  return out;
229124
229855
  }
229125
229856
  //#endregion
229857
+ //#region src/email-smtp-password.ts
229858
+ /**
229859
+ * The camera SMTP password an operator wrote on the Email tab, when it is a real value to push
229860
+ * to the camera and keep: a non-empty string that is not a keychain marker. Blank means "keep
229861
+ * the stored one" and a marker is the form echoing back what it was shown; neither is a write.
229862
+ */
229863
+ function smtpPasswordToWrite(value) {
229864
+ if (typeof value !== "string" || value.length === 0) return null;
229865
+ return isSecretMarker(value) ? null : value;
229866
+ }
229867
+ //#endregion
229126
229868
  //#region src/hub-child-settings.ts
229127
229869
  /**
229128
229870
  * A camera adopted under an NVR / Home Hub dials through the integration's session: the address
@@ -231756,6 +232498,13 @@ var PirAccessory = class extends BaseDevice {
231756
232498
  * inverse `101 - userValue` (lower raw = more sensitive).
231757
232499
  * Mirrors `refreshSwitchFromExternal`'s reverse transform. */
231758
232500
  async pushConfigToFirmware(enable) {
232501
+ if (this.parent.wakeForWrite && !await this.parent.wakeForWrite()) {
232502
+ this.ctx.logger.warn("pir write not sent — the battery camera could not be woken", {
232503
+ tags: { deviceId: this.id },
232504
+ meta: { channel: this.channel }
232505
+ });
232506
+ throw new Error("The camera is asleep and could not be woken; try again in a moment.");
232507
+ }
231759
232508
  const api = await this.api;
231760
232509
  const sensitive = this.config.get("pirSensitive");
231761
232510
  const reduceAlarm = this.config.get("pirReduceAlarm");
@@ -233651,10 +234400,9 @@ var PowerSourceReadingSchema = _enum([
233651
234400
  "battery",
233652
234401
  "unknown"
233653
234402
  ]);
233654
- var ReadPowerSourceResultSchema = object({ source: PowerSourceReadingSchema });
233655
234403
  /** The device (or this code) declined before any real write was sent. */
233656
234404
  var PowerSourceRefusalReasonSchema = _enum(["dry-run-refused", "dry-run-failed"]);
233657
- var SwitchPowerSourceResultSchema = discriminatedUnion("outcome", [
234405
+ discriminatedUnion("outcome", [
233658
234406
  object({
233659
234407
  outcome: literal("refused"),
233660
234408
  mode: PowerSourceModeSchema,
@@ -233798,6 +234546,54 @@ async function switchPowerSourceTo(target, mode) {
233798
234546
  applied
233799
234547
  };
233800
234548
  }
234549
+ /** The settings key of the power source: an ordinary select, owned by the camera (never stored). */
234550
+ var POWER_SOURCE_SETTING_KEY = "powerSource";
234551
+ /**
234552
+ * The power source as a setting, in its own section of the Advanced tab.
234553
+ * Only a battery camera whose read ANSWERED with a mode has one: a camera that
234554
+ * was never asked, or that did not answer, shows nothing rather than a guess.
234555
+ */
234556
+ function buildPowerSourceSettingsSection(input) {
234557
+ const { isBattery, source } = input;
234558
+ if (!isBattery || source === void 0 || source === "unknown") return [];
234559
+ return [{
234560
+ id: "power-source",
234561
+ tab: "advanced",
234562
+ title: "Power source",
234563
+ titleKey: "provider-reolink:schema.s_power-source.title",
234564
+ description: "Only switch to wired power when the adapter meets the camera's spec.",
234565
+ descriptionKey: "provider-reolink:schema.s_power-source.description",
234566
+ columns: 1,
234567
+ fields: [{
234568
+ type: "select",
234569
+ key: POWER_SOURCE_SETTING_KEY,
234570
+ label: "Power source",
234571
+ labelKey: "provider-reolink:schema.s_power-source.powerSource.label",
234572
+ default: source,
234573
+ options: [{
234574
+ value: "adapter",
234575
+ label: "Wired power",
234576
+ labelKey: "provider-reolink:schema.s_power-source.powerSource.o_adapter.label"
234577
+ }, {
234578
+ value: "battery",
234579
+ label: "Battery power",
234580
+ labelKey: "provider-reolink:schema.s_power-source.powerSource.o_battery.label"
234581
+ }]
234582
+ }]
234583
+ }];
234584
+ }
234585
+ /**
234586
+ * Apply the setting: switch the camera and REFUSE to call a switch that did not
234587
+ * land a success — the settings form keeps the operator's edit, marked unsaved.
234588
+ */
234589
+ async function applyPowerSourceSetting(target, value) {
234590
+ const mode = PowerSourceModeSchema.safeParse(value);
234591
+ if (!mode.success) throw new Error(`Not a power source: ${String(value)}`);
234592
+ const outcome = await switchPowerSourceTo(target, mode.data);
234593
+ if (outcome.outcome === "refused") throw new Error(`The camera refused the power source switch (${outcome.reason})`);
234594
+ if (outcome.outcome === "failed") throw new Error(`The power source switch failed: ${outcome.error}`);
234595
+ if (!outcome.applied) throw new Error(`The camera did not take the power source switch (it reports ${outcome.after})`);
234596
+ }
233801
234597
  //#endregion
233802
234598
  //#region src/ptz-zoom.ts
233803
234599
  /**
@@ -234771,6 +235567,7 @@ function slicesForPatch(patch) {
234771
235567
  if (has("pirReduceFalseAlarm")) out.add("pir");
234772
235568
  if (has("autoRebootEnabled", "autoRebootWeekDay", "autoRebootHour", "autoRebootMinute")) out.add("autoReboot");
234773
235569
  if (has("timeZoneId")) out.add("systemGeneral");
235570
+ if (has("powerSource")) out.add("powerSource");
234774
235571
  return out;
234775
235572
  }
234776
235573
  /**
@@ -234787,8 +235584,6 @@ var RefreshSettingsResultSchema = object({
234787
235584
  capsWarmed: number$1(),
234788
235585
  capsTotal: number$1()
234789
235586
  });
234790
- /** The two switch actions, one implementation each way. */
234791
- var POWER_SWITCH_ACTIONS = [["switch-to-wired-power", "adapter"], ["switch-to-battery-power", "battery"]];
234792
235587
  /** The uid out of a device's metadata bag, or nothing. Never a cast. */
234793
235588
  function metaUid(metadata) {
234794
235589
  if (metadata === null) return void 0;
@@ -235596,6 +236391,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
235596
236391
  } catch (err) {
235597
236392
  this.ctx.logger.debug("reolink getPirInfo probe failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
235598
236393
  }
236394
+ if (want("powerSource") && this.isBattery) cacheUpdate.powerSourceSnapshot = { source: await readPowerSource(await this.powerSourceTarget()) };
235599
236395
  if (want("autoReboot")) try {
235600
236396
  const reboot = await api.getAutoReboot();
235601
236397
  cacheUpdate.autoRebootSnapshot = {
@@ -235948,6 +236744,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
235948
236744
  runTest: false
235949
236745
  }, this.getChannel());
235950
236746
  this.ctx.logger.info("email-push: camera auto-configure applied", { tags: { deviceId: this.id } });
236747
+ if (params.authPassword !== void 0) await this.config.setAll({ emailPassword: params.authPassword });
235951
236748
  await this.refreshCameraEmailConfig().catch(() => {});
235952
236749
  }
235953
236750
  /**
@@ -236174,16 +236971,6 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
236174
236971
  capsTotal
236175
236972
  };
236176
236973
  });
236177
- if (this.isBattery) {
236178
- this.registerDeviceAction("read-power-source", deviceCustomAction(unknown(), ReadPowerSourceResultSchema, { kind: "mutation" }), async () => {
236179
- await this.wakeIfSleeping();
236180
- return { source: await readPowerSource(await this.powerSourceTarget()) };
236181
- });
236182
- for (const [action, mode] of POWER_SWITCH_ACTIONS) this.registerDeviceAction(action, deviceCustomAction(unknown(), SwitchPowerSourceResultSchema, { kind: "mutation" }), async () => {
236183
- await this.wakeIfSleeping();
236184
- return switchPowerSourceTo(await this.powerSourceTarget(), mode);
236185
- });
236186
- }
236187
236974
  this.registerDeviceAction("refresh-sessions", deviceCustomAction(unknown(), _void(), { kind: "mutation" }), async () => {
236188
236975
  await this.refreshSessionsSnapshot();
236189
236976
  });
@@ -236733,56 +237520,6 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
236733
237520
  };
236734
237521
  }
236735
237522
  /**
236736
- * Battery-cam power-source section (General tab): read the source, switch to
236737
- * wired or back to battery. Returns `[]` for a wired-only camera. The buttons
236738
- * dispatch the `read-power-source` / `switch-to-*-power` device actions.
236739
- */
236740
- buildPowerSourceSection() {
236741
- if (!this.isBattery) return [];
236742
- const switchMessage = "Switch {outcome} · before: {before} · after: {after} · applied: {applied}";
236743
- return [{
236744
- id: "power-source",
236745
- tab: "general",
236746
- title: "Power source",
236747
- titleKey: "provider-reolink:schema.s_power-source.title",
236748
- description: "Only switch to wired power when the adapter meets the camera's spec.",
236749
- descriptionKey: "provider-reolink:schema.s_power-source.description",
236750
- columns: 1,
236751
- fields: [
236752
- {
236753
- type: "device-action-button",
236754
- key: "_readPowerSource",
236755
- label: "Power source",
236756
- labelKey: "provider-reolink:schema.s_power-source._readPowerSource.label",
236757
- buttonLabel: "Read power source",
236758
- action: "read-power-source",
236759
- variant: "default",
236760
- successMessage: "Power source: {source}"
236761
- },
236762
- {
236763
- type: "device-action-button",
236764
- key: "_switchToWiredPower",
236765
- label: "Wired power",
236766
- labelKey: "provider-reolink:schema.s_power-source._switchToWiredPower.label",
236767
- buttonLabel: "Switch to wired power",
236768
- action: "switch-to-wired-power",
236769
- variant: "default",
236770
- successMessage: switchMessage
236771
- },
236772
- {
236773
- type: "device-action-button",
236774
- key: "_switchToBatteryPower",
236775
- label: "Battery power",
236776
- labelKey: "provider-reolink:schema.s_power-source._switchToBatteryPower.label",
236777
- buttonLabel: "Switch to battery power",
236778
- action: "switch-to-battery-power",
236779
- variant: "default",
236780
- successMessage: switchMessage
236781
- }
236782
- ]
236783
- }];
236784
- }
236785
- /**
236786
237523
  * Battery-cam Email Push auto-configure section. Returns `[]` for any
236787
237524
  * camera that wouldn't benefit (wired cams keep a live socket for
236788
237525
  * native push; hub children have no independent email path). The
@@ -236973,7 +237710,8 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
236973
237710
  if (typeof fields.emailSmtpServer === "string") patch.smtpServer = fields.emailSmtpServer;
236974
237711
  if (typeof fields.emailSmtpPort === "number") patch.smtpPort = fields.emailSmtpPort;
236975
237712
  if (typeof fields.emailUserName === "string") patch.userName = fields.emailUserName;
236976
- if (typeof fields.emailPassword === "string" && fields.emailPassword.length > 0) patch.password = fields.emailPassword;
237713
+ const smtpPassword = smtpPasswordToWrite(fields.emailPassword);
237714
+ if (smtpPassword !== null) patch.password = smtpPassword;
236977
237715
  if (typeof fields.emailSsl === "boolean") patch.ssl = fields.emailSsl ? 1 : 0;
236978
237716
  if (typeof fields.emailRecipient1 === "string") patch.address1 = fields.emailRecipient1;
236979
237717
  if (typeof fields.emailRecipient2 === "string") patch.address2 = fields.emailRecipient2;
@@ -241694,7 +242432,10 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
241694
242432
  }),
241695
242433
  ...this.buildSessionsTabSections(),
241696
242434
  ...this.buildEmailPushSection(),
241697
- ...this.buildPowerSourceSection(),
242435
+ ...buildPowerSourceSettingsSection({
242436
+ isBattery: this.isBattery,
242437
+ source: cache?.powerSourceSnapshot?.source
242438
+ }),
241698
242439
  ...this.buildEmailTabSections(),
241699
242440
  ...buildClipRefreshDeviceSection({
241700
242441
  isHubChild: this.isHubChild(),
@@ -241723,7 +242464,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
241723
242464
  emailSmtpServer: emailSnap?.smtpServer ?? "",
241724
242465
  emailSmtpPort: emailSnap?.smtpPort ?? 587,
241725
242466
  emailUserName: emailSnap?.userName ?? "",
241726
- emailPassword: "",
242467
+ emailPassword: this.config.get("emailPassword"),
241727
242468
  emailSsl: emailSnap?.ssl ?? false,
241728
242469
  emailRecipient1: emailSnap?.recipients?.[0] ?? "",
241729
242470
  emailRecipient2: emailSnap?.recipients?.[1] ?? "",
@@ -241790,6 +242531,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
241790
242531
  audioNoiseLevel: this.config.get("audioNoiseLevel") ?? (cache?.audioNoiseSnapshot?.enabled ? cache.audioNoiseSnapshot?.level ?? 1 : 0),
241791
242532
  autoFocusEnabled: this.config.get("autoFocusEnabled") ?? cache?.autoFocusSnapshot?.enabled ?? true,
241792
242533
  pirReduceFalseAlarm: this.config.get("pirReduceFalseAlarm") ?? cache?.pirSnapshot?.reduceFalseAlarm ?? false,
242534
+ ...cache?.powerSourceSnapshot !== void 0 ? { [POWER_SOURCE_SETTING_KEY]: cache.powerSourceSnapshot.source } : {},
241793
242535
  gop: this.config.get("gop") ?? cache?.encSnapshot?.mainStream?.gop ?? 4,
241794
242536
  autoRebootEnabled: this.config.get("autoRebootEnabled") ?? cache?.autoRebootSnapshot?.enabled ?? false,
241795
242537
  autoRebootWeekDay: this.config.get("autoRebootWeekDay") ?? cache?.autoRebootSnapshot?.weekDay ?? "everyday",
@@ -241819,8 +242561,8 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
241819
242561
  }
241820
242562
  async applySettingsPatch(patch) {
241821
242563
  if (this.isHubChild()) this.refuseHubChildPatch(patch);
241822
- const { emailSmtpServer, emailSmtpPort, emailUserName, emailPassword, emailSsl, emailRecipient1, emailRecipient2, emailRecipient3, emailSendNickname, emailScheduleEnabled, osdChannelEnabled, osdChannelName, osdChannelPosition, osdTimeEnabled, osdTimePosition, osdWatermark, hubName: _hubName, ...rest } = patch;
241823
- if ((osdChannelEnabled !== void 0 || osdChannelName !== void 0 || osdChannelPosition !== void 0 || osdTimeEnabled !== void 0 || osdTimePosition !== void 0 || osdWatermark !== void 0 || emailSmtpServer !== void 0 || emailRecipient1 !== void 0) && !await this.wakeIfSleeping()) this.ctx.logger.warn("settings write: battery cam did not wake — writing anyway", { tags: { deviceId: this.id } });
242564
+ const { emailSmtpServer, emailSmtpPort, emailUserName, emailPassword, emailSsl, emailRecipient1, emailRecipient2, emailRecipient3, emailSendNickname, emailScheduleEnabled, osdChannelEnabled, osdChannelName, osdChannelPosition, osdTimeEnabled, osdTimePosition, osdWatermark, hubName: _hubName, [POWER_SOURCE_SETTING_KEY]: powerSource, ...rest } = patch;
242565
+ if ((osdChannelEnabled !== void 0 || osdChannelName !== void 0 || osdChannelPosition !== void 0 || osdTimeEnabled !== void 0 || osdTimePosition !== void 0 || osdWatermark !== void 0 || emailSmtpServer !== void 0 || emailRecipient1 !== void 0 || powerSource !== void 0) && !await this.wakeIfSleeping()) this.ctx.logger.warn("settings write: battery cam did not wake — writing anyway", { tags: { deviceId: this.id } });
241824
242566
  const emailFields = {
241825
242567
  emailSmtpServer,
241826
242568
  emailSmtpPort,
@@ -241833,12 +242575,18 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
241833
242575
  emailSendNickname,
241834
242576
  emailScheduleEnabled
241835
242577
  };
241836
- if (Object.values(emailFields).some((v) => v !== void 0)) await this.applyEmailConfigPatch(emailFields).catch((err) => {
241837
- this.ctx.logger.warn("email config write failed", {
241838
- tags: { deviceId: this.id },
241839
- meta: { error: err instanceof Error ? err.message : String(err) }
242578
+ if (Object.values(emailFields).some((v) => v !== void 0)) {
242579
+ let written = true;
242580
+ await this.applyEmailConfigPatch(emailFields).catch((err) => {
242581
+ written = false;
242582
+ this.ctx.logger.warn("email config write failed", {
242583
+ tags: { deviceId: this.id },
242584
+ meta: { error: err instanceof Error ? err.message : String(err) }
242585
+ });
241840
242586
  });
241841
- });
242587
+ const stored = smtpPasswordToWrite(emailPassword);
242588
+ if (written && stored !== null) await this.config.setAll({ emailPassword: stored });
242589
+ }
241842
242590
  const osdPatch = buildOsdPatch({
241843
242591
  osdChannelEnabled,
241844
242592
  osdChannelName,
@@ -241855,6 +242603,10 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
241855
242603
  osdTimePosition,
241856
242604
  osdWatermark
241857
242605
  ].some((v) => v !== void 0);
242606
+ if (powerSource !== void 0) {
242607
+ await applyPowerSourceSetting(await this.powerSourceTarget(), powerSource);
242608
+ await this.refreshParentSettingsSnapshot(new Set(["powerSource"]), "post-write");
242609
+ }
241858
242610
  if (Object.keys(rest).length === 0 && !hasOsdPatch) return;
241859
242611
  if (Object.keys(rest).length > 0) await this.config.setAll(rest);
241860
242612
  const typedPatch = patch;
@@ -242289,6 +243041,11 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
242289
243041
  isSleeping() {
242290
243042
  return this.sleeping;
242291
243043
  }
243044
+ /** Implements `ReolinkAccessoryHost.wakeForWrite`: an accessory's operator
243045
+ * write (PIR, ...) wakes a sleeping battery camera first. */
243046
+ wakeForWrite() {
243047
+ return this.wakeIfSleeping();
243048
+ }
242292
243049
  async ensureApi() {
242293
243050
  if (this.isHubChild()) {
242294
243051
  const session = this.hubSession();
@@ -243313,6 +244070,8 @@ var EmailPushBridge = class {
243313
244070
  /** The last failure that was reported, so a mailbox provider that stays away is said once. */
243314
244071
  lastFailure = null;
243315
244072
  chain = Promise.resolve();
244073
+ /** The integrations whose empty link this process filled (only those are released). */
244074
+ filled = /* @__PURE__ */ new Set();
243316
244075
  constructor(deps) {
243317
244076
  this.deps = deps;
243318
244077
  }
@@ -243383,43 +244142,104 @@ var EmailPushBridge = class {
243383
244142
  const recipients = this.recipients();
243384
244143
  if (recipients.length === 0) {
243385
244144
  if (this.brokerId !== null && this.subscriptionId !== null) await this.deps.port.unsubscribe(this.brokerId, this.subscriptionId);
243386
- if (this.brokerId !== null) await this.syncLinks(this.brokerId, /* @__PURE__ */ new Set());
244145
+ if (this.brokerId !== null) await this.syncLinks(this.brokerId, await this.tryDefaultId(), false);
243387
244146
  this.subscriptionId = null;
243388
244147
  this.declared = null;
243389
244148
  return;
243390
244149
  }
243391
- const owners = this.linkOwners();
243392
- const key = `${recipients.join(",")}|${[...owners].sort().join(",")}`;
244150
+ const { defaultId, complete } = await this.resolveDefault();
244151
+ const picked = await this.pickedMailbox(defaultId);
244152
+ const key = `${recipients.join(",")}|${defaultId ?? ""}|${picked ?? this.brokerId ?? ""}`;
243393
244153
  if (!force && this.declared === key && this.subscriptionId !== null) return;
243394
- const brokerId = await this.ensureMailbox();
244154
+ const brokerId = picked ?? await this.ensureMailbox();
244155
+ if (this.brokerId !== null && this.brokerId !== brokerId && this.subscriptionId !== null) {
244156
+ await this.deps.port.unsubscribe(this.brokerId, this.subscriptionId);
244157
+ this.subscriptionId = null;
244158
+ }
243395
244159
  await this.seedBaseline(brokerId);
243396
244160
  const { subscriptionId } = await this.deps.port.subscribe(brokerId, recipients);
243397
244161
  this.brokerId = brokerId;
243398
244162
  this.subscriptionId = subscriptionId;
243399
- this.declared = await this.syncLinks(brokerId, owners) ? key : null;
244163
+ const linked = await this.syncLinks(brokerId, defaultId, true);
244164
+ this.declared = linked && complete ? `${recipients.join(",")}|${defaultId ?? ""}|${brokerId}` : null;
243400
244165
  await this.reconcile();
243401
244166
  }
243402
- /** The integrations whose standalone cameras mail the mailbox: they link to it. */
243403
- linkOwners() {
243404
- const owners = /* @__PURE__ */ new Set();
243405
- for (const cam of this.deps.listCameras()) if (cam.isEmailPushEligible && cam.integrationId !== null) owners.add(cam.integrationId);
243406
- return owners;
244167
+ /**
244168
+ * The default integration holds the mailbox link for every email-push camera (a hub child's
244169
+ * integration carries none). `complete` is false when it could not be resolved: the caller
244170
+ * retries at the next sync.
244171
+ */
244172
+ async resolveDefault() {
244173
+ const cam = this.deps.listCameras().find((c) => c.isEmailPushEligible);
244174
+ const tags = cam === void 0 ? {} : { tags: { deviceId: cam.id } };
244175
+ let defaultId = null;
244176
+ try {
244177
+ defaultId = await this.deps.defaultIntegrationId();
244178
+ } catch (err) {
244179
+ this.deps.logger.warn("email-push: the default integration could not be read", {
244180
+ ...tags,
244181
+ meta: { error: errMsg(err) }
244182
+ });
244183
+ return {
244184
+ defaultId: null,
244185
+ complete: false
244186
+ };
244187
+ }
244188
+ if (defaultId === null) {
244189
+ this.deps.logger.warn("email-push: a camera uses the mailbox but the default integration is not resolved yet; retrying at the next sync", tags);
244190
+ return {
244191
+ defaultId: null,
244192
+ complete: false
244193
+ };
244194
+ }
244195
+ return {
244196
+ defaultId,
244197
+ complete: true
244198
+ };
244199
+ }
244200
+ async tryDefaultId() {
244201
+ try {
244202
+ return await this.deps.defaultIntegrationId();
244203
+ } catch {
244204
+ return null;
244205
+ }
244206
+ }
244207
+ /**
244208
+ * The mailbox the operator picked on the default integration, or null while none is picked.
244209
+ * A pick that no mailbox answers to throws: the bridge never swaps it for another one.
244210
+ */
244211
+ async pickedMailbox(defaultId) {
244212
+ if (defaultId === null) return null;
244213
+ const row = (await this.deps.links.list()).find((r) => r.id === defaultId);
244214
+ if (row === void 0 || row.mailboxId === "") return null;
244215
+ if (!(await this.deps.port.list()).some((m) => m.id === row.mailboxId)) throw new Error(`the camera mailbox picked on the default integration (${row.mailboxId}) does not exist`);
244216
+ return row.mailboxId;
244217
+ }
244218
+ /** The mailbox a camera is pointed at: the operator's pick, else the one this addon adopts or creates. */
244219
+ async resolveMailbox() {
244220
+ return await this.pickedMailbox(await this.tryDefaultId()) ?? await this.ensureMailbox();
243407
244221
  }
243408
244222
  /**
243409
- * Make the `mailboxId` links say who uses the mailbox: `owners` link to it, no other
243410
- * integration does. Idempotent, so an install whose mailbox already exists is filled from it
243411
- * (the mailbox is re-adopted by `ensureMailbox`) with nothing stored beforehand. False when the
243412
- * links could not be written: the caller retries at the next sync.
244223
+ * Make the `mailboxId` link of the DEFAULT integration say it uses the mailbox. It is filled only
244224
+ * while empty (a pick of the operator is never overwritten) and released only if this process
244225
+ * filled it. A hub integration carries no link: a stale one is cleared. With no default
244226
+ * resolved nothing is touched. False when the links could not be written.
243413
244227
  */
243414
- async syncLinks(brokerId, owners) {
244228
+ async syncLinks(brokerId, defaultId, inUse) {
244229
+ if (defaultId === null) return true;
243415
244230
  try {
243416
244231
  const rows = await this.deps.links.list();
243417
- for (const row of rows) {
243418
- const wanted = owners.has(row.id) ? brokerId : "";
243419
- if (row.mailboxId !== wanted) await this.deps.links.set(row.id, wanted);
243420
- }
243421
- for (const owner of owners) if (!rows.some((row) => row.id === owner)) this.deps.logger.warn("email-push: an integration with email-push cameras has no record to link the mailbox from", { meta: {
243422
- integrationId: owner,
244232
+ for (const row of rows) if (row.id !== defaultId) {
244233
+ if (row.mailboxId !== "") await this.deps.links.set(row.id, "");
244234
+ } else if (inUse && row.mailboxId === "") {
244235
+ await this.deps.links.set(row.id, brokerId);
244236
+ this.filled.add(row.id);
244237
+ } else if (!inUse && this.filled.has(row.id) && row.mailboxId === brokerId) {
244238
+ await this.deps.links.set(row.id, "");
244239
+ this.filled.delete(row.id);
244240
+ }
244241
+ if (inUse && !rows.some((row) => row.id === defaultId)) this.deps.logger.warn("email-push: the default integration has no record to link the mailbox from", { meta: {
244242
+ integrationId: defaultId,
243423
244243
  brokerId
243424
244244
  } });
243425
244245
  return true;
@@ -243558,7 +244378,7 @@ var EmailPushBridge = class {
243558
244378
  */
243559
244379
  async buildCameraSetupParams(cam) {
243560
244380
  if (!cam.isEmailPushEligible) return null;
243561
- const brokerId = await this.ensureMailbox();
244381
+ const brokerId = await this.resolveMailbox();
243562
244382
  const parsed = SmtpInboundConfigSchema.safeParse(await this.deps.port.getBrokerConfig(brokerId));
243563
244383
  if (!parsed.success) throw new Error("The camera mailbox answered a configuration this build cannot read");
243564
244384
  const config = parsed.data;
@@ -243580,6 +244400,60 @@ function pickMailbox(list) {
243580
244400
  return list.find((b) => b.id === "smtp-inbound-default")?.id ?? list[0]?.id ?? null;
243581
244401
  }
243582
244402
  //#endregion
244403
+ //#region src/email-push-removal-hook.ts
244404
+ /**
244405
+ * A removed camera leaves its `cam-<stableId>` recipient in the mailbox (D865). The addon holds
244406
+ * no per-device DATA for the intake (the mailbox is owned by the mail addon), so removal only
244407
+ * redeclares the recipient set without the camera. Driven by the tombstone, never by absence.
244408
+ */
244409
+ function createEmailPushRemovalHook(deps) {
244410
+ return {
244411
+ onDeviceRemoved: async () => {
244412
+ await deps.resync();
244413
+ return { counts: { "mailbox-recipients": 0 } };
244414
+ },
244415
+ listDeviceData: async () => []
244416
+ };
244417
+ }
244418
+ var LEGACY_PREFIX = "/webhook/";
244419
+ async function startLegacyWebhookIntake(deps) {
244420
+ const warned = /* @__PURE__ */ new Set();
244421
+ const server = (0, node_http.createServer)((req, res) => {
244422
+ const url = req.url ?? "";
244423
+ if (!url.startsWith(LEGACY_PREFIX)) {
244424
+ res.writeHead(404).end();
244425
+ return;
244426
+ }
244427
+ const rest = url.slice(8);
244428
+ req.url = rest;
244429
+ const id = decodeURIComponent(rest.replace(/^\//, "").split("?")[0] ?? "");
244430
+ const camera = deps.listCameras().find((c) => c.stableId === id);
244431
+ if (camera !== void 0 && !warned.has(id)) {
244432
+ warned.add(id);
244433
+ deps.logger.warn("legacy webhook port used — camera will be re-pointed", {
244434
+ tags: { deviceId: camera.id },
244435
+ meta: { port: deps.port ?? 9081 }
244436
+ });
244437
+ }
244438
+ Promise.resolve(deps.handler(req, res)).catch((err) => {
244439
+ deps.logger.error("legacy webhook intake failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
244440
+ if (!res.headersSent) res.writeHead(500);
244441
+ res.end();
244442
+ });
244443
+ });
244444
+ await new Promise((resolve, reject) => {
244445
+ server.once("error", reject);
244446
+ server.listen(deps.port ?? 9081, "0.0.0.0", () => {
244447
+ server.off("error", reject);
244448
+ resolve();
244449
+ });
244450
+ });
244451
+ return {
244452
+ server,
244453
+ close: () => new Promise((resolve) => server.close(() => resolve()))
244454
+ };
244455
+ }
244456
+ //#endregion
243583
244457
  //#region src/reolink-connection-test.ts
243584
244458
  /**
243585
244459
  * The Reolink NVR / Home Hub connection test (planning#581): log in over Baichuan with the
@@ -243687,6 +244561,28 @@ var reolinkConnectionsEntryKind = defineEntryKind("connections", {
243687
244561
  }),
243688
244562
  writeTrigger: "an operator adds, edits or removes a Reolink integration"
243689
244563
  });
244564
+ /** The kind of the default integration (standalone cameras): a name and the mailbox link, no Test. */
244565
+ var REOLINK_DEFAULT_KIND = "default";
244566
+ /** The kind of an NVR / Home Hub integration: its connection, with a Test. */
244567
+ var REOLINK_HUB_KIND = "connection";
244568
+ /** The form of the default integration: which camera mailbox its standalone cameras use. */
244569
+ function buildDefaultInstanceSchema() {
244570
+ return { sections: [{
244571
+ id: "mailbox",
244572
+ title: "Camera mailbox",
244573
+ titleKey: "provider-reolink:connection.s_mailbox.title",
244574
+ description: "The mailbox the standalone cameras send their email push to.",
244575
+ descriptionKey: "provider-reolink:connection.s_mailbox.description",
244576
+ columns: 1,
244577
+ fields: [{
244578
+ ...linkFieldDescriptor(MAILBOX_LINK_FIELD, SMTP_MAILBOX_LINK, {
244579
+ label: "Camera mailbox",
244580
+ required: false
244581
+ }),
244582
+ labelKey: "provider-reolink:connection.s_mailbox.mailboxId.label"
244583
+ }]
244584
+ }] };
244585
+ }
243690
244586
  /** Every kind this addon declares, keyed by its name. */
243691
244587
  var reolinkRecordKinds = { connections: reolinkConnectionsEntryKind };
243692
244588
  /**
@@ -243793,12 +244689,26 @@ function buildReolinkInstances(records, deps) {
243793
244689
  kind: "connection",
243794
244690
  canTest: true,
243795
244691
  kinds: [{
243796
- id: "connection",
243797
- label: "Reolink",
244692
+ id: REOLINK_DEFAULT_KIND,
244693
+ label: "Reolink standalone cameras",
243798
244694
  functionCap: "device-provider",
243799
- role: "devices"
244695
+ role: "devices",
244696
+ canTest: false,
244697
+ creatable: false
244698
+ }, {
244699
+ id: REOLINK_HUB_KIND,
244700
+ label: "Reolink NVR / Home Hub",
244701
+ functionCap: "device-provider",
244702
+ role: "devices",
244703
+ canTest: true
244704
+ }],
244705
+ links: [{
244706
+ kind: REOLINK_DEFAULT_KIND,
244707
+ field: MAILBOX_LINK_FIELD,
244708
+ to: SMTP_MAILBOX_LINK
243800
244709
  }]
243801
244710
  },
244711
+ kindOf: () => REOLINK_HUB_KIND,
243802
244712
  formSchema: () => buildHubInstanceSchema(),
243803
244713
  initialBody: (name) => ({ name }),
243804
244714
  configured: (body) => (body.host ?? "").length === 0 || (body.password ?? "").length > 0,
@@ -243812,10 +244722,15 @@ function buildReolinkInstances(records, deps) {
243812
244722
  */
243813
244723
  function reolinkInstancesProvider(instances, deps) {
243814
244724
  const base = instances.toProvider();
243815
- const withAddDevice = async (instance) => ({
243816
- ...instance,
243817
- addDevice: await integrationIsHubCached(instances, deps.evidenceCache, instance.id) ? "children" : "scan"
243818
- });
244725
+ const withAddDevice = async (instance) => {
244726
+ const isHub = await integrationIsHubCached(instances, deps.evidenceCache, instance.id);
244727
+ const known = deps.evidenceCache.get(instance.id) !== null;
244728
+ return {
244729
+ ...instance,
244730
+ kind: known && !isHub ? REOLINK_DEFAULT_KIND : REOLINK_HUB_KIND,
244731
+ addDevice: isHub ? "children" : "scan"
244732
+ };
244733
+ };
243819
244734
  return {
243820
244735
  ...base,
243821
244736
  listInstances: async (input) => Promise.all((await base.listInstances(input)).map(withAddDevice)),
@@ -243831,7 +244746,7 @@ function reolinkInstancesProvider(instances, deps) {
243831
244746
  originStableId: evidence.originStableId,
243832
244747
  info: evidence.info,
243833
244748
  settings: body === null ? {} : hubSettingsOf(body)
243834
- }) || body === null ? buildHubInstanceSchema() : { sections: [] };
244749
+ }) || body === null ? buildHubInstanceSchema() : buildDefaultInstanceSchema();
243835
244750
  }
243836
244751
  };
243837
244752
  }
@@ -243883,60 +244798,6 @@ function mailboxLinkStoreOver(records) {
243883
244798
  };
243884
244799
  }
243885
244800
  //#endregion
243886
- //#region src/email-push-removal-hook.ts
243887
- /**
243888
- * A removed camera leaves its `cam-<stableId>` recipient in the mailbox (D865). The addon holds
243889
- * no per-device DATA for the intake (the mailbox is owned by the mail addon), so removal only
243890
- * redeclares the recipient set without the camera. Driven by the tombstone, never by absence.
243891
- */
243892
- function createEmailPushRemovalHook(deps) {
243893
- return {
243894
- onDeviceRemoved: async () => {
243895
- await deps.resync();
243896
- return { counts: { "mailbox-recipients": 0 } };
243897
- },
243898
- listDeviceData: async () => []
243899
- };
243900
- }
243901
- var LEGACY_PREFIX = "/webhook/";
243902
- async function startLegacyWebhookIntake(deps) {
243903
- const warned = /* @__PURE__ */ new Set();
243904
- const server = (0, node_http.createServer)((req, res) => {
243905
- const url = req.url ?? "";
243906
- if (!url.startsWith(LEGACY_PREFIX)) {
243907
- res.writeHead(404).end();
243908
- return;
243909
- }
243910
- const rest = url.slice(8);
243911
- req.url = rest;
243912
- const id = decodeURIComponent(rest.replace(/^\//, "").split("?")[0] ?? "");
243913
- const camera = deps.listCameras().find((c) => c.stableId === id);
243914
- if (camera !== void 0 && !warned.has(id)) {
243915
- warned.add(id);
243916
- deps.logger.warn("legacy webhook port used — camera will be re-pointed", {
243917
- tags: { deviceId: camera.id },
243918
- meta: { port: deps.port ?? 9081 }
243919
- });
243920
- }
243921
- Promise.resolve(deps.handler(req, res)).catch((err) => {
243922
- deps.logger.error("legacy webhook intake failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
243923
- if (!res.headersSent) res.writeHead(500);
243924
- res.end();
243925
- });
243926
- });
243927
- await new Promise((resolve, reject) => {
243928
- server.once("error", reject);
243929
- server.listen(deps.port ?? 9081, "0.0.0.0", () => {
243930
- server.off("error", reject);
243931
- resolve();
243932
- });
243933
- });
243934
- return {
243935
- server,
243936
- close: () => new Promise((resolve) => server.close(() => resolve()))
243937
- };
243938
- }
243939
- //#endregion
243940
244801
  //#region src/migrations/drop-webhook-intake-settings.ts
243941
244802
  /**
243942
244803
  * The camera webhook is a plane of the addon's HTTP data plane, not a private listener
@@ -244157,6 +245018,14 @@ var REOLINK_MIGRATIONS = [{
244157
245018
  },
244158
245019
  plan: planDropWebhookIntakeSettings
244159
245020
  }];
245021
+ /** The date of the device claim (D1007). */
245022
+ var CLAIM_DEVICES_DATE = "2026-11-04";
245023
+ /**
245024
+ * Every persisted camera that names no integration is claimed to the addon's default one. The
245025
+ * integration a hub migration created is never the default, so it is not eligible. The integration
245026
+ * settings themselves stay where they are until this addon's own wave moves them.
245027
+ */
245028
+ var REOLINK_CLAIM_ELIGIBLE = (integration) => integration.info[MIGRATED_FROM_HUB_KEY] === void 0;
244160
245029
  /**
244161
245030
  * The integration wave (D1007) in declaration order, which must follow `seq`: the device claim
244162
245031
  * shipped first (seq 3) and the rows move follows it (seq 4). The engine refuses the whole
@@ -244164,10 +245033,10 @@ var REOLINK_MIGRATIONS = [{
244164
245033
  */
244165
245034
  var REOLINK_INTEGRATION_MIGRATIONS = [claimDevicesMigration({
244166
245035
  addonId: "provider-reolink",
244167
- date: "2026-11-04",
245036
+ date: CLAIM_DEVICES_DATE,
244168
245037
  seq: 3,
244169
245038
  dependsOn: [],
244170
- eligible: (integration) => integration.info[MIGRATED_FROM_HUB_KEY] === void 0
245039
+ eligible: REOLINK_CLAIM_ELIGIBLE
244171
245040
  }), REOLINK_ROWS_TO_RECORD_MIGRATION];
244172
245041
  //#endregion
244173
245042
  //#region src/reolink-adoption-provider.ts
@@ -245019,12 +245888,24 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
245019
245888
  if (records === void 0) throw new Error("provider-reolink: ctx.records is required (hub-only addon)");
245020
245889
  return records;
245021
245890
  }
245891
+ /**
245892
+ * The registry id of the default integration (standalone cameras): the lowest-numbered one this
245893
+ * addon owns that no hub migration created, the same rule as the device claim (D1007).
245894
+ */
245895
+ async resolveDefaultIntegrationId() {
245896
+ return defaultIntegrationOf((await this.ctx.api.integrations.list.query()).filter((i) => i.addonId === this.ctx.id).map((i) => ({
245897
+ id: i.id,
245898
+ name: i.name,
245899
+ info: { ...i.info }
245900
+ })), REOLINK_CLAIM_ELIGIBLE)?.id ?? null;
245901
+ }
245022
245902
  /** The camera mailbox bridge, built once. */
245023
245903
  ensureEmailBridge() {
245024
245904
  this.emailBridge ??= new EmailPushBridge({
245025
245905
  port: createBrokerPort(this.ctx.api),
245026
245906
  links: mailboxLinkStoreOver(this.requireRecords()),
245027
245907
  listCameras: () => this.listReolinkCameras(),
245908
+ defaultIntegrationId: () => this.resolveDefaultIntegrationId(),
245028
245909
  logger: this.ctx.logger.child("email-push"),
245029
245910
  pending: {
245030
245911
  read: () => this.readPendingMailbox(),