@riddix/hamh 2.1.0-alpha.385 → 2.1.0-alpha.387
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/backend/cli.js
CHANGED
|
@@ -165580,19 +165580,20 @@ var ComposedSensorEndpoint = class _ComposedSensorEndpoint extends Endpoint {
|
|
|
165580
165580
|
scheduleUpdate(endpoint, entityId, states) {
|
|
165581
165581
|
const state = states[entityId];
|
|
165582
165582
|
if (!state) return;
|
|
165583
|
+
const key = endpoint === this ? `_parent_:${entityId}` : entityId;
|
|
165583
165584
|
const stateJson = JSON.stringify({
|
|
165584
165585
|
s: state.state,
|
|
165585
165586
|
a: state.attributes
|
|
165586
165587
|
});
|
|
165587
|
-
if (this.lastStates.get(
|
|
165588
|
-
this.lastStates.set(
|
|
165589
|
-
let debouncedFn = this.debouncedUpdates.get(
|
|
165588
|
+
if (this.lastStates.get(key) === stateJson) return;
|
|
165589
|
+
this.lastStates.set(key, stateJson);
|
|
165590
|
+
let debouncedFn = this.debouncedUpdates.get(key);
|
|
165590
165591
|
if (!debouncedFn) {
|
|
165591
165592
|
debouncedFn = debounce2(
|
|
165592
165593
|
(ep, s) => this.flushUpdate(ep, s),
|
|
165593
165594
|
50
|
|
165594
165595
|
);
|
|
165595
|
-
this.debouncedUpdates.set(
|
|
165596
|
+
this.debouncedUpdates.set(key, debouncedFn);
|
|
165596
165597
|
}
|
|
165597
165598
|
debouncedFn(endpoint, state);
|
|
165598
165599
|
}
|
|
@@ -166589,6 +166590,32 @@ var AlarmPanelEndpointType = ModeSelectDevice.with(
|
|
|
166589
166590
|
HomeAssistantEntityBehavior,
|
|
166590
166591
|
AlarmModeServer
|
|
166591
166592
|
);
|
|
166593
|
+
var AlarmOnOffServer = OnOffServer2({
|
|
166594
|
+
isOn: (entityState, agent) => {
|
|
166595
|
+
return agent.get(HomeAssistantEntityBehavior).isAvailable && entityState.state !== "disarmed";
|
|
166596
|
+
},
|
|
166597
|
+
turnOn: (_, agent) => {
|
|
166598
|
+
const ha = agent.get(HomeAssistantEntityBehavior);
|
|
166599
|
+
const features2 = ha.entity.state.attributes.supported_features ?? 0;
|
|
166600
|
+
if (features2 & FEATURE_ARM_AWAY)
|
|
166601
|
+
return { action: "alarm_control_panel.alarm_arm_away" };
|
|
166602
|
+
if (features2 & FEATURE_ARM_HOME)
|
|
166603
|
+
return { action: "alarm_control_panel.alarm_arm_home" };
|
|
166604
|
+
if (features2 & FEATURE_ARM_NIGHT)
|
|
166605
|
+
return { action: "alarm_control_panel.alarm_arm_night" };
|
|
166606
|
+
return { action: "alarm_control_panel.alarm_arm_away" };
|
|
166607
|
+
},
|
|
166608
|
+
turnOff: () => ({ action: "alarm_control_panel.alarm_disarm" })
|
|
166609
|
+
});
|
|
166610
|
+
var AlarmOnOffEndpointType = OnOffPlugInUnitDevice.with(
|
|
166611
|
+
BasicInformationServer2,
|
|
166612
|
+
IdentifyServer2,
|
|
166613
|
+
HomeAssistantEntityBehavior,
|
|
166614
|
+
AlarmOnOffServer
|
|
166615
|
+
);
|
|
166616
|
+
function AlarmOnOffDevice(homeAssistantEntity) {
|
|
166617
|
+
return AlarmOnOffEndpointType.set({ homeAssistantEntity });
|
|
166618
|
+
}
|
|
166592
166619
|
function AlarmControlPanelDevice(homeAssistantEntity) {
|
|
166593
166620
|
const attrs = homeAssistantEntity.entity.state.attributes;
|
|
166594
166621
|
const modes = getAlarmModes(attrs);
|
|
@@ -167726,10 +167753,6 @@ var config4 = {
|
|
|
167726
167753
|
if (systemMode === Thermostat3.SystemMode.Auto) {
|
|
167727
167754
|
const modes = attributes4(entity).hvac_modes ?? [];
|
|
167728
167755
|
if (isHeatCoolOnly(modes)) {
|
|
167729
|
-
const action2 = attributes4(entity).hvac_action;
|
|
167730
|
-
if (action2 === ClimateHvacAction.cooling) {
|
|
167731
|
-
return Thermostat3.SystemMode.Cool;
|
|
167732
|
-
}
|
|
167733
167756
|
return Thermostat3.SystemMode.Heat;
|
|
167734
167757
|
}
|
|
167735
167758
|
const hasHeatCool = modes.includes(ClimateHvacMode.heat_cool);
|
|
@@ -167759,15 +167782,15 @@ var config4 = {
|
|
|
167759
167782
|
if (!action) {
|
|
167760
167783
|
return Thermostat3.ThermostatRunningMode.Off;
|
|
167761
167784
|
}
|
|
167762
|
-
|
|
167785
|
+
const runningMode = hvacActionToRunningMode[action] ?? Thermostat3.ThermostatRunningMode.Off;
|
|
167786
|
+
if (runningMode === Thermostat3.ThermostatRunningMode.Cool && isHeatCoolOnly(attributes4(entity).hvac_modes ?? [])) {
|
|
167787
|
+
return Thermostat3.ThermostatRunningMode.Heat;
|
|
167788
|
+
}
|
|
167789
|
+
return runningMode;
|
|
167763
167790
|
},
|
|
167764
167791
|
getControlSequence: (entity) => {
|
|
167765
167792
|
const modes = attributes4(entity).hvac_modes ?? [];
|
|
167766
167793
|
if (isHeatCoolOnly(modes)) {
|
|
167767
|
-
const action = attributes4(entity).hvac_action;
|
|
167768
|
-
if (action === ClimateHvacAction.cooling) {
|
|
167769
|
-
return Thermostat3.ControlSequenceOfOperation.CoolingOnly;
|
|
167770
|
-
}
|
|
167771
167794
|
return Thermostat3.ControlSequenceOfOperation.HeatingOnly;
|
|
167772
167795
|
}
|
|
167773
167796
|
const hasCooling = modes.some(
|
|
@@ -167895,9 +167918,8 @@ function ClimateDevice(homeAssistantEntity) {
|
|
|
167895
167918
|
const hasBatteryAttr = attributes7.battery_level != null || attributes7.battery != null;
|
|
167896
167919
|
const hasBatteryEntity = !!homeAssistantEntity.mapping?.batteryEntity;
|
|
167897
167920
|
const hasBattery = hasBatteryAttr || hasBatteryEntity;
|
|
167898
|
-
const
|
|
167899
|
-
|
|
167900
|
-
);
|
|
167921
|
+
const heatCoolOnly = attributes7.hvac_modes.includes(ClimateHvacMode.heat_cool) && !attributes7.hvac_modes.includes(ClimateHvacMode.heat) && !attributes7.hvac_modes.includes(ClimateHvacMode.cool);
|
|
167922
|
+
const supportsCooling = heatCoolOnly ? false : coolingModes.some((mode) => attributes7.hvac_modes.includes(mode));
|
|
167901
167923
|
const hasExplicitHeating = heatingModes.some(
|
|
167902
167924
|
(mode) => attributes7.hvac_modes.includes(mode)
|
|
167903
167925
|
);
|
|
@@ -171519,6 +171541,9 @@ var TemperaturePressureSensorWithBatteryType = TemperatureSensorDevice.with(
|
|
|
171519
171541
|
);
|
|
171520
171542
|
|
|
171521
171543
|
// src/matter/endpoints/legacy/sensor/index.ts
|
|
171544
|
+
var tempDt = { deviceType: DeviceTypeId(770), revision: 2 };
|
|
171545
|
+
var humidityDt = { deviceType: DeviceTypeId(775), revision: 2 };
|
|
171546
|
+
var pressureDt = { deviceType: DeviceTypeId(773), revision: 2 };
|
|
171522
171547
|
function SensorDevice(homeAssistantEntity) {
|
|
171523
171548
|
const attributes7 = homeAssistantEntity.entity.state.attributes;
|
|
171524
171549
|
const deviceClass = attributes7.device_class;
|
|
@@ -171529,29 +171554,39 @@ function SensorDevice(homeAssistantEntity) {
|
|
|
171529
171554
|
const hasBattery = !!mapping?.batteryEntity;
|
|
171530
171555
|
if (hasHumidity && hasPressure && hasBattery) {
|
|
171531
171556
|
return TemperatureHumidityPressureSensorWithBatteryType.set({
|
|
171532
|
-
homeAssistantEntity
|
|
171557
|
+
homeAssistantEntity,
|
|
171558
|
+
descriptor: { deviceTypeList: [tempDt, humidityDt, pressureDt] }
|
|
171533
171559
|
});
|
|
171534
171560
|
}
|
|
171535
171561
|
if (hasHumidity && hasPressure) {
|
|
171536
171562
|
return TemperatureHumidityPressureSensorType.set({
|
|
171537
|
-
homeAssistantEntity
|
|
171563
|
+
homeAssistantEntity,
|
|
171564
|
+
descriptor: { deviceTypeList: [tempDt, humidityDt, pressureDt] }
|
|
171538
171565
|
});
|
|
171539
171566
|
}
|
|
171540
171567
|
if (hasHumidity && hasBattery) {
|
|
171541
171568
|
return TemperatureHumiditySensorWithBatteryType.set({
|
|
171542
|
-
homeAssistantEntity
|
|
171569
|
+
homeAssistantEntity,
|
|
171570
|
+
descriptor: { deviceTypeList: [tempDt, humidityDt] }
|
|
171543
171571
|
});
|
|
171544
171572
|
}
|
|
171545
171573
|
if (hasHumidity) {
|
|
171546
|
-
return TemperatureHumiditySensorType.set({
|
|
171574
|
+
return TemperatureHumiditySensorType.set({
|
|
171575
|
+
homeAssistantEntity,
|
|
171576
|
+
descriptor: { deviceTypeList: [tempDt, humidityDt] }
|
|
171577
|
+
});
|
|
171547
171578
|
}
|
|
171548
171579
|
if (hasPressure && hasBattery) {
|
|
171549
171580
|
return TemperaturePressureSensorWithBatteryType.set({
|
|
171550
|
-
homeAssistantEntity
|
|
171581
|
+
homeAssistantEntity,
|
|
171582
|
+
descriptor: { deviceTypeList: [tempDt, pressureDt] }
|
|
171551
171583
|
});
|
|
171552
171584
|
}
|
|
171553
171585
|
if (hasPressure) {
|
|
171554
|
-
return TemperaturePressureSensorType.set({
|
|
171586
|
+
return TemperaturePressureSensorType.set({
|
|
171587
|
+
homeAssistantEntity,
|
|
171588
|
+
descriptor: { deviceTypeList: [tempDt, pressureDt] }
|
|
171589
|
+
});
|
|
171555
171590
|
}
|
|
171556
171591
|
if (hasBattery) {
|
|
171557
171592
|
return TemperatureSensorWithBatteryType.set({ homeAssistantEntity });
|
|
@@ -173769,7 +173804,13 @@ var matterDeviceTypeFactories = {
|
|
|
173769
173804
|
extended_color_light: (ha) => ExtendedColorLightType(true, true).set({
|
|
173770
173805
|
homeAssistantEntity: { entity: ha.entity, customName: ha.customName }
|
|
173771
173806
|
}),
|
|
173772
|
-
on_off_plugin_unit:
|
|
173807
|
+
on_off_plugin_unit: (ha) => {
|
|
173808
|
+
const domain = ha.entity.entity_id.split(".")[0];
|
|
173809
|
+
if (domain === "alarm_control_panel") {
|
|
173810
|
+
return AlarmOnOffDevice(ha);
|
|
173811
|
+
}
|
|
173812
|
+
return SwitchDevice(ha);
|
|
173813
|
+
},
|
|
173773
173814
|
on_off_switch: SwitchDevice,
|
|
173774
173815
|
door_lock: LockDevice,
|
|
173775
173816
|
window_covering: CoverDevice,
|