Skip to content

Commit

Permalink
fix: hvac_action set to fan when active
Browse files Browse the repository at this point in the history
Fixes #247
  • Loading branch information
= authored and swingerman committed Jul 24, 2024
1 parent 71f9c7a commit 309753e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from homeassistant.components.climate import HVACMode
from homeassistant.components.climate import HVACAction, HVACMode

from custom_components.dual_smart_thermostat.hvac_device.cooler_device import (
CoolerDevice,
Expand Down Expand Up @@ -36,3 +36,11 @@ def __init__(

if self.features.is_fan_uses_outside_air:
self.fan_air_surce_outside = True

@property
def hvac_action(self) -> HVACAction:
if self.hvac_mode == HVACMode.OFF:
return HVACAction.OFF
if self.is_active:
return HVACAction.FAN
return HVACAction.IDLE
5 changes: 5 additions & 0 deletions tests/test_fan_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2519,13 +2519,15 @@ async def test_set_target_temp_ac_on_after_fan_tolerance_2(

assert hass.states.get(cooler_switch).state == STATE_OFF
assert hass.states.get(fan_switch).state == STATE_ON
assert hass.states.get(common.ENTITY).attributes["hvac_action"] == HVACAction.FAN

# within hot_tolerance and fan_hot_tolerance
setup_sensor(hass, 20.5)
await hass.async_block_till_done()

assert hass.states.get(cooler_switch).state == STATE_OFF
assert hass.states.get(fan_switch).state == STATE_ON
assert hass.states.get(common.ENTITY).attributes["hvac_action"] == HVACAction.FAN

# within hot_tolerance and fan_hot_tolerance
setup_sensor(hass, 20.7)
Expand All @@ -2540,6 +2542,9 @@ async def test_set_target_temp_ac_on_after_fan_tolerance_2(

assert hass.states.get(cooler_switch).state == STATE_ON
assert hass.states.get(fan_switch).state == STATE_OFF
assert (
hass.states.get(common.ENTITY).attributes["hvac_action"] == HVACAction.COOLING
)


async def test_set_target_temp_ac_on_ignore_fan_tolerance(
Expand Down

0 comments on commit 309753e

Please sign in to comment.