Skip to content

Commit 56f9521

Browse files
KipKfirstof9
andauthored
Missing plain/text http header in set_divert_mode (#436)
* fix /divertmode call * missing = * missing header in set_divert_mode * Update openevsehttp/__main__.py Co-authored-by: Chris <[email protected]> * Update test_main.py * remove unused headers variable * formatting * formatting with black --------- Co-authored-by: Chris <[email protected]> Co-authored-by: [email protected] <[email protected]>
1 parent 2630172 commit 56f9521

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

openevsehttp/__main__.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -876,19 +876,16 @@ async def set_led_brightness(self, level: int) -> None:
876876
async def set_divert_mode(self, mode: str = "fast") -> None:
877877
"""Set the divert mode."""
878878
url = f"{self.url}divertmode"
879-
880879
if mode not in ["fast", "eco"]:
881-
_LOGGER.error("Invalid value for charge_mode: %s", mode)
880+
_LOGGER.error("Invalid value for divert mode: %s", mode)
882881
raise ValueError
883-
884882
_LOGGER.debug("Setting divert mode to %s", mode)
885-
886883
# convert text to int
887884
new_mode = divert_mode[mode]
888-
data = "divertmode=" + str(new_mode)
889-
response = await self.process_request(
890-
url=url, method="post", data=data
891-
) # noqa: E501
885+
886+
data = f"divertmode={new_mode}"
887+
888+
response = await self.process_request(url=url, method="post", rapi=data)
892889
if response != "Divert Mode changed":
893890
_LOGGER.error("Problem issuing command: %s", response)
894891
raise UnknownError

tests/test_main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,7 @@ async def test_set_divert_mode(
21952195
with pytest.raises(ValueError):
21962196
with caplog.at_level(logging.DEBUG):
21972197
await test_charger_new.set_divert_mode("test")
2198-
assert "Invalid value for charge_mode: test" in caplog.text
2198+
assert "Invalid value for divert mode: test" in caplog.text
21992199

22002200
mock_aioclient.post(
22012201
TEST_URL_DIVERT,

0 commit comments

Comments
 (0)