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