@riddix/hamh 2.1.0-alpha.579 → 2.1.0-alpha.580

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.
@@ -172127,6 +172127,7 @@ var FeaturedBase7 = SwitchServer.with(
172127
172127
  "MomentarySwitchMultiPress"
172128
172128
  );
172129
172129
  var GenericSwitchServerBase = class extends FeaturedBase7 {
172130
+ inLongPress = false;
172130
172131
  async initialize() {
172131
172132
  await super.initialize();
172132
172133
  const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
@@ -172148,6 +172149,7 @@ var GenericSwitchServerBase = class extends FeaturedBase7 {
172148
172149
  triggerPress(eventType) {
172149
172150
  const lower = eventType.toLowerCase();
172150
172151
  if (this.isLongPress(lower)) {
172152
+ this.inLongPress = true;
172151
172153
  this.state.currentPosition = 1;
172152
172154
  this.events.initialPress?.emit({ newPosition: 1 }, this.context);
172153
172155
  this.events.longPress?.emit({ newPosition: 1 }, this.context);
@@ -172155,8 +172157,14 @@ var GenericSwitchServerBase = class extends FeaturedBase7 {
172155
172157
  return;
172156
172158
  }
172157
172159
  if (this.isLongRelease(lower)) {
172158
- this.events.longRelease?.emit({ previousPosition: 1 }, this.context);
172160
+ if (!this.inLongPress) {
172161
+ this.state.currentPosition = 1;
172162
+ this.events.initialPress?.emit({ newPosition: 1 }, this.context);
172163
+ this.events.longPress?.emit({ newPosition: 1 }, this.context);
172164
+ }
172165
+ this.inLongPress = false;
172159
172166
  this.state.currentPosition = 0;
172167
+ this.events.longRelease?.emit({ previousPosition: 1 }, this.context);
172160
172168
  this.fireBridgeEvent(eventType, 1);
172161
172169
  return;
172162
172170
  }
@@ -172166,19 +172174,14 @@ var GenericSwitchServerBase = class extends FeaturedBase7 {
172166
172174
  const pressCount = this.getPressCount(lower);
172167
172175
  this.state.currentPosition = 1;
172168
172176
  this.events.initialPress?.emit({ newPosition: 1 }, this.context);
172169
- setTimeout(
172170
- this.callback(() => {
172171
- this.events.shortRelease?.emit({ previousPosition: 1 }, this.context);
172172
- this.state.currentPosition = 0;
172173
- this.events.multiPressComplete?.emit(
172174
- {
172175
- previousPosition: 0,
172176
- totalNumberOfPressesCounted: pressCount
172177
- },
172178
- this.context
172179
- );
172180
- }),
172181
- 100
172177
+ this.state.currentPosition = 0;
172178
+ this.events.shortRelease?.emit({ previousPosition: 1 }, this.context);
172179
+ this.events.multiPressComplete?.emit(
172180
+ {
172181
+ previousPosition: 0,
172182
+ totalNumberOfPressesCounted: pressCount
172183
+ },
172184
+ this.context
172182
172185
  );
172183
172186
  this.fireBridgeEvent(eventType, pressCount);
172184
172187
  }
@@ -179122,6 +179125,7 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
179122
179125
  lastState;
179123
179126
  pendingMappedChange = false;
179124
179127
  flushUpdate;
179128
+ eventUpdateChain = Promise.resolve();
179125
179129
  async delete() {
179126
179130
  this.flushUpdate.clear();
179127
179131
  await super.delete();
@@ -179142,6 +179146,12 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
179142
179146
  `State update received for ${this.entityId}: state=${state.state}`
179143
179147
  );
179144
179148
  this.lastState = state;
179149
+ if (this.entityId.startsWith("event.")) {
179150
+ this.eventUpdateChain = this.eventUpdateChain.then(
179151
+ () => this.flushPendingUpdate(state)
179152
+ );
179153
+ return;
179154
+ }
179145
179155
  this.flushUpdate(state);
179146
179156
  }
179147
179157
  async flushPendingUpdate(state) {