Skip to content

Commit e638fd7

Browse files
BeardedTech0oclaude
andcommitted
Investigate write endpoint: fix serial field, value format, and add error logging
- Change inverterSn to serialNum in remoteSet/write payload (matches read endpoints) - Change AC charge value from 1/0 to "true"/"false" string format - Log full server response body on HTTP 4xx errors to aid debugging Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 341e481 commit e638fd7

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

  • custom_components/luxcloud

‎custom_components/luxcloud/api.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from __future__ import annotations
33

44
import asyncio
5+
import json
56
import logging
67
from typing import Any
78

@@ -121,8 +122,16 @@ async def _request(
121122
data=data,
122123
timeout=aiohttp.ClientTimeout(total=20),
123124
) as resp:
125+
raw = await resp.text()
126+
if not resp.ok:
127+
_LOGGER.error(
128+
"LuxCloud HTTP %s at %s — response body: %s",
129+
resp.status,
130+
path,
131+
raw,
132+
)
124133
resp.raise_for_status()
125-
body = await resp.json(content_type=None)
134+
body = json.loads(raw) if raw else {}
126135
except aiohttp.ClientError as exc:
127136
raise LuxCloudApiError(f"HTTP error talking to LuxCloud: {exc}") from exc
128137

@@ -236,7 +245,7 @@ async def _write(self, hold_param: str, value: int | str) -> None:
236245
await self._request(
237246
"/v2/web/maintain/remoteSet/write",
238247
data={
239-
"inverterSn": self._serial,
248+
"serialNum": self._serial,
240249
"holdParam": hold_param,
241250
"valueText": str(value),
242251
"clientType": "WEB",
@@ -246,7 +255,7 @@ async def _write(self, hold_param: str, value: int | str) -> None:
246255

247256
async def async_set_ac_charge(self, enabled: bool) -> None:
248257
"""Enable or disable AC charging."""
249-
await self._write("HOLD_AC_CHARGE_ENABLE", 1 if enabled else 0)
258+
await self._write("HOLD_AC_CHARGE_ENABLE", "true" if enabled else "false")
250259

251260
async def async_set_ac_charge_current(self, current: int) -> None:
252261
"""Set AC charge current limit (0-80 A)."""

0 commit comments

Comments
 (0)