@camstack/addon-provider-homematic 1.2.198 → 1.2.199

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
@@ -820,7 +820,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
820
820
  return EventCategory;
821
821
  }({});
822
822
  //#endregion
823
- //#region ../types/dist/composed-stable-id-B3wcvtvW.mjs
823
+ //#region ../types/dist/composed-stable-id-COP6zOXx.mjs
824
824
  /**
825
825
  import { errMsg } from '@camstack/types'
826
826
  * Extract a human-readable message from an unknown error value.
@@ -833,8 +833,6 @@ function errMsg(err) {
833
833
  }
834
834
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
835
835
  DeviceType["Camera"] = "camera";
836
- /** Legacy stored value, read only by the hub-to-integration migrations; no live device carries it. */
837
- DeviceType["Hub"] = "hub";
838
836
  DeviceType["Light"] = "light";
839
837
  DeviceType["Siren"] = "siren";
840
838
  DeviceType["Switch"] = "switch";
@@ -6071,7 +6069,7 @@ var ZodIssueCode = {
6071
6069
  var ZodFirstPartyTypeKind;
6072
6070
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6073
6071
  //#endregion
6074
- //#region ../types/dist/sleep-D7hCDd7y.mjs
6072
+ //#region ../types/dist/sleep-B5XPl2YP.mjs
6075
6073
  /**
6076
6074
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6077
6075
  * window to float samples (D455).
@@ -6734,7 +6732,8 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
6734
6732
  try {
6735
6733
  declaration = await host.declareOwner({
6736
6734
  owner,
6737
- metas: migrations.map((m) => m.meta)
6735
+ metas: migrations.map((m) => m.meta),
6736
+ ...options.retired === void 0 ? {} : { retired: [...options.retired] }
6738
6737
  });
6739
6738
  } catch (err) {
6740
6739
  log.error("the migration engine refused or could not take this addon catalogue — none ran", { meta: { error: errMsg(err) } });
@@ -8667,6 +8666,14 @@ var BaseAddon = class {
8667
8666
  declareRegistrySwitch(spec) {
8668
8667
  this.registrySwitchSpec = spec;
8669
8668
  }
8669
+ /**
8670
+ * Ids this addon removed from its catalogue on purpose (`declareRetiredMigrations`): sent with
8671
+ * every declaration so the engine does not read their applied rows as a newer database.
8672
+ */
8673
+ retiredMigrationIds = [];
8674
+ declareRetiredMigrations(ids) {
8675
+ this.retiredMigrationIds = ids;
8676
+ }
8670
8677
  registrySwitchSpec = null;
8671
8678
  registrySwitchBound() {
8672
8679
  const spec = this.registrySwitchSpec;
@@ -8690,10 +8697,14 @@ var BaseAddon = class {
8690
8697
  async runBound(declared, options) {
8691
8698
  const added = this.registrySwitchBound();
8692
8699
  const migrations = [...declared, ...added];
8693
- const phased = options?.only === void 0 || added.length === 0 ? options : {
8700
+ const widened = options?.only === void 0 || added.length === 0 ? options : {
8694
8701
  ...options,
8695
8702
  only: [...options.only, ...added.map((m) => m.meta.id)]
8696
8703
  };
8704
+ const phased = this.retiredMigrationIds.length === 0 ? widened ?? {} : {
8705
+ ...widened,
8706
+ retired: this.retiredMigrationIds
8707
+ };
8697
8708
  const api = this.ctx.api.migrations;
8698
8709
  const report = await runAddonMigrations({
8699
8710
  declareOwner: (input) => api.declareOwner.mutate(input),
@@ -21668,7 +21679,7 @@ Object.freeze({
21668
21679
  }
21669
21680
  });
21670
21681
  //#endregion
21671
- //#region ../types/dist/implemented-methods-CgUBu6uM.mjs
21682
+ //#region ../types/dist/implemented-methods-0xxMOekw.mjs
21672
21683
  /**
21673
21684
  * The ffmpeg build every CamStack node downloads, per platform and arch.
21674
21685
  *
@@ -57522,7 +57533,7 @@ var mediaPlayerCapability = {
57522
57533
  ]
57523
57534
  }
57524
57535
  };
57525
- DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, 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.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.EnergySystem, 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.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.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.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.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;
57536
+ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter, 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.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.EnergySystem, 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.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.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.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.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;
57526
57537
  var NUMBER = {
57527
57538
  kind: "fixed",
57528
57539
  result: ["number"]
@@ -61849,7 +61860,7 @@ var TransitionsStatusSchema = object({
61849
61860
  /** Refused rows since start, by reason. */
61850
61861
  refused: record$1(string(), number$1())
61851
61862
  });
61852
- Object.values(DeviceType).filter((type) => type !== DeviceType.Hub && type !== DeviceType.Container), method(object({
61863
+ Object.values(DeviceType).filter((type) => type !== DeviceType.Container), method(object({
61853
61864
  deviceId: number$1().int(),
61854
61865
  capName: string().optional(),
61855
61866
  actorKind: TransitionActorKindSchema.optional(),
@@ -65796,7 +65807,7 @@ var HeroSceneSchema = object({
65796
65807
  /** 0..1: volume, cover position, cycle progress. */
65797
65808
  level: number$1().min(0).max(1).nullable()
65798
65809
  });
65799
- DeviceType.Camera, DeviceType.Hub, 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.HeatPump, DeviceType.EnergySystem, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
65810
+ 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.HeatPump, DeviceType.EnergySystem, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
65800
65811
  DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.SwitchLight, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
65801
65812
  var HeroRowIdSchema = _enum([
65802
65813
  "progress",
@@ -70552,7 +70563,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
70552
70563
  auth: "admin"
70553
70564
  }), method(object({
70554
70565
  owner: string().min(1),
70555
- metas: array(MigrationMetaSchema)
70566
+ metas: array(MigrationMetaSchema),
70567
+ /** Ids the owner deliberately removed: an applied row of one is fine, never "newer". */
70568
+ retired: array(string().min(1)).optional()
70556
70569
  }), object({
70557
70570
  bootId: string(),
70558
70571
  snapshot: _enum([
@@ -94999,7 +95012,7 @@ var BaseDeviceProvider = class extends BaseAddon {
94999
95012
  }
95000
95013
  };
95001
95014
  DeviceType.HeatPump;
95002
- DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
95015
+ DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Camera, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
95003
95016
  new Set(Object.values(DeviceType));
95004
95017
  /** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
95005
95018
  function contribution(cap, schema, build) {
@@ -97044,7 +97057,7 @@ var HEAT_PUMP_FAMILY_CONTRIBUTIONS = { "heat-pump-status": contribution("heat-pu
97044
97057
  ...Object.values(CLIMATE_FAMILY_CONTRIBUTIONS),
97045
97058
  ...Object.values(HEAT_PUMP_FAMILY_CONTRIBUTIONS)
97046
97059
  ];
97047
- DeviceType.Camera, DeviceType.Hub, 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.HeatPump, DeviceType.EnergySystem, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
97060
+ 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.HeatPump, DeviceType.EnergySystem, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
97048
97061
  /**
97049
97062
  * Who looks like what (D1023). One look per {@link DeviceType}, refined by a
97050
97063
  * {@link DeviceRole} where the role changes how the device reads (a leak
@@ -97688,7 +97701,7 @@ lookOf({
97688
97701
  standby: MUTED
97689
97702
  });
97690
97703
  DeviceType.Climate;
97691
- DeviceType.Camera, DeviceType.Hub, 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.HeatPump, DeviceType.EnergySystem, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
97704
+ 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.HeatPump, DeviceType.EnergySystem, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
97692
97705
  DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.SwitchLight, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
97693
97706
  Object.freeze({
97694
97707
  "accessories.getStatus": {
@@ -108159,7 +108172,7 @@ function offered(received) {
108159
108172
  };
108160
108173
  }
108161
108174
  offered(HA_AS), withheld(HOMEKIT_REASON), withheld(ALEXA_REASON), withheld(GOOGLE_REASON), withheld(MATTER_REASON);
108162
- DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.HeatPump, DeviceType.EnergySystem, 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.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
108175
+ DeviceType.Camera, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.HeatPump, DeviceType.EnergySystem, 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.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
108163
108176
  DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.SwitchLight, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
108164
108177
  new Set(Object.values(DeviceType));
108165
108178
  new Set(Object.values(DeviceRole));
@@ -113712,6 +113725,17 @@ function buildCcuDeviceStateHandlers(deps) {
113712
113725
  channels: device.channels.map(toChannelValues)
113713
113726
  };
113714
113727
  },
113728
+ /**
113729
+ * Read-only: why a key does not deliver presses. The library reads the
113730
+ * central link, direct links, VALUES/MASTER, the CCU's own data point
113731
+ * timestamps and the programs using the key, and when this client last
113732
+ * received each event — every section on its own (nodehomematic 0.8.0).
113733
+ */
113734
+ diagnoseCcuKeyEvents: async (input) => {
113735
+ const facade = requireFacade(deps, input.integrationId);
113736
+ requireDevice(facade.devices(), input.address);
113737
+ return facade.diagnoseKeyEvents(input.address);
113738
+ },
113715
113739
  setCcuValue: async (input) => {
113716
113740
  requireConfirmed(input.confirmed);
113717
113741
  const facade = requireFacade(deps, input.integrationId);
@@ -132281,7 +132305,7 @@ function serializeValue(value) {
132281
132305
  if (value instanceof Date) return `<value><dateTime.iso8601>${formatDateTime(value)}</dateTime.iso8601></value>`;
132282
132306
  if (value instanceof Uint8Array) return `<value><base64>${Buffer.from(value).toString("base64")}</base64></value>`;
132283
132307
  if (Array.isArray(value)) return `<value><array><data>${value.map((item) => serializeValue(item)).join("")}</data></array></value>`;
132284
- return `<value><struct>${Object.entries(value).map(([name, member]) => `<member><name>${escapeXml(name)}</name>${serializeValue(member)}</member>`).join("")}</struct></value>`;
132308
+ return `<value><struct>${Object.entries(value).map(([name2, member]) => `<member><name>${escapeXml(name2)}</name>${serializeValue(member)}</member>`).join("")}</struct></value>`;
132285
132309
  }
132286
132310
  function paramsBlock(params) {
132287
132311
  if (params.length === 0) return "<params></params>";
@@ -132364,8 +132388,8 @@ function parseStruct(structChildren) {
132364
132388
  const nameNodes = childrenOf(member, "name");
132365
132389
  const valueNodes = childrenOf(member, "value");
132366
132390
  if (nameNodes === void 0 || valueNodes === void 0) continue;
132367
- const name = textOf(nameNodes);
132368
- result[name] = parseValue(valueNodes);
132391
+ const name2 = textOf(nameNodes);
132392
+ result[name2] = parseValue(valueNodes);
132369
132393
  }
132370
132394
  return result;
132371
132395
  }
@@ -132632,11 +132656,11 @@ var InterfaceClient = class {
132632
132656
  * these four strings. Not retried: a second attempt after a lost answer
132633
132657
  * could race the first.
132634
132658
  */
132635
- async addLink(sender, receiver, name, description) {
132659
+ async addLink(sender, receiver, name2, description) {
132636
132660
  await this.callGuarded("addLink", [
132637
132661
  sender,
132638
132662
  receiver,
132639
- name,
132663
+ name2,
132640
132664
  description
132641
132665
  ]);
132642
132666
  }
@@ -133539,9 +133563,9 @@ function isRecord(value) {
133539
133563
  return value !== null && typeof value === "object" && !Array.isArray(value);
133540
133564
  }
133541
133565
  function validName(raw, what) {
133542
- const name = raw.trim();
133543
- if (name === "" || name.length > MAX_NAME || CONTROL_CHARS2.test(name)) throw new ValidationError(`${what} name must be 1..${MAX_NAME} characters without control characters.`);
133544
- return name;
133566
+ const name2 = raw.trim();
133567
+ if (name2 === "" || name2.length > MAX_NAME || CONTROL_CHARS2.test(name2)) throw new ValidationError(`${what} name must be 1..${MAX_NAME} characters without control characters.`);
133568
+ return name2;
133545
133569
  }
133546
133570
  function validRoomId(id) {
133547
133571
  if (!ROOM_ID.test(id)) throw new ValidationError(`Invalid room id "${id}".`);
@@ -133576,11 +133600,11 @@ var CcuTopology = class {
133576
133600
  /** Rename a device, and with `renameChannels` every channel to `<name>:<index>`. */
133577
133601
  async renameDevice(address, rawName, renameChannels) {
133578
133602
  if (!DEVICE_ADDRESS.test(address)) throw new ValidationError(`Invalid device address "${address}".`);
133579
- const name = validName(rawName, "Device");
133603
+ const name2 = validName(rawName, "Device");
133580
133604
  const label = "ReGa.runScript(renameDevice)";
133581
133605
  const answer = okOf(await this.#rega(label, RENAME_DEVICE, {
133582
133606
  address,
133583
- name,
133607
+ name: name2,
133584
133608
  channels: renameChannels ? "1" : "0"
133585
133609
  }), label);
133586
133610
  if (answer["ok"] !== true) throw new ValidationError(`Unknown device "${address}".`);
@@ -133602,11 +133626,11 @@ var CcuTopology = class {
133602
133626
  /** Rename one channel; resolves with the name the CCU stored. */
133603
133627
  async renameChannel(address, rawName) {
133604
133628
  validChannelAddress(address);
133605
- const name = validName(rawName, "Channel");
133629
+ const name2 = validName(rawName, "Channel");
133606
133630
  const label = "ReGa.runScript(renameChannel)";
133607
133631
  const answer = okOf(await this.#rega(label, RENAME_CHANNEL, {
133608
133632
  address,
133609
- name
133633
+ name: name2
133610
133634
  }), label);
133611
133635
  if (answer["ok"] !== true) throw new ValidationError(`Unknown channel "${address}".`);
133612
133636
  return {
@@ -133625,10 +133649,10 @@ var CcuTopology = class {
133625
133649
  }
133626
133650
  /** Create an empty room; a room of the same name is a {@link ValidationError}. */
133627
133651
  async createRoom(rawName) {
133628
- const name = validName(rawName, "Room");
133652
+ const name2 = validName(rawName, "Room");
133629
133653
  const label = "ReGa.runScript(createRoom)";
133630
- const answer = okOf(await this.#rega(label, CREATE_ROOM, { name }), label);
133631
- if (answer["error"] === "exists") throw new ValidationError(`A room named "${name}" already exists.`);
133654
+ const answer = okOf(await this.#rega(label, CREATE_ROOM, { name: name2 }), label);
133655
+ if (answer["error"] === "exists") throw new ValidationError(`A room named "${name2}" already exists.`);
133632
133656
  const room = toRoom({
133633
133657
  ...answer,
133634
133658
  channels: []
@@ -133638,11 +133662,11 @@ var CcuTopology = class {
133638
133662
  }
133639
133663
  /** Rename a room by id. */
133640
133664
  async renameRoom(id, rawName) {
133641
- const name = validName(rawName, "Room");
133665
+ const name2 = validName(rawName, "Room");
133642
133666
  const label = "ReGa.runScript(renameRoom)";
133643
133667
  if (okOf(await this.#rega(label, RENAME_ROOM, {
133644
133668
  id: validRoomId(id),
133645
- name
133669
+ name: name2
133646
133670
  }), label)["ok"] !== true) throw new ValidationError(`Unknown room "${id}".`);
133647
133671
  }
133648
133672
  /** Delete a room by id; an unerasable room is a {@link ValidationError}. */
@@ -133674,25 +133698,35 @@ var CcuTopology = class {
133674
133698
  var DATAPOINT_NAME = /^[0-9A-Za-z_-]+\.[0-9A-Za-z_-]+:\d+\.PRESS_(?:SHORT|LONG)$/;
133675
133699
  function checkedDatapoints(datapoints) {
133676
133700
  if (datapoints.length === 0) throw new ValidationError("A key event program needs at least one data point.");
133677
- for (const name of datapoints) if (!DATAPOINT_NAME.test(name)) throw new ValidationError(`Invalid key data point "${name}".`);
133701
+ for (const name2 of datapoints) if (!DATAPOINT_NAME.test(name2)) throw new ValidationError(`Invalid key data point "${name2}".`);
133678
133702
  return datapoints;
133679
133703
  }
133680
133704
  var FIND_PROGRAM = `string sName = "##name##";
133681
133705
  object oPrograms = dom.GetObject(ID_PROGRAMS);
133682
133706
  object oProg;
133683
133707
  string sPid;
133708
+ string sIds = "";
133709
+ string sIdSep = "";
133710
+ integer iMatches = 0;
133684
133711
  foreach(sPid, oPrograms.EnumUsedIDs()) {
133685
133712
  object oCand = dom.GetObject(sPid);
133686
133713
  if (oCand) {
133687
133714
  if (oCand.Name() == sName) {
133688
133715
  oProg = oCand;
133716
+ sIds = sIds # sIdSep # "\\"" # sPid # "\\"";
133717
+ sIdSep = ",";
133718
+ iMatches = iMatches + 1;
133689
133719
  }
133690
133720
  }
133691
133721
  }`;
133722
+ var UNLESS_DUPLICATE = `if (iMatches > 1) {
133723
+ Write("{\\"error\\":\\"duplicate\\",\\"ids\\":[" # sIds # "]}");
133724
+ } else {`;
133692
133725
  function buildEnsureKeyEventProgram(datapoints) {
133693
133726
  const dps = checkedDatapoints(datapoints);
133694
133727
  return `! nodehomematic:ensureKeyEventProgram
133695
133728
  ${FIND_PROGRAM}
133729
+ ${UNLESS_DUPLICATE}
133696
133730
  string sMissing = "";
133697
133731
  string sMissSep = "";
133698
133732
  ${dps.map((dp, i) => `object oDp${i} = dom.GetObject("${dp}");
@@ -133740,18 +133774,22 @@ oSc.ConditionChannel(oDp${i}.Channel());`).join("\n")}
133740
133774
  Write("false");
133741
133775
  }
133742
133776
  Write("}");
133777
+ }
133743
133778
  }`;
133744
133779
  }
133745
133780
  var REMOVE_KEY_EVENT_PROGRAM = `! nodehomematic:removeKeyEventProgram
133746
133781
  ${FIND_PROGRAM}
133747
- if (oProg) {
133748
- dom.DeleteObject(oProg.ID());
133749
- Write("{\\"removed\\":true}");
133750
- } else {
133751
- Write("{\\"removed\\":false}");
133782
+ ${UNLESS_DUPLICATE}
133783
+ if (oProg) {
133784
+ dom.DeleteObject(oProg.ID());
133785
+ Write("{\\"removed\\":true}");
133786
+ } else {
133787
+ Write("{\\"removed\\":false}");
133788
+ }
133752
133789
  }`;
133753
133790
  var GET_KEY_EVENT_PROGRAM = `! nodehomematic:getKeyEventProgram
133754
133791
  ${FIND_PROGRAM}
133792
+ ${UNLESS_DUPLICATE}
133755
133793
  if (!oProg) {
133756
133794
  Write("{\\"found\\":false}");
133757
133795
  } else {
@@ -133777,7 +133815,32 @@ if (!oProg) {
133777
133815
  }
133778
133816
  }
133779
133817
  Write("]}");
133818
+ }
133819
+ }`;
133820
+ var PROGRAM_ID = /^\d+$/;
133821
+ function buildDeleteProgram(programId) {
133822
+ if (!PROGRAM_ID.test(programId)) throw new ValidationError(`Invalid program id "${programId}".`);
133823
+ return `! nodehomematic:deleteProgram
133824
+ string sId = "${programId}";
133825
+ string sPid;
133826
+ boolean bProgram = false;
133827
+ foreach(sPid, dom.GetObject(ID_PROGRAMS).EnumUsedIDs()) {
133828
+ if (sPid == sId) {
133829
+ bProgram = true;
133830
+ }
133831
+ }
133832
+ if (bProgram) {
133833
+ object oProg = dom.GetObject(sId);
133834
+ if (oProg) {
133835
+ dom.DeleteObject(oProg.ID());
133836
+ Write("{\\"removed\\":true}");
133837
+ } else {
133838
+ Write("{\\"removed\\":false}");
133839
+ }
133840
+ } else {
133841
+ Write("{\\"removed\\":false}");
133780
133842
  }`;
133843
+ }
133781
133844
  var CHANNEL_ADDRESS2 = /^[0-9A-Za-z_-]+:\d+$/;
133782
133845
  var CONTROL_CHARS3 = /[\u0000-\u001F\u007F]/;
133783
133846
  var MAX_NAME2 = 128;
@@ -133789,13 +133852,19 @@ function record(raw, label) {
133789
133852
  if (!isRecord2(raw)) throw new ClientError(`${label}: unexpected answer from the CCU.`);
133790
133853
  return raw;
133791
133854
  }
133855
+ function throwIfDuplicate(answer, name2) {
133856
+ if (answer["error"] !== "duplicate") return;
133857
+ const raw = answer["ids"];
133858
+ const ids = Array.isArray(raw) ? raw.filter((id) => typeof id === "string" && id !== "") : [];
133859
+ throw new ValidationError(`More than one program is named "${name2}" (ids ${ids.length > 0 ? ids.join(", ") : "?"}). deleteProgram(id) deletes one of them.`);
133860
+ }
133792
133861
  function validName2(raw) {
133793
- const name = raw.trim();
133794
- if (name === "" || name.length > MAX_NAME2 || CONTROL_CHARS3.test(name)) throw new ValidationError(`Program name must be 1..${MAX_NAME2} characters without control characters.`);
133795
- return name;
133862
+ const name2 = raw.trim();
133863
+ if (name2 === "" || name2.length > MAX_NAME2 || CONTROL_CHARS3.test(name2)) throw new ValidationError(`Program name must be 1..${MAX_NAME2} characters without control characters.`);
133864
+ return name2;
133796
133865
  }
133797
133866
  function interfaceNameOf(interfaceId2) {
133798
- const match = Object.values(Interface).find((name) => interfaceId2.endsWith(`-${name}`));
133867
+ const match = Object.values(Interface).find((name2) => interfaceId2.endsWith(`-${name2}`));
133799
133868
  if (match === void 0) throw new ValidationError(`Cannot derive the CCU interface from "${interfaceId2}".`);
133800
133869
  return match;
133801
133870
  }
@@ -133810,7 +133879,7 @@ var CcuKeyPrograms = class {
133810
133879
  * channels live on (`HmIP-RF`).
133811
133880
  */
133812
133881
  async ensure(interfaceName, input) {
133813
- const name = validName2(input.name);
133882
+ const name2 = validName2(input.name);
133814
133883
  const parameters = input.parameters ?? DEFAULT_PARAMETERS;
133815
133884
  if (parameters.length === 0) throw new ValidationError("At least one key parameter is needed.");
133816
133885
  const datapoints = input.channelAddresses.flatMap((address) => {
@@ -133818,7 +133887,8 @@ var CcuKeyPrograms = class {
133818
133887
  return parameters.map((param) => `${interfaceName}.${address}.${param}`);
133819
133888
  });
133820
133889
  const label = "ReGa.runScript(ensureKeyEventProgram)";
133821
- const answer = record(await this.#rega(label, buildEnsureKeyEventProgram(datapoints), { name }), label);
133890
+ const answer = record(await this.#rega(label, buildEnsureKeyEventProgram(datapoints), { name: name2 }), label);
133891
+ throwIfDuplicate(answer, name2);
133822
133892
  if (answer["error"] === "datapoint") throw new ValidationError(`The CCU has no such key data point: ${Array.isArray(answer["missing"]) ? answer["missing"].join(", ") : "?"}.`);
133823
133893
  const programId = answer["programId"];
133824
133894
  const created = answer["created"];
@@ -133828,19 +133898,32 @@ var CcuKeyPrograms = class {
133828
133898
  created
133829
133899
  };
133830
133900
  }
133901
+ /**
133902
+ * Delete the program `programId` (digits only). `removed: false` when the id
133903
+ * is missing or is not a program; nothing is deleted in that case.
133904
+ */
133905
+ async delete(programId) {
133906
+ const script = buildDeleteProgram(programId);
133907
+ const label = "ReGa.runScript(deleteProgram)";
133908
+ const answer = record(await this.#rega(label, script), label);
133909
+ if (typeof answer["removed"] !== "boolean") throw new ClientError(`${label}: unexpected answer from the CCU.`);
133910
+ return { removed: answer["removed"] };
133911
+ }
133831
133912
  /** Delete the program by name; `removed: false` when it does not exist. */
133832
133913
  async remove(rawName) {
133833
- const name = validName2(rawName);
133914
+ const name2 = validName2(rawName);
133834
133915
  const label = "ReGa.runScript(removeKeyEventProgram)";
133835
- const answer = record(await this.#rega(label, REMOVE_KEY_EVENT_PROGRAM, { name }), label);
133916
+ const answer = record(await this.#rega(label, REMOVE_KEY_EVENT_PROGRAM, { name: name2 }), label);
133917
+ throwIfDuplicate(answer, name2);
133836
133918
  if (typeof answer["removed"] !== "boolean") throw new ClientError(`${label}: unexpected answer from the CCU.`);
133837
133919
  return { removed: answer["removed"] };
133838
133920
  }
133839
133921
  /** The program and the channels it listens to, or `null` when absent. */
133840
133922
  async get(rawName) {
133841
- const name = validName2(rawName);
133923
+ const name2 = validName2(rawName);
133842
133924
  const label = "ReGa.runScript(getKeyEventProgram)";
133843
- const answer = record(await this.#rega(label, GET_KEY_EVENT_PROGRAM, { name }), label);
133925
+ const answer = record(await this.#rega(label, GET_KEY_EVENT_PROGRAM, { name: name2 }), label);
133926
+ throwIfDuplicate(answer, name2);
133844
133927
  if (answer["found"] !== true) return null;
133845
133928
  const programId = answer["programId"];
133846
133929
  if (typeof programId !== "string" || programId === "") throw new ClientError(`${label}: the CCU did not return the program id.`);
@@ -133857,21 +133940,231 @@ var CcuKeyPrograms = class {
133857
133940
  };
133858
133941
  }
133859
133942
  };
133943
+ var CHANNEL_ADDRESS3 = /^([0-9A-Za-z_-]+):\d+$/;
133944
+ var INTERFACE_NAME = /^[0-9A-Za-z_-]+$/;
133945
+ var KEY_DIAGNOSIS_PARAMETERS = [
133946
+ "PRESS_SHORT",
133947
+ "PRESS_LONG",
133948
+ "PRESS_LONG_RELEASE"
133949
+ ];
133950
+ function keyDatapointName(interfaceName, channelAddress2, parameter) {
133951
+ return `${interfaceName}.${channelAddress2}.${parameter}`;
133952
+ }
133953
+ function checkedInput(interfaceName, channelAddresses) {
133954
+ if (!INTERFACE_NAME.test(interfaceName)) throw new ValidationError(`Invalid interface name "${interfaceName}".`);
133955
+ for (const address of channelAddresses) if (!CHANNEL_ADDRESS3.test(address)) throw new ValidationError(`Invalid channel address "${address}".`);
133956
+ return channelAddresses;
133957
+ }
133958
+ function channelBlock(interfaceName, address, i) {
133959
+ return `Write(sSep);
133960
+ sSep = ",";
133961
+ Write("{\\"address\\":\\"${address}\\",");
133962
+ if (sChId${i} == "") {
133963
+ Write("\\"found\\":false,");
133964
+ } else {
133965
+ object oChn${i} = dom.GetObject(sChId${i});
133966
+ Write("\\"found\\":true,\\"id\\":\\"" # oChn${i}.ID() # "\\",\\"name\\":\\"" # oChn${i}.Name().UriEncode() # "\\",\\"visible\\":\\"" # oChn${i}.Visible() # "\\",\\"enabled\\":\\"" # "" # "\\",\\"readyConfig\\":\\"" # oChn${i}.ReadyConfig() # "\\",\\"lastActionSeconds\\":\\"" # oChn${i}.LastDPActionTimeSeconds() # "\\",");
133967
+ }
133968
+ Write("\\"datapoints\\":[");
133969
+ sDpSep = "";
133970
+ ${KEY_DIAGNOSIS_PARAMETERS.map((parameter) => {
133971
+ const name2 = keyDatapointName(interfaceName, address, parameter);
133972
+ return `oDp = dom.GetObject("${name2}");
133973
+ Write(sDpSep);
133974
+ sDpSep = ",";
133975
+ Write("{\\"name\\":\\"${name2}\\"");
133976
+ if (oDp) {
133977
+ Write(",\\"exists\\":true,\\"id\\":\\"" # oDp.ID() # "\\",\\"value\\":\\"" # ("" # oDp.Value()).UriEncode() # "\\",\\"timestampSeconds\\":\\"" # oDp.TimestampSeconds() # "\\",\\"lastTimestampSeconds\\":\\"" # "" # "\\"}");
133978
+ } else {
133979
+ Write(",\\"exists\\":false}");
133980
+ }`;
133981
+ }).join("\n")}
133982
+ Write("]}");`;
133983
+ }
133984
+ function buildDiagnoseKeyEvents(interfaceName, channelAddresses) {
133985
+ const addresses = checkedInput(interfaceName, channelAddresses);
133986
+ const lookups = addresses.map((_a, i) => `string sChId${i} = "";`).join("\n");
133987
+ const matches = addresses.map((address, i) => `if (oTmp.Address() == "${address}") {
133988
+ sChId${i} = sId;
133989
+ }`).join("\n ");
133990
+ return `! nodehomematic:diagnoseKeyEvents
133991
+ string sId;
133992
+ string sSep = "";
133993
+ string sDpSep = "";
133994
+ string sTargets = "|";
133995
+ object oDp;
133996
+ ${lookups}
133997
+ ${addresses.flatMap((address) => KEY_DIAGNOSIS_PARAMETERS.map((parameter) => `sTargets = sTargets # "${keyDatapointName(interfaceName, address, parameter)}|";`)).join("\n")}
133998
+ foreach(sId, dom.GetObject(ID_CHANNELS).EnumUsedIDs()) {
133999
+ object oTmp = dom.GetObject(sId);
134000
+ if (oTmp) {
134001
+ ${matches}
134002
+ }
134003
+ }
134004
+ Write("{\\"channels\\":[");
134005
+ ${addresses.map((address, i) => channelBlock(interfaceName, address, i)).join("\n")}
134006
+ Write("],\\"programs\\":[");
134007
+ string sPrgId;
134008
+ string sPSep = "";
134009
+ foreach(sPrgId, dom.GetObject(ID_PROGRAMS).EnumUsedIDs()) {
134010
+ object oPrg = dom.GetObject(sPrgId);
134011
+ if (oPrg) {
134012
+ string sRefs = "";
134013
+ string sRSep = "";
134014
+ object oRule = oPrg.Rule();
134015
+ if (oRule) {
134016
+ integer iC = 0;
134017
+ integer iCn = oRule.RuleConditions().Count();
134018
+ while (iC < iCn) {
134019
+ object oCnd = oRule.RuleCondition(iC);
134020
+ if (oCnd) {
134021
+ integer iN = oCnd.CndSingleCount();
134022
+ integer iI = 0;
134023
+ while (iI < iN) {
134024
+ object oSc = oCnd.CndSingleCondition(iI);
134025
+ object oLeft = dom.GetObject(oSc.LeftVal());
134026
+ if (oLeft) {
134027
+ string sLn = oLeft.Name();
134028
+ if (sTargets.Find("|" # sLn # "|") != -1) {
134029
+ sRefs = sRefs # sRSep # "\\"" # sLn # "\\"";
134030
+ sRSep = ",";
134031
+ }
134032
+ }
134033
+ iI = iI + 1;
134034
+ }
134035
+ }
134036
+ iC = iC + 1;
134037
+ }
134038
+ }
134039
+ if (sRefs != "") {
134040
+ Write(sPSep);
134041
+ sPSep = ",";
134042
+ Write("{\\"id\\":\\"" # oPrg.ID() # "\\",\\"name\\":\\"" # oPrg.Name().UriEncode() # "\\",\\"active\\":\\"" # oPrg.Active() # "\\",\\"internal\\":\\"" # "" # "\\",\\"lastExecuteSeconds\\":\\"" # oPrg.ProgramLastExecuteTimeSeconds() # "\\",\\"datapoints\\":[" # sRefs # "]}");
134043
+ }
134044
+ }
134045
+ }
134046
+ Write("]}");`;
134047
+ }
134048
+ function isRecord3(value) {
134049
+ return value !== null && typeof value === "object" && !Array.isArray(value);
134050
+ }
134051
+ function records(value) {
134052
+ return Array.isArray(value) ? value.filter(isRecord3) : [];
134053
+ }
134054
+ function str(entry, key) {
134055
+ const value = entry[key];
134056
+ return typeof value === "string" && value !== "" ? value : null;
134057
+ }
134058
+ function name(entry, key) {
134059
+ const value = str(entry, key);
134060
+ return value === null ? null : decodeRegaName(value);
134061
+ }
134062
+ function bool(entry, key) {
134063
+ const value = str(entry, key);
134064
+ if (value === "true" || value === "1") return true;
134065
+ if (value === "false" || value === "0") return false;
134066
+ return null;
134067
+ }
134068
+ function epochMs(entry, key) {
134069
+ const value = str(entry, key);
134070
+ if (value === null) return null;
134071
+ const seconds = Number(value);
134072
+ return Number.isFinite(seconds) && seconds > 0 ? seconds * 1e3 : null;
134073
+ }
134074
+ function datapoint(entry) {
134075
+ const dpName = str(entry, "name");
134076
+ if (dpName === null) return null;
134077
+ if (entry["exists"] !== true) return {
134078
+ name: dpName,
134079
+ exists: false,
134080
+ id: null,
134081
+ value: null,
134082
+ timestamp: null,
134083
+ lastTimestamp: null
134084
+ };
134085
+ return {
134086
+ name: dpName,
134087
+ exists: true,
134088
+ id: str(entry, "id"),
134089
+ value: name(entry, "value"),
134090
+ timestamp: epochMs(entry, "timestampSeconds"),
134091
+ lastTimestamp: epochMs(entry, "lastTimestampSeconds")
134092
+ };
134093
+ }
134094
+ function channel(entry) {
134095
+ const address = str(entry, "address");
134096
+ if (address === null) return null;
134097
+ const datapoints = records(entry["datapoints"]).flatMap((dp) => {
134098
+ const parsed = datapoint(dp);
134099
+ return parsed === null ? [] : [parsed];
134100
+ });
134101
+ const found = entry["found"] === true;
134102
+ return {
134103
+ address,
134104
+ found,
134105
+ id: found ? str(entry, "id") : null,
134106
+ name: found ? name(entry, "name") : null,
134107
+ visible: found ? bool(entry, "visible") : null,
134108
+ enabled: found ? bool(entry, "enabled") : null,
134109
+ readyConfig: found ? bool(entry, "readyConfig") : null,
134110
+ lastActionAt: found ? epochMs(entry, "lastActionSeconds") : null,
134111
+ datapoints
134112
+ };
134113
+ }
134114
+ function program(entry) {
134115
+ const id = str(entry, "id");
134116
+ if (id === null) return null;
134117
+ const datapoints = Array.isArray(entry["datapoints"]) ? entry["datapoints"].filter((dp) => typeof dp === "string") : [];
134118
+ return {
134119
+ id,
134120
+ name: name(entry, "name") ?? "",
134121
+ active: bool(entry, "active"),
134122
+ internal: bool(entry, "internal"),
134123
+ lastExecutedAt: epochMs(entry, "lastExecuteSeconds"),
134124
+ datapoints
134125
+ };
134126
+ }
134127
+ var CcuKeyDiagnosis = class {
134128
+ #rega;
134129
+ constructor(rega) {
134130
+ this.#rega = rega;
134131
+ }
134132
+ /**
134133
+ * Read the ReGa channel objects, key data points and referencing programs
134134
+ * for `channelAddresses` on `interfaceName` (`HmIP-RF`). Writes nothing.
134135
+ */
134136
+ async read(interfaceName, channelAddresses) {
134137
+ if (channelAddresses.length === 0) throw new ValidationError("The key diagnosis needs at least one channel.");
134138
+ const label = "ReGa.runScript(diagnoseKeyEvents)";
134139
+ const answer = await this.#rega(label, buildDiagnoseKeyEvents(interfaceName, channelAddresses));
134140
+ if (!isRecord3(answer)) throw new ClientError(`${label}: unexpected answer from the CCU.`);
134141
+ return {
134142
+ channels: records(answer["channels"]).flatMap((entry) => {
134143
+ const parsed = channel(entry);
134144
+ return parsed === null ? [] : [parsed];
134145
+ }),
134146
+ programs: records(answer["programs"]).flatMap((entry) => {
134147
+ const parsed = program(entry);
134148
+ return parsed === null ? [] : [parsed];
134149
+ })
134150
+ };
134151
+ }
134152
+ };
133860
134153
  var GROUP_CREATE_PATH = "/pages/jpages/group/create";
133861
134154
  var GROUP_SAVE_PATH = "/pages/jpages/group/save";
133862
134155
  var GROUP_DELETE_PATH = "/pages/jpages/group/delete";
133863
134156
  var DRAFT_GROUP_ID = /self\.groupId\s*=\s*(\d+)/;
133864
134157
  var KNOWN_GROUP_TYPES = ["hmip.heating.group", "HomeMatic.heating"];
133865
- var CHANNEL_ADDRESS3 = /^[0-9A-Za-z_-]+:\d+$/;
134158
+ var CHANNEL_ADDRESS4 = /^[0-9A-Za-z_-]+:\d+$/;
133866
134159
  var MAX_GROUP_NAME = 64;
133867
134160
  var DEFAULT_INSTALL_SECONDS = 60;
133868
134161
  var MAX_INSTALL_SECONDS = 3600;
133869
134162
  var SERVICE_MESSAGE_ID = /^\d+$/;
133870
- function isRecord3(value) {
134163
+ function isRecord4(value) {
133871
134164
  return value !== null && typeof value === "object" && !Array.isArray(value);
133872
134165
  }
133873
134166
  function asRecordArray(value) {
133874
- return Array.isArray(value) ? value.filter(isRecord3) : [];
134167
+ return Array.isArray(value) ? value.filter(isRecord4) : [];
133875
134168
  }
133876
134169
  function strOrNull(value) {
133877
134170
  if (typeof value === "string") return value === "" ? null : value;
@@ -133884,9 +134177,9 @@ function numOrNull(value) {
133884
134177
  return Number.isFinite(num) ? num : null;
133885
134178
  }
133886
134179
  var INTERFACES_BY_NAME = new Map(Object.values(Interface).map((iface) => [iface.toString(), iface]));
133887
- function toInterface(name) {
133888
- const match = INTERFACES_BY_NAME.get(name);
133889
- if (match === void 0) throw new ValidationError(`Unknown interface "${name}".`);
134180
+ function toInterface(name2) {
134181
+ const match = INTERFACES_BY_NAME.get(name2);
134182
+ if (match === void 0) throw new ValidationError(`Unknown interface "${name2}".`);
133890
134183
  return match;
133891
134184
  }
133892
134185
  function toGateway(info) {
@@ -133996,13 +134289,13 @@ var CcuManagement = class {
133996
134289
  const address = strOrNull(entry["address"]);
133997
134290
  const colon = address === null ? -1 : address.lastIndexOf(":");
133998
134291
  const device = address === null ? null : colon === -1 ? address : address.slice(0, colon);
133999
- const channel = address === null || colon === -1 ? null : numOrNull(address.slice(colon + 1));
134292
+ const channel2 = address === null || colon === -1 ? null : numOrNull(address.slice(colon + 1));
134000
134293
  const seconds = numOrNull(entry["timestamp"]);
134001
134294
  return [{
134002
134295
  id,
134003
134296
  name: decodedOrNull(entry["name"]),
134004
134297
  address: device,
134005
- channel,
134298
+ channel: channel2,
134006
134299
  type: strOrNull(entry["type"]),
134007
134300
  timestamp: seconds === null || seconds <= 0 ? null : seconds * 1e3,
134008
134301
  acknowledgeable: entry["acknowledgeable"] === true
@@ -134013,7 +134306,7 @@ var CcuManagement = class {
134013
134306
  async acknowledgeServiceMessage(id) {
134014
134307
  if (!SERVICE_MESSAGE_ID.test(id)) throw new ValidationError(`Invalid service message id "${id}".`);
134015
134308
  const raw = await this.rega("ReGa.runScript(acknowledgeServiceMessage)", ACKNOWLEDGE_SERVICE_MESSAGE, { id });
134016
- if (!isRecord3(raw) || raw["ok"] !== true) throw new ValidationError(`Unknown service message "${id}".`);
134309
+ if (!isRecord4(raw) || raw["ok"] !== true) throw new ValidationError(`Unknown service message "${id}".`);
134017
134310
  }
134018
134311
  /** Version, product, serial and hostname; each `null` when unanswered. */
134019
134312
  async ccuInfo() {
@@ -134023,8 +134316,8 @@ var CcuManagement = class {
134023
134316
  this.rega("ReGa.runScript(ccuPlatform)", GET_CCU_PLATFORM)
134024
134317
  ]);
134025
134318
  if (version.status === "rejected" && serial.status === "rejected" && platform.status === "rejected") throw version.reason instanceof CcuManagementError ? version.reason : new CcuManagementError(JsonRpcMethod.CCU_GET_VERSION, version.reason);
134026
- const release = platform.status === "fulfilled" && isRecord3(platform.value) ? parseKeyValueLines(decodeRegaName(releaseText(platform.value))) : /* @__PURE__ */ new Map();
134027
- const hostname = platform.status === "fulfilled" && isRecord3(platform.value) ? decodedOrNull(platform.value["host"]) : null;
134319
+ const release = platform.status === "fulfilled" && isRecord4(platform.value) ? parseKeyValueLines(decodeRegaName(releaseText(platform.value))) : /* @__PURE__ */ new Map();
134320
+ const hostname = platform.status === "fulfilled" && isRecord4(platform.value) ? decodedOrNull(platform.value["host"]) : null;
134028
134321
  const product = strOrNull(release.get("PRODUCT"));
134029
134322
  return {
134030
134323
  version: version.status === "fulfilled" ? strOrNull(version.value) : null,
@@ -134050,7 +134343,7 @@ var CcuManagement = class {
134050
134343
  } catch (err) {
134051
134344
  throw new CcuManagementError(JsonRpcMethod.CCU_GET_HEATING_GROUP_LIST, err);
134052
134345
  }
134053
- if (!isRecord3(parsed)) return [];
134346
+ if (!isRecord4(parsed)) return [];
134054
134347
  return Object.keys(parsed).sort().flatMap((key) => asRecordArray(parsed[key])).flatMap((entry) => {
134055
134348
  const group = toGroup(entry);
134056
134349
  return group === null ? [] : [group];
@@ -134058,7 +134351,7 @@ var CcuManagement = class {
134058
134351
  }
134059
134352
  /** Create a group; resolves with the group as read back from the CCU. */
134060
134353
  async createGroup(input) {
134061
- const name = validateGroupName(input.name);
134354
+ const name2 = validateGroupName(input.name);
134062
134355
  const members = validateMembers(input.members);
134063
134356
  const before = await this.groups();
134064
134357
  this.validateType(input.type, before);
@@ -134069,16 +134362,16 @@ var CcuManagement = class {
134069
134362
  const draftId = Number(draft[1]);
134070
134363
  const id = numOrNull(await this.saveGroup(webUi, sid, {
134071
134364
  groupId: draftId,
134072
- groupName: jsEscape(name),
134365
+ groupName: jsEscape(name2),
134073
134366
  groupTypeId: input.type,
134074
134367
  forbidSingleOperation: false,
134075
134368
  assignedDevicesIds: members,
134076
134369
  isNewGroup: true,
134077
- groupDeviceName: `${name} `
134370
+ groupDeviceName: `${name2} `
134078
134371
  })) ?? draftId;
134079
134372
  await this.flagMembers(members, "true");
134080
134373
  return this.verifyPresent(id, {
134081
- name,
134374
+ name: name2,
134082
134375
  type: input.type,
134083
134376
  members
134084
134377
  });
@@ -134086,11 +134379,11 @@ var CcuManagement = class {
134086
134379
  /** Change a group's name and/or member list; resolves with the group read back. */
134087
134380
  async updateGroup(id, patch) {
134088
134381
  if (patch.name === void 0 && patch.members === void 0) throw new ValidationError("updateGroup needs a name and/or members.");
134089
- const name = patch.name === void 0 ? void 0 : validateGroupName(patch.name);
134382
+ const name2 = patch.name === void 0 ? void 0 : validateGroupName(patch.name);
134090
134383
  const members = patch.members === void 0 ? void 0 : validateMembers(patch.members);
134091
134384
  const current = await this.requireGroup(id);
134092
134385
  const { webUi, sid } = await this.requireWebUi("group/save");
134093
- const nextName = name ?? current.name;
134386
+ const nextName = name2 ?? current.name;
134094
134387
  const nextMembers = members ?? current.members.map((m) => m.address);
134095
134388
  await this.saveGroup(webUi, sid, {
134096
134389
  groupId: id,
@@ -134176,6 +134469,10 @@ var CcuManagement = class {
134176
134469
  keyPrograms() {
134177
134470
  return new CcuKeyPrograms((label, script, params) => this.rega(label, script, params));
134178
134471
  }
134472
+ /** The read-only key diagnosis (ReGa side), on this service's session. */
134473
+ keyDiagnosis() {
134474
+ return new CcuKeyDiagnosis((label, script, params) => this.rega(label, script, params));
134475
+ }
134179
134476
  requireClient(interfaceName) {
134180
134477
  const iface = toInterface(interfaceName);
134181
134478
  const client = this.interfaceClient(iface);
@@ -134218,17 +134515,17 @@ var CcuManagement = class {
134218
134515
  info: null
134219
134516
  }));
134220
134517
  return asRecordArray(await this.call(JsonRpcMethod.INTERFACE_LIST_INTERFACES)).flatMap((entry) => {
134221
- const name = strOrNull(entry["name"]);
134222
- return name === null ? [] : [{
134223
- name,
134518
+ const name2 = strOrNull(entry["name"]);
134519
+ return name2 === null ? [] : [{
134520
+ name: name2,
134224
134521
  port: numOrNull(entry["port"]),
134225
134522
  info: strOrNull(entry["info"])
134226
134523
  }];
134227
134524
  });
134228
134525
  }
134229
- async isPresent(name) {
134526
+ async isPresent(name2) {
134230
134527
  if (this.json === void 0) return null;
134231
- const answer = await this.tryOrNull(() => this.call(JsonRpcMethod.INTERFACE_IS_PRESENT, { interface: name }));
134528
+ const answer = await this.tryOrNull(() => this.call(JsonRpcMethod.INTERFACE_IS_PRESENT, { interface: name2 }));
134232
134529
  if (typeof answer === "boolean") return answer;
134233
134530
  if (answer === "true") return true;
134234
134531
  if (answer === "false") return false;
@@ -134254,8 +134551,8 @@ var DEVICE_ADDRESS_SUFFIX = /\b(INT\d{7})\s*$/;
134254
134551
  function toGroup(entry) {
134255
134552
  const id = numOrNull(entry["id"]);
134256
134553
  if (id === null) return null;
134257
- const props = isRecord3(entry["groupProperties"]) ? entry["groupProperties"] : {};
134258
- const groupType = isRecord3(entry["groupType"]) ? entry["groupType"] : {};
134554
+ const props = isRecord4(entry["groupProperties"]) ? entry["groupProperties"] : {};
134555
+ const groupType = isRecord4(entry["groupType"]) ? entry["groupType"] : {};
134259
134556
  const deviceName = strOrNull(props["GROUP_DEVICE_NAME"]);
134260
134557
  const deviceMatch = deviceName === null ? null : DEVICE_ADDRESS_SUFFIX.exec(deviceName);
134261
134558
  const members = asRecordArray(entry["groupMembers"]).flatMap((m) => {
@@ -134263,7 +134560,7 @@ function toGroup(entry) {
134263
134560
  if (address === null) return [];
134264
134561
  return [{
134265
134562
  address,
134266
- type: (isRecord3(m["memberType"]) ? strOrNull(m["memberType"]["id"]) : null) ?? ""
134563
+ type: (isRecord4(m["memberType"]) ? strOrNull(m["memberType"]["id"]) : null) ?? ""
134267
134564
  }];
134268
134565
  });
134269
134566
  return {
@@ -134280,12 +134577,12 @@ function virtualDeviceSerial(id) {
134280
134577
  return `INT${String(id).padStart(7, "0")}`;
134281
134578
  }
134282
134579
  function validateGroupName(raw) {
134283
- const name = raw.replace(/"/g, "'").trim();
134284
- if (name === "" || name.length > MAX_GROUP_NAME) throw new ValidationError(`Group name must be 1..${MAX_GROUP_NAME} characters.`);
134285
- return name;
134580
+ const name2 = raw.replace(/"/g, "'").trim();
134581
+ if (name2 === "" || name2.length > MAX_GROUP_NAME) throw new ValidationError(`Group name must be 1..${MAX_GROUP_NAME} characters.`);
134582
+ return name2;
134286
134583
  }
134287
134584
  function validateMembers(members) {
134288
- for (const address of members) if (!CHANNEL_ADDRESS3.test(address)) throw new ValidationError(`Invalid member channel address "${address}".`);
134585
+ for (const address of members) if (!CHANNEL_ADDRESS4.test(address)) throw new ValidationError(`Invalid member channel address "${address}".`);
134289
134586
  return [...new Set(members)];
134290
134587
  }
134291
134588
  function checkWebUiResponse(path$5, text) {
@@ -134295,8 +134592,8 @@ function checkWebUiResponse(path$5, text) {
134295
134592
  } catch {
134296
134593
  throw new CcuManagementError(path$5, new ClientError("response was not JSON"));
134297
134594
  }
134298
- if (!isRecord3(parsed) || parsed["isSuccessful"] !== true) {
134299
- const code = isRecord3(parsed) ? strOrNull(parsed["errorCode"]) : null;
134595
+ if (!isRecord4(parsed) || parsed["isSuccessful"] !== true) {
134596
+ const code = isRecord4(parsed) ? strOrNull(parsed["errorCode"]) : null;
134300
134597
  throw new CcuManagementError(path$5, new ClientError(code === "42" ? "session expired (errorCode 42)" : `refused (errorCode ${code ?? "none"})`));
134301
134598
  }
134302
134599
  const content = parsed["content"];
@@ -134306,33 +134603,33 @@ var FAULT_METHOD_NOT_FOUND = -32601;
134306
134603
  var FAULT_INTERNAL_ERROR = -32603;
134307
134604
  var MethodNotFoundError = class extends BaseHomematicError {};
134308
134605
  var InvalidParamsError = class extends BaseHomematicError {};
134309
- function requireString(params, index, name) {
134606
+ function requireString(params, index, name2) {
134310
134607
  const value = params[index];
134311
- if (typeof value !== "string") throw new InvalidParamsError(`expected string argument "${name}" at position ${index}`);
134608
+ if (typeof value !== "string") throw new InvalidParamsError(`expected string argument "${name2}" at position ${index}`);
134312
134609
  return value;
134313
134610
  }
134314
- function requireNumber(params, index, name) {
134611
+ function requireNumber(params, index, name2) {
134315
134612
  const value = params[index];
134316
- if (typeof value !== "number" || Number.isNaN(value)) throw new InvalidParamsError(`expected number argument "${name}" at position ${index}`);
134613
+ if (typeof value !== "number" || Number.isNaN(value)) throw new InvalidParamsError(`expected number argument "${name2}" at position ${index}`);
134317
134614
  return value;
134318
134615
  }
134319
- function requireArg(params, index, name) {
134320
- if (index >= params.length) throw new InvalidParamsError(`missing required argument "${name}" at position ${index}`);
134616
+ function requireArg(params, index, name2) {
134617
+ if (index >= params.length) throw new InvalidParamsError(`missing required argument "${name2}" at position ${index}`);
134321
134618
  return params[index];
134322
134619
  }
134323
- function requireStringArray(params, index, name) {
134324
- const value = requireArg(params, index, name);
134325
- if (!Array.isArray(value)) throw new InvalidParamsError(`expected array argument "${name}" at position ${index}`);
134620
+ function requireStringArray(params, index, name2) {
134621
+ const value = requireArg(params, index, name2);
134622
+ if (!Array.isArray(value)) throw new InvalidParamsError(`expected array argument "${name2}" at position ${index}`);
134326
134623
  return value.map((item, i) => {
134327
- if (typeof item !== "string") throw new InvalidParamsError(`expected string at "${name}"[${i}]`);
134624
+ if (typeof item !== "string") throw new InvalidParamsError(`expected string at "${name2}"[${i}]`);
134328
134625
  return item;
134329
134626
  });
134330
134627
  }
134331
- function requireStructArray(params, index, name) {
134332
- const value = requireArg(params, index, name);
134333
- if (!Array.isArray(value)) throw new InvalidParamsError(`expected array argument "${name}" at position ${index}`);
134628
+ function requireStructArray(params, index, name2) {
134629
+ const value = requireArg(params, index, name2);
134630
+ if (!Array.isArray(value)) throw new InvalidParamsError(`expected array argument "${name2}" at position ${index}`);
134334
134631
  return value.map((item, i) => {
134335
- if (typeof item !== "object" || item === null || Array.isArray(item)) throw new InvalidParamsError(`expected struct at "${name}"[${i}]`);
134632
+ if (typeof item !== "object" || item === null || Array.isArray(item)) throw new InvalidParamsError(`expected struct at "${name2}"[${i}]`);
134336
134633
  return item;
134337
134634
  });
134338
134635
  }
@@ -134652,7 +134949,7 @@ var DeviceRegistry = class {
134652
134949
  const deviceAddress = channelAddress2.slice(0, lastColon);
134653
134950
  const device = this.devices.get(deviceAddress);
134654
134951
  if (device === void 0) return void 0;
134655
- return device.channels.find((channel) => channel.address === channelAddress2);
134952
+ return device.channels.find((channel2) => channel2.address === channelAddress2);
134656
134953
  }
134657
134954
  /**
134658
134955
  * Resolve the {@link ParameterSpec} addressed by a dpk: device → channel
@@ -134660,9 +134957,9 @@ var DeviceRegistry = class {
134660
134957
  * `dpk.paramsetKey`. Returns `undefined` if any hop is missing.
134661
134958
  */
134662
134959
  resolveParameter(dpk) {
134663
- const channel = this.getChannel(dpk.channelAddress);
134664
- if (channel === void 0) return void 0;
134665
- const specs = channel.parameters.get(dpk.parameter);
134960
+ const channel2 = this.getChannel(dpk.channelAddress);
134961
+ if (channel2 === void 0) return void 0;
134962
+ const specs = channel2.parameters.get(dpk.parameter);
134666
134963
  if (specs === void 0) return void 0;
134667
134964
  if (dpk.paramsetKey === "VALUES") return specs.VALUES;
134668
134965
  if (dpk.paramsetKey === "MASTER") return specs.MASTER;
@@ -134939,23 +135236,23 @@ var FileStorageBackend = class {
134939
135236
  this.dir = options.dir;
134940
135237
  this.prefix = slug(options.centralName);
134941
135238
  }
134942
- fileFor(name) {
134943
- return (0, path.join)(this.dir, `${this.prefix}_${name}.json`);
135239
+ fileFor(name2) {
135240
+ return (0, path.join)(this.dir, `${this.prefix}_${name2}.json`);
134944
135241
  }
134945
- async load(name) {
135242
+ async load(name2) {
134946
135243
  try {
134947
- return await (0, fs_promises.readFile)(this.fileFor(name), "utf-8");
135244
+ return await (0, fs_promises.readFile)(this.fileFor(name2), "utf-8");
134948
135245
  } catch (err) {
134949
135246
  if (isNotFound(err)) return null;
134950
135247
  throw err;
134951
135248
  }
134952
135249
  }
134953
- async save(name, content) {
135250
+ async save(name2, content) {
134954
135251
  await (0, fs_promises.mkdir)(this.dir, { recursive: true });
134955
- await (0, fs_promises.writeFile)(this.fileFor(name), content, "utf-8");
135252
+ await (0, fs_promises.writeFile)(this.fileFor(name2), content, "utf-8");
134956
135253
  }
134957
- async remove(name) {
134958
- await (0, fs_promises.rm)(this.fileFor(name), { force: true });
135254
+ async remove(name2) {
135255
+ await (0, fs_promises.rm)(this.fileFor(name2), { force: true });
134959
135256
  }
134960
135257
  };
134961
135258
  function isNotFound(err) {
@@ -134963,15 +135260,15 @@ function isNotFound(err) {
134963
135260
  }
134964
135261
  var InMemoryStorageBackend = class {
134965
135262
  store = /* @__PURE__ */ new Map();
134966
- load(name) {
134967
- return Promise.resolve(this.store.get(name) ?? null);
135263
+ load(name2) {
135264
+ return Promise.resolve(this.store.get(name2) ?? null);
134968
135265
  }
134969
- save(name, content) {
134970
- this.store.set(name, content);
135266
+ save(name2, content) {
135267
+ this.store.set(name2, content);
134971
135268
  return Promise.resolve();
134972
135269
  }
134973
- remove(name) {
134974
- this.store.delete(name);
135270
+ remove(name2) {
135271
+ this.store.delete(name2);
134975
135272
  return Promise.resolve();
134976
135273
  }
134977
135274
  };
@@ -135082,14 +135379,14 @@ function buildChannel(interfaceId2, channelAddress2, desc, paramsetCache, detail
135082
135379
  if (paramset === void 0) continue;
135083
135380
  for (const [parameter, data] of Object.entries(paramset)) mergeSpec(parameters, parameter, key, parameterSpecFromData(data));
135084
135381
  }
135085
- const name = details?.nameByAddress.get(channelAddress2);
135382
+ const name2 = details?.nameByAddress.get(channelAddress2);
135086
135383
  return {
135087
135384
  address: channelAddress2,
135088
135385
  index: channelIndexOf(channelAddress2),
135089
135386
  parameters,
135090
135387
  ...desc?.TYPE !== void 0 ? { type: desc.TYPE } : {},
135091
135388
  ...desc?.DIRECTION !== void 0 ? { direction: desc.DIRECTION } : {},
135092
- ...name !== void 0 ? { name } : {}
135389
+ ...name2 !== void 0 ? { name: name2 } : {}
135093
135390
  };
135094
135391
  }
135095
135392
  function mergeSpec(parameters, parameter, key, spec) {
@@ -135105,7 +135402,7 @@ function mergeSpec(parameters, parameter, key, spec) {
135105
135402
  }
135106
135403
  function buildDevice(interfaceId2, device, channels, details) {
135107
135404
  const address = device.ADDRESS;
135108
- const name = details?.nameByAddress.get(address);
135405
+ const name2 = details?.nameByAddress.get(address);
135109
135406
  const rooms = details?.roomsByAddress.get(address);
135110
135407
  const functions = details?.functionsByAddress.get(address);
135111
135408
  const updatable = device.UPDATABLE ?? device.FIRMWARE_UPDATABLE;
@@ -135119,7 +135416,7 @@ function buildDevice(interfaceId2, device, channels, details) {
135119
135416
  ...device.AVAILABLE_FIRMWARE !== void 0 ? { availableFirmware: device.AVAILABLE_FIRMWARE } : {},
135120
135417
  ...updatable !== void 0 ? { updatable } : {},
135121
135418
  ...device.FIRMWARE_UPDATE_STATE !== void 0 ? { firmwareUpdateState: device.FIRMWARE_UPDATE_STATE } : {},
135122
- ...name !== void 0 ? { name } : {},
135419
+ ...name2 !== void 0 ? { name: name2 } : {},
135123
135420
  ...rooms !== void 0 && rooms.length > 0 ? { rooms } : {},
135124
135421
  ...functions !== void 0 && functions.length > 0 ? { functions } : {}
135125
135422
  };
@@ -135153,10 +135450,10 @@ function parseDeviceDetail(item, nameByAddress, channelIdToAddress) {
135153
135450
  const record2 = asRecord(item);
135154
135451
  if (record2 === void 0) return;
135155
135452
  const address = asString(record2.address);
135156
- const name = asString(record2.name);
135157
- if (address !== void 0 && name !== void 0) nameByAddress.set(address, name);
135158
- for (const channel of asArray(record2.channels)) {
135159
- const ch = asRecord(channel);
135453
+ const name2 = asString(record2.name);
135454
+ if (address !== void 0 && name2 !== void 0) nameByAddress.set(address, name2);
135455
+ for (const channel2 of asArray(record2.channels)) {
135456
+ const ch = asRecord(channel2);
135160
135457
  if (ch === void 0) continue;
135161
135458
  const chAddress = asString(ch.address);
135162
135459
  if (chAddress === void 0) continue;
@@ -135170,31 +135467,31 @@ function deviceAddressOf(channelAddress2) {
135170
135467
  const colon = channelAddress2.lastIndexOf(":");
135171
135468
  return colon === -1 ? channelAddress2 : channelAddress2.slice(0, colon);
135172
135469
  }
135173
- function addGroupName(into, address, name) {
135470
+ function addGroupName(into, address, name2) {
135174
135471
  const existing = into.get(address);
135175
- if (existing === void 0) into.set(address, [name]);
135176
- else if (!existing.includes(name)) existing.push(name);
135472
+ if (existing === void 0) into.set(address, [name2]);
135473
+ else if (!existing.includes(name2)) existing.push(name2);
135177
135474
  }
135178
135475
  function parseGroup(item, channelIdToAddress, into) {
135179
135476
  const record2 = asRecord(item);
135180
135477
  if (record2 === void 0) return;
135181
- const name = asString(record2.name);
135182
- if (name === void 0) return;
135478
+ const name2 = asString(record2.name);
135479
+ if (name2 === void 0) return;
135183
135480
  const idMembers = asArray(record2.channelIds);
135184
135481
  for (const member of idMembers) {
135185
135482
  const channelId = asString(member);
135186
135483
  if (channelId === void 0) continue;
135187
135484
  const channelAddress2 = channelIdToAddress.get(channelId);
135188
135485
  if (channelAddress2 === void 0) continue;
135189
- addGroupName(into, channelAddress2, name);
135190
- addGroupName(into, deviceAddressOf(channelAddress2), name);
135486
+ addGroupName(into, channelAddress2, name2);
135487
+ addGroupName(into, deviceAddressOf(channelAddress2), name2);
135191
135488
  }
135192
135489
  const addressMembers = firstArray(record2.channelAddresses, record2.members);
135193
135490
  for (const member of addressMembers) {
135194
135491
  const channelAddress2 = asString(member);
135195
135492
  if (channelAddress2 === void 0) continue;
135196
- addGroupName(into, channelAddress2, name);
135197
- addGroupName(into, deviceAddressOf(channelAddress2), name);
135493
+ addGroupName(into, channelAddress2, name2);
135494
+ addGroupName(into, deviceAddressOf(channelAddress2), name2);
135198
135495
  }
135199
135496
  }
135200
135497
  function asArray(value) {
@@ -135249,7 +135546,7 @@ function parseSysVarValue(type, raw) {
135249
135546
  }
135250
135547
  }
135251
135548
  var WRITABLE_MARKER = "HAHM";
135252
- function isRecord4(value) {
135549
+ function isRecord5(value) {
135253
135550
  return value !== null && typeof value === "object";
135254
135551
  }
135255
135552
  function asString2(value) {
@@ -135270,7 +135567,7 @@ function asOptionalNumber(value) {
135270
135567
  }
135271
135568
  function asRecordArray2(value) {
135272
135569
  if (!Array.isArray(value)) return [];
135273
- return value.filter(isRecord4);
135570
+ return value.filter(isRecord5);
135274
135571
  }
135275
135572
  var HubFetcher = class {
135276
135573
  client;
@@ -135294,9 +135591,9 @@ var HubFetcher = class {
135294
135591
  return entries.map((entry) => this.toSystemVariable(entry, descriptions));
135295
135592
  }
135296
135593
  /** Read a single system variable's raw value by name. */
135297
- async getSystemVariable(name) {
135594
+ async getSystemVariable(name2) {
135298
135595
  const sid = this.sid();
135299
- const raw = await this.client.post(JsonRpcMethod.SYSVAR_GET_VALUE_BY_NAME, { name }, sidOpts(sid));
135596
+ const raw = await this.client.post(JsonRpcMethod.SYSVAR_GET_VALUE_BY_NAME, { name: name2 }, sidOpts(sid));
135300
135597
  if (typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean") return raw;
135301
135598
  if (raw === null || raw === void 0) return null;
135302
135599
  return asString2(raw);
@@ -135306,25 +135603,25 @@ var HubFetcher = class {
135306
135603
  * `SysVar.setBool` (1/0), number → `SysVar.setFloat`, string → ReGa
135307
135604
  * `SET_SYSTEM_VARIABLE`. A null value is rejected.
135308
135605
  */
135309
- async setSystemVariable(name, value) {
135606
+ async setSystemVariable(name2, value) {
135310
135607
  const sid = this.sid();
135311
- if (value === null) throw new ValidationError(`Cannot set system variable "${name}" to null`);
135608
+ if (value === null) throw new ValidationError(`Cannot set system variable "${name2}" to null`);
135312
135609
  if (typeof value === "boolean") {
135313
135610
  await this.client.post(JsonRpcMethod.SYSVAR_SET_BOOL, {
135314
- name,
135611
+ name: name2,
135315
135612
  value: value ? 1 : 0
135316
135613
  }, sidOpts(sid));
135317
135614
  return;
135318
135615
  }
135319
135616
  if (typeof value === "number") {
135320
135617
  await this.client.post(JsonRpcMethod.SYSVAR_SET_FLOAT, {
135321
- name,
135618
+ name: name2,
135322
135619
  value
135323
135620
  }, sidOpts(sid));
135324
135621
  return;
135325
135622
  }
135326
135623
  await runScript(this.client, sid, SET_SYSTEM_VARIABLE, {
135327
- name,
135624
+ name: name2,
135328
135625
  value
135329
135626
  });
135330
135627
  }
@@ -135363,8 +135660,8 @@ var HubFetcher = class {
135363
135660
  const sid = this.sid();
135364
135661
  const parsed = await runScript(this.client, sid, GET_ROOMS_FUNCTIONS);
135365
135662
  return {
135366
- rooms: toDecodedMap(isRecord4(parsed) ? parsed.rooms : void 0),
135367
- functions: toDecodedMap(isRecord4(parsed) ? parsed.functions : void 0)
135663
+ rooms: toDecodedMap(isRecord5(parsed) ? parsed.rooms : void 0),
135664
+ functions: toDecodedMap(isRecord5(parsed) ? parsed.functions : void 0)
135368
135665
  };
135369
135666
  }
135370
135667
  /** Build the `SYSVAR_DESCRIPTIONS` map: sysvar id → description text. */
@@ -135410,7 +135707,7 @@ function sidOpts(sid) {
135410
135707
  }
135411
135708
  function toDecodedMap(value) {
135412
135709
  const map = /* @__PURE__ */ new Map();
135413
- if (!isRecord4(value)) return map;
135710
+ if (!isRecord5(value)) return map;
135414
135711
  for (const [addr, names] of Object.entries(value)) if (Array.isArray(names)) map.set(addr, names.filter((n) => typeof n === "string").map((n) => decodeRegaName(n)));
135415
135712
  return map;
135416
135713
  }
@@ -135470,6 +135767,10 @@ var ConnectionStateTracker = class {
135470
135767
  recordEvent(interfaceId2, at = this.now()) {
135471
135768
  this.lastEventAt.set(interfaceId2, at);
135472
135769
  }
135770
+ /** Time of the latest inbound event recorded for an interface, or `undefined`. */
135771
+ getLastEventAt(interfaceId2) {
135772
+ return this.lastEventAt.get(interfaceId2);
135773
+ }
135473
135774
  /**
135474
135775
  * True if the callback channel is considered alive: either no event has been
135475
135776
  * recorded yet (we have no evidence of silence) or the elapsed time since the
@@ -135742,8 +136043,8 @@ var Scheduler = class {
135742
136043
  this.timers.clear();
135743
136044
  }
135744
136045
  /** Suspend every job except the named one (keeps it running unchanged). */
135745
- pauseAllExcept(name) {
135746
- for (const [jobName, timer] of this.timers) if (jobName !== name) {
136046
+ pauseAllExcept(name2) {
136047
+ for (const [jobName, timer] of this.timers) if (jobName !== name2) {
135747
136048
  clearInterval(timer);
135748
136049
  this.timers.delete(jobName);
135749
136050
  }
@@ -135846,7 +136147,8 @@ var CallbackRouter = class {
135846
136147
  type: "valueReceived",
135847
136148
  dpk,
135848
136149
  value,
135849
- receivedAt
136150
+ receivedAt,
136151
+ origin: "event"
135850
136152
  });
135851
136153
  }
135852
136154
  async routeNewDevices(interfaceId2, descriptions) {
@@ -136060,6 +136362,20 @@ var CentralUnit = class {
136060
136362
  async installFirmware(interfaceId2, deviceAddress) {
136061
136363
  await this.clientFor(interfaceId2).installFirmware(deviceAddress);
136062
136364
  }
136365
+ /**
136366
+ * What the connection tracker knows about one interface: its state, the time
136367
+ * of the latest inbound event of ANY kind (`ConnectionStateTracker.recordEvent`,
136368
+ * called by the callback router for every event), and whether the callback
136369
+ * channel is considered alive (`isCallbackAlive`: true until the silence
136370
+ * exceeds the warn interval, or before the first event). Read only.
136371
+ */
136372
+ getConnectionInfo(interfaceId2) {
136373
+ return {
136374
+ state: this.connectionState.getState(interfaceId2),
136375
+ lastEventAt: this.connectionState.getLastEventAt(interfaceId2) ?? null,
136376
+ callbackAlive: this.connectionState.isCallbackAlive(interfaceId2)
136377
+ };
136378
+ }
136063
136379
  /** XML-RPC `getLinks(channelAddress, flags)`, routed by interface id. */
136064
136380
  async getLinks(interfaceId2, channelAddress2, flags) {
136065
136381
  return this.clientFor(interfaceId2).getLinks(channelAddress2, flags);
@@ -136076,8 +136392,8 @@ var CentralUnit = class {
136076
136392
  return this.clientFor(interfaceId2).reportValueUsage(channelAddress2, valueId, refCounter);
136077
136393
  }
136078
136394
  /** XML-RPC `addLink(sender, receiver, name, description)`, routed by interface id. */
136079
- async addLink(interfaceId2, sender, receiver, name, description) {
136080
- await this.clientFor(interfaceId2).addLink(sender, receiver, name, description);
136395
+ async addLink(interfaceId2, sender, receiver, name2, description) {
136396
+ await this.clientFor(interfaceId2).addLink(sender, receiver, name2, description);
136081
136397
  }
136082
136398
  /** XML-RPC `removeLink(sender, receiver)`, routed by interface id. */
136083
136399
  async removeLink(interfaceId2, sender, receiver) {
@@ -136302,17 +136618,17 @@ var CentralUnit = class {
136302
136618
  const tasks = [];
136303
136619
  for (const runtime of this.runtimes.values()) for (const node of this.registryStore.getAll()) {
136304
136620
  if (node.interfaceId !== runtime.interfaceId) continue;
136305
- for (const channel of node.channels) {
136306
- if (!this.channelHasValuesParams(channel)) continue;
136307
- tasks.push(() => this.seedChannel(runtime, channel.address));
136621
+ for (const channel2 of node.channels) {
136622
+ if (!this.channelHasValuesParams(channel2)) continue;
136623
+ tasks.push(() => this.seedChannel(runtime, channel2.address));
136308
136624
  }
136309
136625
  }
136310
136626
  const seeded = await runBounded(tasks, SEED_CONCURRENCY);
136311
136627
  if (seeded > 0) this.logger.debug(`seeded ${seeded} initial value(s) from VALUES paramsets`);
136312
136628
  }
136313
136629
  /** True if the channel advertises at least one VALUES parameter. */
136314
- channelHasValuesParams(channel) {
136315
- for (const [, specs] of channel.parameters) if (specs.VALUES !== void 0) return true;
136630
+ channelHasValuesParams(channel2) {
136631
+ for (const [, specs] of channel2.parameters) if (specs.VALUES !== void 0) return true;
136316
136632
  return false;
136317
136633
  }
136318
136634
  /**
@@ -136332,7 +136648,8 @@ var CentralUnit = class {
136332
136648
  type: "valueReceived",
136333
136649
  dpk,
136334
136650
  value: rawValue,
136335
- receivedAt
136651
+ receivedAt,
136652
+ origin: "seed"
136336
136653
  });
136337
136654
  count += 1;
136338
136655
  }
@@ -136490,13 +136807,13 @@ var CentralUnit = class {
136490
136807
  if (runtime === void 0) return;
136491
136808
  for (const node of this.registryStore.getAll()) {
136492
136809
  if (node.interfaceId !== interfaceId2) continue;
136493
- for (const channel of node.channels) {
136494
- const valuesParams = channel.parameters;
136810
+ for (const channel2 of node.channels) {
136811
+ const valuesParams = channel2.parameters;
136495
136812
  for (const [parameter, specs] of valuesParams) {
136496
136813
  if (specs.VALUES === void 0 || !specs.VALUES.readable) continue;
136497
136814
  try {
136498
- const value = await runtime.client.getValue(channel.address, parameter);
136499
- const dpk = makeDpkValues(interfaceId2, channel.address, parameter);
136815
+ const value = await runtime.client.getValue(channel2.address, parameter);
136816
+ const dpk = makeDpkValues(interfaceId2, channel2.address, parameter);
136500
136817
  this.valueCache.add(dpk, value, this.now());
136501
136818
  } catch {}
136502
136819
  }
@@ -136791,22 +137108,22 @@ var ModelDevice = class {
136791
137108
  function interfaceFamilyOf(interfaceId2) {
136792
137109
  return interfaceId2.toLowerCase().includes("hmip") ? "HMIP" : "HM";
136793
137110
  }
136794
- function buildChannel2(channel, interfaceId2, family) {
137111
+ function buildChannel2(channel2, interfaceId2, family) {
136795
137112
  const dataPoints = [];
136796
- for (const [parameter, specs] of channel.parameters) {
137113
+ for (const [parameter, specs] of channel2.parameters) {
136797
137114
  const spec = specs.VALUES;
136798
137115
  if (spec === void 0 || !spec.readable && !spec.hasEvents && !spec.writable) continue;
136799
137116
  dataPoints.push(new GenericDataPoint({
136800
- dpk: makeDpk(interfaceId2, channel.address, "VALUES", parameter),
137117
+ dpk: makeDpk(interfaceId2, channel2.address, "VALUES", parameter),
136801
137118
  spec,
136802
137119
  interfaceFamily: family
136803
137120
  }));
136804
137121
  }
136805
137122
  return new ModelChannel({
136806
- address: channel.address,
136807
- index: channel.index,
136808
- ...channel.type !== void 0 ? { type: channel.type } : {},
136809
- ...channel.name !== void 0 ? { name: channel.name } : {},
137123
+ address: channel2.address,
137124
+ index: channel2.index,
137125
+ ...channel2.type !== void 0 ? { type: channel2.type } : {},
137126
+ ...channel2.name !== void 0 ? { name: channel2.name } : {},
136810
137127
  dataPoints
136811
137128
  });
136812
137129
  }
@@ -136850,11 +137167,11 @@ function parseChannelLinks(value) {
136850
137167
  const sender = structString(entry, "SENDER");
136851
137168
  const receiver = structString(entry, "RECEIVER");
136852
137169
  if (sender === void 0 || receiver === void 0) continue;
136853
- const name = entry.NAME;
137170
+ const name2 = entry.NAME;
136854
137171
  links.push({
136855
137172
  sender,
136856
137173
  receiver,
136857
- name: typeof name === "string" ? name : ""
137174
+ name: typeof name2 === "string" ? name2 : ""
136858
137175
  });
136859
137176
  }
136860
137177
  return links;
@@ -136864,6 +137181,138 @@ function metadataHasCentralLink(value) {
136864
137181
  const counter = value[REPORT_VALUE_USAGE_VALUE_ID];
136865
137182
  return typeof counter === "number" && counter > 0;
136866
137183
  }
137184
+ var KEY_CHANNEL_TYPES = /* @__PURE__ */ new Set([
137185
+ "KEY_TRANSCEIVER",
137186
+ "KEY",
137187
+ "VIRTUAL_KEY"
137188
+ ]);
137189
+ function messageOf(err) {
137190
+ return err instanceof Error ? err.message : String(err);
137191
+ }
137192
+ async function section(read) {
137193
+ try {
137194
+ return {
137195
+ ok: true,
137196
+ data: await read()
137197
+ };
137198
+ } catch (err) {
137199
+ return {
137200
+ ok: false,
137201
+ error: messageOf(err)
137202
+ };
137203
+ }
137204
+ }
137205
+ function pressShortCount(metadata) {
137206
+ if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata) || metadata instanceof Date || metadata instanceof Uint8Array) return null;
137207
+ const counter = metadata["PRESS_SHORT"];
137208
+ return typeof counter === "number" ? counter : null;
137209
+ }
137210
+ function isKeyChannel(source, device, channel2) {
137211
+ if (channel2.type !== void 0 && KEY_CHANNEL_TYPES.has(channel2.type)) return true;
137212
+ if (channel2.dataPoint("PRESS_SHORT") !== void 0) return true;
137213
+ const spec = source.getParamsetSpec(device.interfaceId, channel2.address, "VALUES");
137214
+ return spec !== void 0 && "PRESS_SHORT" in spec;
137215
+ }
137216
+ function clientState(channel2, address, withPress) {
137217
+ const known = new Map((channel2?.dataPoints ?? []).map((dp) => [dp.parameter, dp]));
137218
+ const press = withPress ? KEY_DIAGNOSIS_PARAMETERS : [];
137219
+ const rest = [...known.keys()].filter((parameter) => !press.includes(parameter));
137220
+ return {
137221
+ channelAddress: address,
137222
+ parameters: [...press, ...rest].map((parameter) => {
137223
+ const dp = known.get(parameter);
137224
+ return {
137225
+ parameter,
137226
+ known: dp !== void 0,
137227
+ lastEventAt: dp?.lastUpdatedAt ?? null,
137228
+ value: dp?.value ?? null
137229
+ };
137230
+ })
137231
+ };
137232
+ }
137233
+ async function readChannelXmlRpc(source, interfaceId2, address) {
137234
+ const [centralLink, directLinks, values, master] = await Promise.all([
137235
+ section(async () => {
137236
+ const metadata = await source.getMetadata(interfaceId2, address, REPORT_VALUE_USAGE_DATA);
137237
+ return {
137238
+ pressShortCount: pressShortCount(metadata),
137239
+ active: metadataHasCentralLink(metadata)
137240
+ };
137241
+ }),
137242
+ section(async () => parseChannelLinks(await source.getLinks(interfaceId2, address, GET_LINKS_FLAGS))),
137243
+ section(() => source.readParamset(interfaceId2, address, "VALUES")),
137244
+ section(() => source.readParamset(interfaceId2, address, "MASTER"))
137245
+ ]);
137246
+ return {
137247
+ centralLink,
137248
+ directLinks,
137249
+ values,
137250
+ master
137251
+ };
137252
+ }
137253
+ async function readMaintenance(source, interfaceId2, address) {
137254
+ return section(async () => {
137255
+ const values = await source.readParamset(interfaceId2, address, "VALUES");
137256
+ return {
137257
+ channelAddress: address,
137258
+ configPending: values["CONFIG_PENDING"] ?? null,
137259
+ unreach: values["UNREACH"] ?? null,
137260
+ rssiDevice: values["RSSI_DEVICE"] ?? null,
137261
+ rssiPeer: values["RSSI_PEER"] ?? null,
137262
+ updatePending: values["UPDATE_PENDING"] ?? null
137263
+ };
137264
+ });
137265
+ }
137266
+ async function readRega(source, device, keyAddresses) {
137267
+ if (keyAddresses.length === 0) return {
137268
+ available: true,
137269
+ state: {
137270
+ channels: [],
137271
+ programs: []
137272
+ }
137273
+ };
137274
+ try {
137275
+ return {
137276
+ available: true,
137277
+ state: await source.readRega(interfaceNameOf(device.interfaceId), keyAddresses)
137278
+ };
137279
+ } catch (err) {
137280
+ return {
137281
+ available: false,
137282
+ reason: messageOf(err)
137283
+ };
137284
+ }
137285
+ }
137286
+ async function diagnoseKeyEvents(source, device) {
137287
+ const keyChannels = device.channels.filter((channel2) => isKeyChannel(source, device, channel2));
137288
+ const maintenanceAddress = `${device.address}:0`;
137289
+ const [maintenance, channels, rega] = await Promise.all([
137290
+ readMaintenance(source, device.interfaceId, maintenanceAddress),
137291
+ Promise.all(keyChannels.map(async (channel2) => ({
137292
+ address: channel2.address,
137293
+ type: channel2.type ?? null,
137294
+ xmlRpc: await readChannelXmlRpc(source, device.interfaceId, channel2.address),
137295
+ client: clientState(channel2, channel2.address, true)
137296
+ }))),
137297
+ readRega(source, device, keyChannels.map((channel2) => channel2.address))
137298
+ ]);
137299
+ const info = source.getConnectionInfo(device.interfaceId);
137300
+ return {
137301
+ deviceAddress: device.address,
137302
+ interfaceId: device.interfaceId,
137303
+ takenAt: source.now(),
137304
+ maintenance,
137305
+ maintenanceClient: clientState(device.channel(maintenanceAddress), maintenanceAddress, false),
137306
+ channels,
137307
+ rega,
137308
+ interfaceClient: {
137309
+ interfaceId: device.interfaceId,
137310
+ state: String(info.state),
137311
+ lastEventAt: info.lastEventAt,
137312
+ callbackAlive: info.callbackAlive
137313
+ }
137314
+ };
137315
+ }
136867
137316
  var SWITCH_LINK_SENDER_TYPE = "KEY_TRANSCEIVER";
136868
137317
  var SWITCH_LINK_RECEIVER_TYPE = "SWITCH_VIRTUAL_RECEIVER";
136869
137318
  var ACTION_TYPE = "PROFILE_ACTION_TYPE";
@@ -136989,12 +137438,12 @@ function parseLinks(value) {
136989
137438
  const sender = nonEmptyString(entry["SENDER"]);
136990
137439
  const receiver = nonEmptyString(entry["RECEIVER"]);
136991
137440
  if (sender === void 0 || receiver === void 0) continue;
136992
- const name = entry["NAME"];
137441
+ const name2 = entry["NAME"];
136993
137442
  const description = entry["DESCRIPTION"];
136994
137443
  links.push({
136995
137444
  sender,
136996
137445
  receiver,
136997
- name: typeof name === "string" ? name : "",
137446
+ name: typeof name2 === "string" ? name2 : "",
136998
137447
  description: typeof description === "string" ? description : ""
136999
137448
  });
137000
137449
  }
@@ -137640,8 +138089,8 @@ var RfLockEntity = class extends CustomEntity {
137640
138089
  await this.write("OPEN", true);
137641
138090
  }
137642
138091
  };
137643
- function channelAddress(deviceAddress, channel) {
137644
- return `${deviceAddress}:${channel}`;
138092
+ function channelAddress(deviceAddress, channel2) {
138093
+ return `${deviceAddress}:${channel2}`;
137645
138094
  }
137646
138095
  function resolveFields(device, baseChannel, mappings, defaultOffset, target, readTarget) {
137647
138096
  for (const mapping of mappings) {
@@ -137843,9 +138292,9 @@ var TypedEventEmitter = class {
137843
138292
  };
137844
138293
  var DEFAULT_CENTRAL_NAME = "nodehomematic";
137845
138294
  var pendingTestInjectables;
137846
- function toInterface2(name) {
137847
- const match = Object.values(Interface).includes(name) ? name : void 0;
137848
- if (match === void 0) throw new ValidationError(`Unknown interface "${name}".`);
138295
+ function toInterface2(name2) {
138296
+ const match = Object.values(Interface).includes(name2) ? name2 : void 0;
138297
+ if (match === void 0) throw new ValidationError(`Unknown interface "${name2}".`);
137849
138298
  return match;
137850
138299
  }
137851
138300
  var CHANNEL_ADDRESS_PATTERN = /^[0-9A-Za-z_-]+:\d+$/;
@@ -138072,7 +138521,9 @@ var Homematic = class {
138072
138521
  * CCU subscribes to the key data points (ReGa scripts and their eq-3/occu
138073
138522
  * sources: `central/rega/key-event-program.ts`). All channels must be on one
138074
138523
  * interface and the CCU must have their data points; a missing one is a
138075
- * {@link ValidationError} naming it. Needs WebUI credentials.
138524
+ * {@link ValidationError} naming it. Two programs with the same name are a
138525
+ * {@link ValidationError} listing their ids (`deleteProgram(id)` removes one).
138526
+ * Needs WebUI credentials.
138076
138527
  */
138077
138528
  async ensureKeyEventProgram(input) {
138078
138529
  if (input.channelAddresses.length === 0) throw new ValidationError("ensureKeyEventProgram needs at least one channel.");
@@ -138081,13 +138532,46 @@ var Homematic = class {
138081
138532
  if (interfaces.size !== 1 || iface === void 0) throw new ValidationError("The key channels of one program must share an interface.");
138082
138533
  return this.#requireManagement().keyPrograms().ensure(iface, input);
138083
138534
  }
138084
- /** Delete the key event program `name`; `removed: false` when it does not exist. Needs WebUI credentials. */
138085
- async removeKeyEventProgram(name) {
138086
- return this.#requireManagement().keyPrograms().remove(name);
138535
+ /** Delete the key event program `name`; `removed: false` when it does not exist. A duplicate name is a {@link ValidationError}. Needs WebUI credentials. */
138536
+ async removeKeyEventProgram(name2) {
138537
+ return this.#requireManagement().keyPrograms().remove(name2);
138538
+ }
138539
+ /**
138540
+ * Delete one CCU program by its ReGa id (digits only). `removed: false` when
138541
+ * the id is missing or is not a program — nothing is deleted then. This is
138542
+ * the way out of two programs that share a name. Needs WebUI credentials.
138543
+ */
138544
+ async deleteProgram(programId) {
138545
+ return this.#requireManagement().keyPrograms().delete(programId);
138087
138546
  }
138088
- /** The key event program `name` and the channels it listens to, or `null`. Needs WebUI credentials. */
138089
- async getKeyEventProgram(name) {
138090
- return this.#requireManagement().keyPrograms().get(name);
138547
+ /** The key event program `name` and the channels it listens to, or `null`. A duplicate name is a {@link ValidationError}. Needs WebUI credentials. */
138548
+ async getKeyEventProgram(name2) {
138549
+ return this.#requireManagement().keyPrograms().get(name2);
138550
+ }
138551
+ /**
138552
+ * Read-only diagnosis of "why does a key of this device not deliver
138553
+ * `PRESS_SHORT` to this client?": for the device's key channels it collects
138554
+ * the XML-RPC side (central link, direct links, VALUES, MASTER, and the
138555
+ * maintenance channel `:0`), the ReGa side (channel and key data point
138556
+ * objects with their last update, and the programs that reference them;
138557
+ * needs WebUI credentials, otherwise `rega.available` is `false`) and what
138558
+ * this client itself received. Each section fails on its own with
138559
+ * `{ ok: false, error }`. Sources and semantics: `key-event-diagnosis.ts`.
138560
+ * Throws {@link ValidationError} for an unknown device or before `start()`.
138561
+ */
138562
+ async diagnoseKeyEvents(deviceAddress) {
138563
+ const management = this.#requireManagement();
138564
+ const device = this.#devicesByAddress.get(deviceAddress);
138565
+ if (device === void 0) throw new ValidationError(`Unknown device "${deviceAddress}".`);
138566
+ return diagnoseKeyEvents({
138567
+ getMetadata: (iface, address, dataId) => this.#central.getMetadata(iface, address, dataId),
138568
+ getLinks: (iface, address, flags) => this.#central.getLinks(iface, address, flags),
138569
+ readParamset: (iface, address, key) => this.#central.readParamset(iface, address, key),
138570
+ getParamsetSpec: (iface, address, key) => this.#central.getParamsetSpec(iface, address, key),
138571
+ getConnectionInfo: (iface) => this.#central.getConnectionInfo(iface),
138572
+ readRega: (iface, addresses) => management.keyDiagnosis().read(iface, addresses),
138573
+ now: () => Date.now()
138574
+ }, device);
138091
138575
  }
138092
138576
  /**
138093
138577
  * Create a direct link from `sender` to `receiver` (XML-RPC
@@ -138097,11 +138581,11 @@ var Homematic = class {
138097
138581
  * without a call and leaves the existing name and description unchanged.
138098
138582
  * The sender must be a known channel; a fault is a {@link ClientError}.
138099
138583
  */
138100
- async addLink(sender, receiver, name = "", description = "") {
138584
+ async addLink(sender, receiver, name2 = "", description = "") {
138101
138585
  const device = this.#requireKnownChannel(sender);
138102
138586
  requireChannelAddress(receiver);
138103
138587
  if (await this.#findLink(device.interfaceId, sender, receiver) !== void 0) return;
138104
- await this.#central.addLink(device.interfaceId, sender, receiver, name, description);
138588
+ await this.#central.addLink(device.interfaceId, sender, receiver, name2, description);
138105
138589
  }
138106
138590
  /**
138107
138591
  * Remove the direct link from `sender` to `receiver` (XML-RPC
@@ -138177,16 +138661,16 @@ var Homematic = class {
138177
138661
  * Resolves with the names the CCU stored (it keeps names unique); `devices()`
138178
138662
  * shows them from then on. Needs WebUI credentials.
138179
138663
  */
138180
- async renameDevice(address, name, options) {
138664
+ async renameDevice(address, name2, options) {
138181
138665
  this.#requireKnownDevice(address);
138182
- const result = await this.#requireTopology().renameDevice(address, name, options.renameChannels);
138666
+ const result = await this.#requireTopology().renameDevice(address, name2, options.renameChannels);
138183
138667
  this.#rememberNames([result.device, ...result.channels]);
138184
138668
  return result;
138185
138669
  }
138186
138670
  /** Rename one channel (as JSON-RPC `Channel.setName`); resolves with the stored name. Needs WebUI credentials. */
138187
- async renameChannel(address, name) {
138671
+ async renameChannel(address, name2) {
138188
138672
  this.#requireKnownChannel(address);
138189
- const result = await this.#requireTopology().renameChannel(address, name);
138673
+ const result = await this.#requireTopology().renameChannel(address, name2);
138190
138674
  this.#rememberNames([result]);
138191
138675
  return result;
138192
138676
  }
@@ -138199,12 +138683,12 @@ var Homematic = class {
138199
138683
  return this.#requireTopology().rooms();
138200
138684
  }
138201
138685
  /** Create an empty room (eq-3/occu `rega/esp/rooms.fn` `createRoomRetId`); a duplicate name is refused. Needs WebUI credentials. */
138202
- async createRoom(name) {
138203
- return this.#requireTopology().createRoom(name);
138686
+ async createRoom(name2) {
138687
+ return this.#requireTopology().createRoom(name2);
138204
138688
  }
138205
138689
  /** Rename a room by its id (`rooms.fn` `changeRoomName`). Needs WebUI credentials. */
138206
- async renameRoom(roomId, name) {
138207
- await this.#requireTopology().renameRoom(roomId, name);
138690
+ async renameRoom(roomId, name2) {
138691
+ await this.#requireTopology().renameRoom(roomId, name2);
138208
138692
  }
138209
138693
  /** Delete a room by its id (`rega/esp/system.fn` `DeleteObject`). Needs WebUI credentials. */
138210
138694
  async deleteRoom(roomId) {
@@ -138358,20 +138842,20 @@ var Homematic = class {
138358
138842
  return this.#sysvars.map(toHmSysVar);
138359
138843
  }
138360
138844
  /** Read a single system variable's current value by name. Throws if no hub. */
138361
- async getSystemVariable(name) {
138362
- return this.#requireHub().getSystemVariable(name);
138845
+ async getSystemVariable(name2) {
138846
+ return this.#requireHub().getSystemVariable(name2);
138363
138847
  }
138364
138848
  /**
138365
138849
  * Write a system variable by name. Validates against the snapshot BEFORE any
138366
138850
  * network call: an unknown or read-only variable throws {@link ValidationError}
138367
138851
  * (no write is attempted). Throws if no hub.
138368
138852
  */
138369
- async setSystemVariable(name, value) {
138853
+ async setSystemVariable(name2, value) {
138370
138854
  const hub = this.#requireHub();
138371
- const sysvar = this.#sysvars.find((v) => v.name === name);
138372
- if (sysvar === void 0) throw new ValidationError(`Unknown system variable "${name}".`);
138373
- if (!sysvar.writable) throw new ValidationError(`System variable "${name}" is read-only.`);
138374
- await hub.setSystemVariable(name, value);
138855
+ const sysvar = this.#sysvars.find((v) => v.name === name2);
138856
+ if (sysvar === void 0) throw new ValidationError(`Unknown system variable "${name2}".`);
138857
+ if (!sysvar.writable) throw new ValidationError(`System variable "${name2}" is read-only.`);
138858
+ await hub.setSystemVariable(name2, value);
138375
138859
  }
138376
138860
  /**
138377
138861
  * An immutable snapshot of every known program (empty when no hub). Refreshed
@@ -138404,65 +138888,65 @@ var Homematic = class {
138404
138888
  return this.#customEntityList.map((entity) => toHmCustomEntity(entity));
138405
138889
  }
138406
138890
  /** Set a climate entity's target temperature (clamped to its range). */
138407
- async climateSetTemperature(device, channel, temperature) {
138408
- await this.#climate(device, channel).setTemperature(temperature);
138891
+ async climateSetTemperature(device, channel2, temperature) {
138892
+ await this.#climate(device, channel2).setTemperature(temperature);
138409
138893
  }
138410
138894
  /** Set a climate entity's operating mode. */
138411
- async climateSetMode(device, channel, mode) {
138412
- await this.#climate(device, channel).setMode(mode);
138895
+ async climateSetMode(device, channel2, mode) {
138896
+ await this.#climate(device, channel2).setMode(mode);
138413
138897
  }
138414
138898
  /** Enable or disable a climate entity's boost mode. */
138415
- async climateSetBoost(device, channel, on) {
138416
- await this.#climate(device, channel).setBoost(on);
138899
+ async climateSetBoost(device, channel2, on) {
138900
+ await this.#climate(device, channel2).setBoost(on);
138417
138901
  }
138418
138902
  /** Turn a switch entity on. */
138419
- async switchTurnOn(device, channel) {
138420
- await this.#switch(device, channel).turnOn();
138903
+ async switchTurnOn(device, channel2) {
138904
+ await this.#switch(device, channel2).turnOn();
138421
138905
  }
138422
138906
  /** Turn a switch entity off. */
138423
- async switchTurnOff(device, channel) {
138424
- await this.#switch(device, channel).turnOff();
138907
+ async switchTurnOff(device, channel2) {
138908
+ await this.#switch(device, channel2).turnOff();
138425
138909
  }
138426
138910
  /** Turn a light entity on (full brightness, or `brightness` 0..255 when given). */
138427
- async lightTurnOn(device, channel, brightness) {
138428
- const light = this.#light(device, channel);
138911
+ async lightTurnOn(device, channel2, brightness) {
138912
+ const light = this.#light(device, channel2);
138429
138913
  await (brightness === void 0 ? light.turnOn() : light.turnOn(brightness));
138430
138914
  }
138431
138915
  /** Turn a light entity off. */
138432
- async lightTurnOff(device, channel) {
138433
- await this.#light(device, channel).turnOff();
138916
+ async lightTurnOff(device, channel2) {
138917
+ await this.#light(device, channel2).turnOff();
138434
138918
  }
138435
138919
  /** Set a light entity's brightness (0..255). */
138436
- async lightSetBrightness(device, channel, brightness) {
138437
- await this.#light(device, channel).setBrightness(brightness);
138920
+ async lightSetBrightness(device, channel2, brightness) {
138921
+ await this.#light(device, channel2).setBrightness(brightness);
138438
138922
  }
138439
138923
  /** Open a cover entity fully. */
138440
- async coverOpen(device, channel) {
138441
- await this.#cover(device, channel).open();
138924
+ async coverOpen(device, channel2) {
138925
+ await this.#cover(device, channel2).open();
138442
138926
  }
138443
138927
  /** Close a cover entity fully. */
138444
- async coverClose(device, channel) {
138445
- await this.#cover(device, channel).close();
138928
+ async coverClose(device, channel2) {
138929
+ await this.#cover(device, channel2).close();
138446
138930
  }
138447
138931
  /** Stop a cover entity where it is. */
138448
- async coverStop(device, channel) {
138449
- await this.#cover(device, channel).stop();
138932
+ async coverStop(device, channel2) {
138933
+ await this.#cover(device, channel2).stop();
138450
138934
  }
138451
138935
  /** Move a cover entity to `position` (0..100). */
138452
- async coverSetPosition(device, channel, position) {
138453
- await this.#cover(device, channel).setPosition(position);
138936
+ async coverSetPosition(device, channel2, position) {
138937
+ await this.#cover(device, channel2).setPosition(position);
138454
138938
  }
138455
138939
  /** Lock a lock entity. */
138456
- async lockLock(device, channel) {
138457
- await this.#lock(device, channel).lock();
138940
+ async lockLock(device, channel2) {
138941
+ await this.#lock(device, channel2).lock();
138458
138942
  }
138459
138943
  /** Unlock a lock entity. */
138460
- async lockUnlock(device, channel) {
138461
- await this.#lock(device, channel).unlock();
138944
+ async lockUnlock(device, channel2) {
138945
+ await this.#lock(device, channel2).unlock();
138462
138946
  }
138463
138947
  /** Release a lock entity's latch (open). */
138464
- async lockOpen(device, channel) {
138465
- await this.#lock(device, channel).open();
138948
+ async lockOpen(device, channel2) {
138949
+ await this.#lock(device, channel2).open();
138466
138950
  }
138467
138951
  /**
138468
138952
  * Resolve the live custom entity for `(device, channel)`, asserting its
@@ -138470,36 +138954,36 @@ var Homematic = class {
138470
138954
  * channel address (normalised like the {@link DataPointRef} resolver). Throws
138471
138955
  * {@link ValidationError} when absent or of the wrong kind.
138472
138956
  */
138473
- #entity(device, channel, expectedKind) {
138474
- const channelAddress2 = typeof channel === "string" && (channel.includes(":") || channel.startsWith(`${device}:`)) ? channel : `${device}:${channel}`;
138957
+ #entity(device, channel2, expectedKind) {
138958
+ const channelAddress2 = typeof channel2 === "string" && (channel2.includes(":") || channel2.startsWith(`${device}:`)) ? channel2 : `${device}:${channel2}`;
138475
138959
  const entity = this.#customEntitiesByKey.get(`${device}:${channelAddress2}`);
138476
138960
  if (entity === void 0) throw new ValidationError(`No custom entity for "${device}" channel "${channelAddress2}".`);
138477
138961
  if (entity.kind !== expectedKind) throw new ValidationError(`Custom entity "${device}" channel "${channelAddress2}" is a ${entity.kind}, not a ${expectedKind}.`);
138478
138962
  return entity;
138479
138963
  }
138480
- #climate(device, channel) {
138481
- const entity = this.#entity(device, channel, "climate");
138964
+ #climate(device, channel2) {
138965
+ const entity = this.#entity(device, channel2, "climate");
138482
138966
  if (!(entity instanceof ClimateEntity)) throw new ValidationError(`Custom entity for "${device}" is not a climate entity.`);
138483
138967
  return entity;
138484
138968
  }
138485
- #switch(device, channel) {
138486
- const entity = this.#entity(device, channel, "switch");
138969
+ #switch(device, channel2) {
138970
+ const entity = this.#entity(device, channel2, "switch");
138487
138971
  if (!(entity instanceof SwitchEntity)) throw new ValidationError(`Custom entity for "${device}" is not a switch entity.`);
138488
138972
  return entity;
138489
138973
  }
138490
- #light(device, channel) {
138491
- const entity = this.#entity(device, channel, "light");
138974
+ #light(device, channel2) {
138975
+ const entity = this.#entity(device, channel2, "light");
138492
138976
  if (!(entity instanceof DimmerEntity)) throw new ValidationError(`Custom entity for "${device}" is not a light entity.`);
138493
138977
  return entity;
138494
138978
  }
138495
- #cover(device, channel) {
138496
- const channelAddress2 = typeof channel === "string" && (channel.includes(":") || channel.startsWith(`${device}:`)) ? channel : `${device}:${channel}`;
138979
+ #cover(device, channel2) {
138980
+ const channelAddress2 = typeof channel2 === "string" && (channel2.includes(":") || channel2.startsWith(`${device}:`)) ? channel2 : `${device}:${channel2}`;
138497
138981
  const entity = this.#customEntitiesByKey.get(`${device}:${channelAddress2}`);
138498
138982
  if (entity === void 0 || !(entity instanceof CoverEntity)) throw new ValidationError(`No cover custom entity for "${device}" channel "${channelAddress2}".`);
138499
138983
  return entity;
138500
138984
  }
138501
- #lock(device, channel) {
138502
- const entity = this.#entity(device, channel, "lock");
138985
+ #lock(device, channel2) {
138986
+ const entity = this.#entity(device, channel2, "lock");
138503
138987
  if (entity instanceof IpLockEntity || entity instanceof RfLockEntity) return entity;
138504
138988
  throw new ValidationError(`Custom entity for "${device}" is not a lock entity.`);
138505
138989
  }
@@ -138571,7 +139055,7 @@ var Homematic = class {
138571
139055
  const bus = this.#central.eventBus;
138572
139056
  this.#unsubscribers.push(bus.subscribe({
138573
139057
  type: "valueReceived",
138574
- handler: (event) => this.#onValueReceived(event.dpk, event.value, event.receivedAt)
139058
+ handler: (event) => this.#onValueReceived(event.dpk, event.value, event.receivedAt, event.origin === "event")
138575
139059
  }), bus.subscribe({
138576
139060
  type: "deviceAdded",
138577
139061
  handler: (event) => this.#onDeviceAdded(event.address)
@@ -138604,16 +139088,22 @@ var Homematic = class {
138604
139088
  dp.applyCcuValue(entry.value, entry.at);
138605
139089
  }
138606
139090
  }
138607
- #onValueReceived(dpk, value, receivedAt) {
139091
+ /**
139092
+ * An ACTION parameter (`PRESS_SHORT`, `PRESS_LONG`, …) is an occurrence, not a
139093
+ * state: every press arrives as the same `true`, so "unchanged" must not
139094
+ * swallow it. A pushed event of an ACTION parameter is always emitted; a
139095
+ * seeded read-back of one never is (it would replay an old press).
139096
+ */
139097
+ #onValueReceived(dpk, value, receivedAt, pushed) {
138608
139098
  const dp = this.#dataPointsById.get(dpkToUniqueId(dpk));
138609
139099
  if (dp === void 0) return;
138610
139100
  const result = dp.applyCcuValue(value, receivedAt);
138611
- if (!result.changed) return;
138612
- const channel = dp.dpk.channelAddress;
139101
+ if (dp.type === "ACTION" ? !pushed : !result.changed) return;
139102
+ const channel2 = dp.dpk.channelAddress;
138613
139103
  this.#emitter.emit("valueChanged", {
138614
139104
  dpId: dp.id,
138615
- device: deviceAddressOf4(channel),
138616
- channel,
139105
+ device: deviceAddressOf4(channel2),
139106
+ channel: channel2,
138617
139107
  parameter: dp.parameter,
138618
139108
  value: result.next,
138619
139109
  prevValue: result.prev,
@@ -138641,8 +139131,8 @@ var Homematic = class {
138641
139131
  if (dp2 === void 0) throw new ValidationError(`Unknown data point id "${ref}".`);
138642
139132
  return dp2;
138643
139133
  }
138644
- const channel = ref.channel;
138645
- const channelAddress2 = typeof channel === "string" && (channel.includes(":") || channel.startsWith(`${ref.device}:`)) ? channel : `${ref.device}:${channel}`;
139134
+ const channel2 = ref.channel;
139135
+ const channelAddress2 = typeof channel2 === "string" && (channel2.includes(":") || channel2.startsWith(`${ref.device}:`)) ? channel2 : `${ref.device}:${channel2}`;
138646
139136
  const device = this.#devicesByAddress.get(ref.device);
138647
139137
  if (device === void 0) throw new ValidationError(`Unknown device "${ref.device}".`);
138648
139138
  const dpId = dpkToUniqueId(makeDpk(device.interfaceId, channelAddress2, "VALUES", ref.parameter));
@@ -138814,11 +139304,11 @@ function toHmDataPoint(dp) {
138814
139304
  }
138815
139305
  function toHmCustomEntity(entity) {
138816
139306
  const device = entity.deviceAddress;
138817
- const channel = entity.primaryChannelAddress;
139307
+ const channel2 = entity.primaryChannelAddress;
138818
139308
  if (entity instanceof ClimateEntity) return {
138819
139309
  kind: "climate",
138820
139310
  device,
138821
- channel,
139311
+ channel: channel2,
138822
139312
  currentTemperature: entity.currentTemperature,
138823
139313
  targetTemperature: entity.targetTemperature,
138824
139314
  currentHumidity: entity.currentHumidity,
@@ -138832,20 +139322,20 @@ function toHmCustomEntity(entity) {
138832
139322
  if (entity instanceof SwitchEntity) return {
138833
139323
  kind: "switch",
138834
139324
  device,
138835
- channel,
139325
+ channel: channel2,
138836
139326
  isOn: entity.isOn
138837
139327
  };
138838
139328
  if (entity instanceof DimmerEntity) return {
138839
139329
  kind: "light",
138840
139330
  device,
138841
- channel,
139331
+ channel: channel2,
138842
139332
  isOn: entity.isOn,
138843
139333
  brightness: entity.brightness
138844
139334
  };
138845
139335
  if (entity instanceof CoverEntity) return {
138846
139336
  kind: entity.kind === "blind" ? "blind" : "cover",
138847
139337
  device,
138848
- channel,
139338
+ channel: channel2,
138849
139339
  channels: entity.channelAddresses,
138850
139340
  statusChannels: entity.statusChannelAddresses,
138851
139341
  currentPosition: entity.currentPosition,
@@ -138856,18 +139346,18 @@ function toHmCustomEntity(entity) {
138856
139346
  if (entity instanceof IpLockEntity || entity instanceof RfLockEntity) return {
138857
139347
  kind: "lock",
138858
139348
  device,
138859
- channel,
139349
+ channel: channel2,
138860
139350
  isLocked: entity.isLocked
138861
139351
  };
138862
139352
  throw new ValidationError(`Unsupported custom entity kind "${entity.kind}".`);
138863
139353
  }
138864
139354
  function toHmDevice(device, hubRooms, hubFunctions, renamed) {
138865
- const channels = device.channels.map((channel) => ({
138866
- address: channel.address,
138867
- index: channel.index,
138868
- ...channel.type !== void 0 ? { type: channel.type } : {},
138869
- name: renamed?.get(channel.address) ?? channel.name ?? null,
138870
- dataPoints: channel.dataPoints.map(toHmDataPoint)
139355
+ const channels = device.channels.map((channel2) => ({
139356
+ address: channel2.address,
139357
+ index: channel2.index,
139358
+ ...channel2.type !== void 0 ? { type: channel2.type } : {},
139359
+ name: renamed?.get(channel2.address) ?? channel2.name ?? null,
139360
+ dataPoints: channel2.dataPoints.map(toHmDataPoint)
138871
139361
  }));
138872
139362
  const rooms = unionStrings(device.rooms, hubRooms);
138873
139363
  const functions = unionStrings(device.functions, hubFunctions);
@@ -138898,13 +139388,13 @@ function toHmSysVar(sysvar) {
138898
139388
  ...sysvar.max !== void 0 ? { max: sysvar.max } : {}
138899
139389
  };
138900
139390
  }
138901
- function toHmProgram(program) {
139391
+ function toHmProgram(program2) {
138902
139392
  return {
138903
- id: program.id,
138904
- name: program.name,
138905
- isActive: program.isActive,
138906
- isInternal: program.isInternal,
138907
- ...program.lastExecuteTime !== void 0 ? { lastExecuteTime: program.lastExecuteTime } : {}
139393
+ id: program2.id,
139394
+ name: program2.name,
139395
+ isActive: program2.isActive,
139396
+ isInternal: program2.isInternal,
139397
+ ...program2.lastExecuteTime !== void 0 ? { lastExecuteTime: program2.lastExecuteTime } : {}
138908
139398
  };
138909
139399
  }
138910
139400
  function aggregateByDevice(byChannel) {
@@ -138912,7 +139402,7 @@ function aggregateByDevice(byChannel) {
138912
139402
  for (const [address, names] of byChannel) {
138913
139403
  const deviceAddress = deviceAddressOf4(address);
138914
139404
  const existing = out.get(deviceAddress) ?? [];
138915
- for (const name of names) if (!existing.includes(name)) existing.push(name);
139405
+ for (const name2 of names) if (!existing.includes(name2)) existing.push(name2);
138916
139406
  out.set(deviceAddress, existing);
138917
139407
  }
138918
139408
  return out;
@@ -138920,8 +139410,8 @@ function aggregateByDevice(byChannel) {
138920
139410
  function unionStrings(base, extra) {
138921
139411
  if ((base === void 0 || base.length === 0) && (extra === void 0 || extra.length === 0)) return;
138922
139412
  const out = [];
138923
- for (const name of base ?? []) if (!out.includes(name)) out.push(name);
138924
- for (const name of extra ?? []) if (!out.includes(name)) out.push(name);
139413
+ for (const name2 of base ?? []) if (!out.includes(name2)) out.push(name2);
139414
+ for (const name2 of extra ?? []) if (!out.includes(name2)) out.push(name2);
138925
139415
  return out;
138926
139416
  }
138927
139417
  var HM_DELETE_FLAGS = {
@@ -139187,7 +139677,7 @@ function buildCcuProgramHandlers(deps) {
139187
139677
  const facade = connectedFacade(deps, input.integrationId);
139188
139678
  const program = programById(facade, input.programId);
139189
139679
  if (program.isInternal) refuse("internal");
139190
- const { removed } = await facade.removeKeyEventProgram(program.name);
139680
+ const { removed } = await facade.deleteProgram(program.id);
139191
139681
  if (!removed) refuse("unknown-program");
139192
139682
  logProgram(deps, "Homematic: program deleted", [], {
139193
139683
  integrationId: input.integrationId,
@@ -139384,6 +139874,11 @@ function buildCcuRoomHandlers(deps) {
139384
139874
  * page). Reads are `query`; every CCU write is a `mutation` whose input carries
139385
139875
  * the operator's `confirmed` flag.
139386
139876
  */
139877
+ /**
139878
+ * The library's diagnosis, passed through as it is: a read-only report for an
139879
+ * operator and an agent, shaped and documented by nodehomematic.
139880
+ */
139881
+ var KeyEventDiagnosisSchema = custom((value) => typeof value === "object" && value !== null);
139387
139882
  var homematicActions = defineCustomActions({
139388
139883
  discoverCcu: customAction(object({}), object({
139389
139884
  hosts: array(object({
@@ -139524,6 +140019,10 @@ var homematicActions = defineCustomActions({
139524
140019
  kind: "query",
139525
140020
  auth: "admin"
139526
140021
  }),
140022
+ diagnoseCcuKeyEvents: customAction(DeviceRefSchema, KeyEventDiagnosisSchema, {
140023
+ kind: "query",
140024
+ auth: "admin"
140025
+ }),
139527
140026
  setCcuValue: customAction(SetValueInputSchema, OkResultSchema, {
139528
140027
  kind: "mutation",
139529
140028
  auth: "admin"