Skip to content

Commit

Permalink
🐛 unable to enable heating
Browse files Browse the repository at this point in the history
  • Loading branch information
daxingplay committed Mar 30, 2024
1 parent e428e25 commit a596aca
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 44 deletions.
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
"python.pythonPath": "/usr/local/bin/python",
"files.associations": {
"*.yaml": "home-assistant"
}
},
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
4 changes: 2 additions & 2 deletions custom_components/vaillant_plus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ async def close(self) -> None:
pass
self._state = "CLOSED"

async def control_device(self, attr, value) -> bool:
async def control_device(self, attrs: dict[str, Any]) -> bool:
"""Send command to control device."""
retry_times = 0
while retry_times < 3:
try:
await self._api_client.control_device(self._device_id, attr, value)
await self._api_client.control_device(self._device_id, attrs)
return True
except InvalidAuthError:
await self._get_token()
Expand Down
22 changes: 10 additions & 12 deletions custom_components/vaillant_plus/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,14 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
_LOGGER.debug("Setting HVAC mode to: %s", hvac_mode)

if hvac_mode == HVACMode.OFF:
await self._client.control_device(
"Heating_Enable",
0,
)
await self._client.control_device({
"Heating_Enable": False,
})
elif hvac_mode == HVACMode.HEAT:
await self._client.control_device(
"Heating_Enable",
1,
)
await self._client.control_device({
"Heating_Enable": True,
"Mode_Setting_CH": "Cruising",
})

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Select new HVAC preset mode."""
Expand All @@ -195,7 +194,6 @@ async def async_set_temperature(self, **kwargs) -> None:

_LOGGER.debug("Setting target temperature to: %s", new_temperature)

await self._client.control_device(
"Room_Temperature_Setpoint_Comfort",
new_temperature,
)
await self._client.control_device({
"Room_Temperature_Setpoint_Comfort": new_temperature,
})
4 changes: 3 additions & 1 deletion custom_components/vaillant_plus/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@ def update_from_latest_data(self, data: dict[str, Any]) -> None:

async def send_command(self, attr: str, value: Any) -> None:
"""Send operations to cloud."""
await self._client.control_device(attr, value)
await self._client.control_device({
f"{attr}": value
})
4 changes: 2 additions & 2 deletions custom_components/vaillant_plus/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"vaillant_plus_cn_api"
],
"requirements": [
"vaillant-plus-cn-api==1.2.9"
"vaillant-plus-cn-api==2.0.0"
],
"ssdp": [],
"version": "1.2.2",
"version": "1.2.3",
"zeroconf": []
}
22 changes: 10 additions & 12 deletions tests/test_cliamte.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,17 @@ async def test_climate_actions(hass, device_api_client):
assert climate.preset_mode == PRESET_COMFORT

await climate.async_set_temperature(temperature=30)
send_command_func.assert_awaited_with(
"Room_Temperature_Setpoint_Comfort",
30,
)
send_command_func.assert_awaited_with({
"Room_Temperature_Setpoint_Comfort": 30,
})

await climate.async_set_hvac_mode(HVACMode.OFF)
send_command_func.assert_awaited_with(
"Heating_Enable",
0,
)
send_command_func.assert_awaited_with({
"Heating_Enable": False
})

await climate.async_set_hvac_mode(HVACMode.HEAT)
send_command_func.assert_awaited_with(
"Heating_Enable",
1,
)
send_command_func.assert_awaited_with({
"Heating_Enable": True,
"Mode_Setting_CH": "Cruising",
})
4 changes: 2 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async def test_client_control_device_invalid_auth(

caplog.clear()
caplog.set_level(logging.WARNING)
ret = await client.control_device("Test_Attr", "1")
ret = await client.control_device({"Test_Attr": "1"})

messages = [
x.message for x in caplog.records if x.message.startswith("Control device failed")
Expand All @@ -127,7 +127,7 @@ async def test_client_control_device(

caplog.clear()
caplog.set_level(logging.WARNING)
ret = await client.control_device("Test_Attr", "1")
ret = await client.control_device({"Test_Attr": "1"})

messages = [
x.message for x in caplog.records if x.message.startswith("Control device failed")
Expand Down
21 changes: 9 additions & 12 deletions tests/test_water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ async def test_water_heater_actions(hass, device_api_client):
send_command_func.assert_not_awaited()

await water_heater.async_set_operation_mode(WATER_HEATER_OFF)
send_command_func.assert_awaited_with(
"WarmStar_Tank_Loading_Enable",
0,
)
send_command_func.assert_awaited_with({
"WarmStar_Tank_Loading_Enable": 0,
})

await water_heater.async_set_operation_mode(WATER_HEATER_ON)
send_command_func.assert_awaited_with(
"WarmStar_Tank_Loading_Enable",
1,
)
send_command_func.assert_awaited_with({
"WarmStar_Tank_Loading_Enable": 1,
})

await water_heater.async_set_temperature(temperature=30)
send_command_func.assert_awaited_with(
"DHW_setpoint",
30,
)
send_command_func.assert_awaited_with({
"DHW_setpoint": 30,
})

0 comments on commit a596aca

Please sign in to comment.