8000 Don't raise when setting HVAC mode without a mode ZwaveValue by raman325 · Pull Request #52444 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Don't raise when setting HVAC mode without a mode ZwaveValue #52444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions homeassistant/components/zwave_js/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,15 @@ async def async_set_temperature(self, **kwargs: Any) -> None:

async def async_set_hvac_mode(self, hvac_mode: str) -> None:
"""Set new target hvac mode."""
if not self._current_mode:
# Thermostat(valve) with no support for setting a mode
raise ValueError(
f"Thermostat {self.entity_id} does not support setting a mode"
)
hvac_mode_value = self._hvac_modes.get(hvac_mode)
if hvac_mode_value is None:
hvac_mode_id = self._hvac_modes.get(hvac_mode)
if hvac_mode_id is None:
raise ValueError(f"Received an invalid hvac mode: {hvac_mode}")
await self.info.node.async_set_value(self._current_mode, hvac_mode_value)

if not self._current_mode:
# Thermostat(valve) has no support for setting a mode, so we make it a no-op
return

await self.info.node.async_set_value(self._current_mode, hvac_mode_id)

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new target preset mode."""
Expand Down
24 changes: 24 additions & 0 deletions tests/components/zwave_js/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,30 @@ async def test_setpoint_thermostat(hass, client, climate_danfoss_lc_13, integrat
blocking=True,
)

# Test setting illegal mode raises an error
with pytest.raises(ValueError):
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
ATTR_ENTITY_ID: CLIMATE_DANFOSS_LC13_ENTITY,
ATTR_HVAC_MODE: HVAC_MODE_COOL,
},
blocking=True,
)

# Test that setting HVAC_MODE_HEAT works. If the no-op logic didn't work, this would
# raise an error
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
ATTR_ENTITY_ID: CLIMATE_DANFOSS_LC13_ENTITY,
ATTR_HVAC_MODE: HVAC_MODE_HEAT,
},
blocking=True,
)

assert len(client.async_send_command_no_wait.call_args_list) == 1
args = client.async_send_command_no_wait.call_args_list[0][0][0]
assert args["command"] == "node.set_value"
Expand Down
0