@riddix/hamh 2.1.0-alpha.405 → 2.1.0-alpha.406

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.
@@ -168013,6 +168013,21 @@ var hvacModeToSystemMode = {
168013
168013
  function isHeatCoolOnly(modes) {
168014
168014
  return modes.includes(ClimateHvacMode.heat_cool) && !modes.includes(ClimateHvacMode.heat) && !modes.includes(ClimateHvacMode.cool);
168015
168015
  }
168016
+ var lastHvacDirection = /* @__PURE__ */ new Map();
168017
+ function getHeatCoolOnlyDirection(entity, agent) {
168018
+ const action = attributes4(entity).hvac_action;
168019
+ const homeAssistant = agent.get(HomeAssistantEntityBehavior);
168020
+ const entityId = homeAssistant.entityId;
168021
+ if (action === ClimateHvacAction.heating || action === ClimateHvacAction.preheating || action === ClimateHvacAction.defrosting || action === ClimateHvacAction.drying) {
168022
+ lastHvacDirection.set(entityId, "heating");
168023
+ return "heating";
168024
+ }
168025
+ if (action === ClimateHvacAction.cooling) {
168026
+ lastHvacDirection.set(entityId, "cooling");
168027
+ return "cooling";
168028
+ }
168029
+ return lastHvacDirection.get(entityId) ?? "heating";
168030
+ }
168016
168031
  var config4 = {
168017
168032
  // Temperature range (target_temp_low/high) only works in heat_cool mode.
168018
168033
  // In heat or cool mode, HA expects a single "temperature" value.
@@ -168031,13 +168046,14 @@ var config4 = {
168031
168046
  getCurrentTemperature: (entity, agent) => getTemp(agent, entity, "current_temperature"),
168032
168047
  getTargetHeatingTemperature: (entity, agent) => getTemp(agent, entity, "target_temp_low") ?? getTemp(agent, entity, "target_temperature") ?? getTemp(agent, entity, "temperature"),
168033
168048
  getTargetCoolingTemperature: (entity, agent) => getTemp(agent, entity, "target_temp_high") ?? getTemp(agent, entity, "target_temperature") ?? getTemp(agent, entity, "temperature"),
168034
- getSystemMode: (entity) => {
168049
+ getSystemMode: (entity, agent) => {
168035
168050
  const hvacMode = entity.state;
168036
168051
  const systemMode = hvacModeToSystemMode[hvacMode] ?? Thermostat3.SystemMode.Off;
168037
168052
  if (systemMode === Thermostat3.SystemMode.Auto) {
168038
168053
  const modes = attributes4(entity).hvac_modes ?? [];
168039
168054
  if (isHeatCoolOnly(modes)) {
168040
- return Thermostat3.SystemMode.Heat;
168055
+ const direction = getHeatCoolOnlyDirection(entity, agent);
168056
+ return direction === "cooling" ? Thermostat3.SystemMode.Cool : Thermostat3.SystemMode.Heat;
168041
168057
  }
168042
168058
  const hasHeatCool = modes.includes(ClimateHvacMode.heat_cool);
168043
168059
  if (hasHeatCool) {
@@ -168066,16 +168082,13 @@ var config4 = {
168066
168082
  if (!action) {
168067
168083
  return Thermostat3.ThermostatRunningMode.Off;
168068
168084
  }
168069
- const runningMode = hvacActionToRunningMode[action] ?? Thermostat3.ThermostatRunningMode.Off;
168070
- if (runningMode === Thermostat3.ThermostatRunningMode.Cool && isHeatCoolOnly(attributes4(entity).hvac_modes ?? [])) {
168071
- return Thermostat3.ThermostatRunningMode.Heat;
168072
- }
168073
- return runningMode;
168085
+ return hvacActionToRunningMode[action] ?? Thermostat3.ThermostatRunningMode.Off;
168074
168086
  },
168075
- getControlSequence: (entity) => {
168087
+ getControlSequence: (entity, agent) => {
168076
168088
  const modes = attributes4(entity).hvac_modes ?? [];
168077
168089
  if (isHeatCoolOnly(modes)) {
168078
- return Thermostat3.ControlSequenceOfOperation.HeatingOnly;
168090
+ const direction = getHeatCoolOnlyDirection(entity, agent);
168091
+ return direction === "cooling" ? Thermostat3.ControlSequenceOfOperation.CoolingOnly : Thermostat3.ControlSequenceOfOperation.HeatingOnly;
168079
168092
  }
168080
168093
  const hasCooling = modes.some(
168081
168094
  (m) => m === ClimateHvacMode.cool || m === ClimateHvacMode.heat_cool
@@ -168202,8 +168215,9 @@ function ClimateDevice(homeAssistantEntity) {
168202
168215
  const hasBatteryAttr = attributes7.battery_level != null || attributes7.battery != null;
168203
168216
  const hasBatteryEntity = !!homeAssistantEntity.mapping?.batteryEntity;
168204
168217
  const hasBattery = hasBatteryAttr || hasBatteryEntity;
168205
- const heatCoolOnly = attributes7.hvac_modes.includes(ClimateHvacMode.heat_cool) && !attributes7.hvac_modes.includes(ClimateHvacMode.heat) && !attributes7.hvac_modes.includes(ClimateHvacMode.cool);
168206
- const supportsCooling = heatCoolOnly ? false : coolingModes.some((mode) => attributes7.hvac_modes.includes(mode));
168218
+ const supportsCooling = coolingModes.some(
168219
+ (mode) => attributes7.hvac_modes.includes(mode)
168220
+ );
168207
168221
  const hasExplicitHeating = heatingModes.some(
168208
168222
  (mode) => attributes7.hvac_modes.includes(mode)
168209
168223
  );