Skip to content

Commit

Permalink
fix: only turns off heater when on if overheated
Browse files Browse the repository at this point in the history
refs:  #181
  • Loading branch information
= authored and swingerman committed May 10, 2024
1 parent 5755206 commit 31d5909
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 21 deletions.
60 changes: 40 additions & 20 deletions config/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ input_number:
name: Room Temperature
initial: 20
min: 16
max: 90
step: .5
max: 30
step: .1
icon: mdi:home-thermometer

room_floor_temp:
name: Room Floor Temperature
initial: 20
min: 16
max: 30
step: .5
step: .1
icon: mdi:thermometer

outside_temp:
name: Outside Temperature
initial: 20
min: 0
max: 30
step: .5
step: .1
icon: mdi:thermometer-lines

sensor:
Expand Down Expand Up @@ -285,29 +285,49 @@ climate:
# target_temp_low: 19
# target_temp_high: 21.5

# - platform: dual_smart_thermostat
# name: Edge Case 184
# unique_id: edge_case_184
# heater: switch.heater
# cooler: switch.cooler
# fan: switch.fan
# target_sensor: sensor.room_temp
# min_temp: 60
# max_temp: 85
# fan_hot_tolerance: 0.5
# heat_cool_mode: true
# min_cycle_duration:
# seconds: 60
# keep_alive:
# minutes: 3
# away:
# target_temp_low: 68
# target_temp_high: 77
# home:
# target_temp_low: 71
# target_temp_high: 74
# precision: 0.1
# target_temp_step: 0.5

- platform: dual_smart_thermostat
name: Edge Case 184
unique_id: edge_case_184
name: Edge Case 181
unique_id: edge_case_181
heater: switch.heater
cooler: switch.cooler
fan: switch.fan
target_sensor: sensor.room_temp
min_temp: 60
max_temp: 85
fan_hot_tolerance: 0.5
floor_sensor: sensor.floor_temp
heat_cool_mode: true
min_cycle_duration:
seconds: 60
keep_alive:
minutes: 3
away:
target_temp_low: 68
target_temp_high: 77
home:
target_temp_low: 71
target_temp_high: 74
max_floor_temp: 26
min_floor_temp: 10
fan_hot_tolerance: 0.7
target_temp_step: 0.1
precision: 0.1
target_temp_step: 0.5
min_temp: 9
max_temp: 32
target_temp: 20
cold_tolerance: 0.3
hot_tolerance: 0.3

# - platform: dual_smart_thermostat
# name: AUX Heat Room
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ async def _async_control_heat_cool(self, time=None, force=False) -> None:
if self.openings.any_opening_open(self.hvac_mode):
await self.async_turn_off()
self._hvac_action_reason = HVACActionReason.OPENING
elif self.temperatures.is_floor_hot:
elif self.temperatures.is_floor_hot and self.heater_device.is_active:
await self.heater_device.async_turn_off()
self._hvac_action_reason = HVACActionReason.OVERHEAT
elif self.temperatures.is_floor_cold:
Expand Down
105 changes: 105 additions & 0 deletions tests/test_dual_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,111 @@ async def test_hvac_mode_mode_heat_cool_fan_tolerance(
assert hass.states.get(fan_switch).state == STATE_OFF


@pytest.mark.parametrize(
"hvac_mode",
[
HVACMode.HEAT_COOL,
HVACMode.COOL,
],
)
async def test_hvac_mode_mode_heat_cool_fan_tolerance_with_floor_sensor(
hass: HomeAssistant, hvac_mode, setup_comp_1 # noqa: F811
):
"""Test thermostat heater and cooler switch in heat/cool mode."""

heater_switch = "input_boolean.heater"
cooler_switch = "input_boolean.cooler"
fan_switch = "input_boolean.fan"

assert await async_setup_component(
hass,
input_boolean.DOMAIN,
{"input_boolean": {"heater": None, "cooler": None, "fan": None}},
)

assert await async_setup_component(
hass,
input_number.DOMAIN,
{
"input_number": {
"temp": {"name": "test", "initial": 10, "min": 0, "max": 40, "step": 1},
"floor_temp": {
"name": "floor_temp",
"initial": 10,
"min": 10,
"max": 40,
"step": 1,
},
}
},
)

assert await async_setup_component(
hass,
CLIMATE,
{
"climate": {
"platform": DOMAIN,
"name": "test",
"cooler": cooler_switch,
"heater": heater_switch,
"fan": fan_switch,
"hot_tolerance": 0.2,
"cold_tolerance": 0.2,
"fan_hot_tolerance": 0.5,
"heat_cool_mode": True,
"target_sensor": common.ENT_SENSOR,
"floor_sensor": common.ENT_FLOOR_SENSOR,
"max_floor_temp": 26,
"min_floor_temp": 10,
}
},
)
await hass.async_block_till_done()

# switch to COOL mode and test the fan hot tolerance
# after the hot tolerance first the fan should turn on
# and outside the fan_hot_tolerance the AC

await common.async_set_hvac_mode(hass, hvac_mode)
await common.async_set_temperature(hass, 20, ENTITY_MATCH_ALL, 20, 18)
setup_sensor(hass, 20)
setup_floor_sensor(hass, 27)
await hass.async_block_till_done()

assert hass.states.get(cooler_switch).state == STATE_OFF
assert hass.states.get(heater_switch).state == STATE_OFF
assert hass.states.get(fan_switch).state == STATE_OFF

setup_sensor(hass, 20.2)
await hass.async_block_till_done()

assert hass.states.get(cooler_switch).state == STATE_OFF
assert hass.states.get(heater_switch).state == STATE_OFF
assert hass.states.get(fan_switch).state == STATE_ON

setup_sensor(hass, 20.5)
await hass.async_block_till_done()

assert hass.states.get(cooler_switch).state == STATE_OFF
assert hass.states.get(heater_switch).state == STATE_OFF
assert hass.states.get(fan_switch).state == STATE_ON

setup_sensor(hass, 20.7)
await hass.async_block_till_done()

assert hass.states.get(cooler_switch).state == STATE_OFF
assert hass.states.get(heater_switch).state == STATE_OFF
assert hass.states.get(fan_switch).state == STATE_ON

setup_sensor(hass, 20.8)
await hass.async_block_till_done()

assert hass.states.get(cooler_switch).state == STATE_ON
assert hass.states.get(heater_switch).state == STATE_OFF
assert hass.states.get(fan_switch).state == STATE_OFF


async def test_hvac_mode_mode_heat_cool_hvac_modes_temps(
hass: HomeAssistant, setup_comp_1 # noqa: F811
):
Expand Down

0 comments on commit 31d5909

Please sign in to comment.