Skip to content
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

Charger configuration sliders not updatable with Zaptec Go 2 #163

Open
paulzaptec opened this issue Feb 9, 2025 · 6 comments
Open

Charger configuration sliders not updatable with Zaptec Go 2 #163

paulzaptec opened this issue Feb 9, 2025 · 6 comments

Comments

@paulzaptec
Copy link

I am testing Home Assistant with the new Zaptec Go 2 charger and everything seems to work fine apart from the "Configuration" pane: the current values are reported correctly, but cannot be changed with the sliders (which are stuck at zero):

Image

The same account works as expected with a Zaptec Go charger:

Image

I cannot see anything unusual in the debug logs and (to the best of my knowledge) the API has not changed for Go 2.

I am happy to provide debug logs (or give remote access to a Go 2 charger) if you'd like to investigate further...

@sveinse
Copy link
Collaborator

sveinse commented Feb 9, 2025

Possibly (and I'm guessing) these two values are not settable on this type of changer. In the "installation" device there is an entity named "Available current". Are you able to adjust that to set the current? That's what I'm using when regulating the charge current for my car. I leave the charger min/max untouched.

The reason they're stuck is because Zaptec portal is rejecting the value.

@paulzaptec
Copy link
Author

paulzaptec commented Feb 9, 2025

Thanks for the quick reply! These values are adjustable in the Zaptec Portal by the same user, so they ought to be settable via the API (unless something is wrong there).

Image

If the API isn't allowing these values to be adjusted, that's an error on Zaptec's side, so I'll report this to the Zaptec API team.

(Editing installation current setting does work for me, but I'm not managing the current that way right now for other reasons...)

@sveinse
Copy link
Collaborator

sveinse commented Feb 9, 2025

It's interesting if setting the min / max current in the Zaptec portal is working, but it does not from HA. HA Zaptec is using the official method. If that isn't working, then I suspect the Zaptec portal is using another undocumented method to set the values. We have a few of that unfortunately.

Here is the official documentation for the command and you can read what Zaptec sais about it:
https://api.zaptec.com/help/index.html#/Charger/post_api_chargers__id__update

@paulzaptec
Copy link
Author

paulzaptec commented Feb 9, 2025

Hmm. I just tried setting the max current manually via the Swagger interface and it works just fine.
By calling /api/chargers/{id}/update to set "maxChargeCurrent": 32
That is using the official API, yes?

So I'm not sure why it's not working via Home Assistant.
(It used to work, but something changed recently to stop it working...)

@sveinse
Copy link
Collaborator

sveinse commented Feb 9, 2025

Hmm, I think it might not, actually.

The entities are defined here:

ZapNumberEntityDescription(
key="charger_min_current",
translation_key="charger_min_current",
device_class=NumberDeviceClass.CURRENT,
entity_category=EntityCategory.CONFIG,
native_min_value=0,
native_max_value=32,
icon="mdi:current-ac",
native_unit_of_measurement=const.UnitOfElectricCurrent.AMPERE,
cls=ZaptecSettingNumber,
setting="CurrentInMinimum",
),
ZapNumberEntityDescription(
key="charger_max_current",
translation_key="charger_max_current",
device_class=NumberDeviceClass.CURRENT,
entity_category=EntityCategory.CONFIG,
native_min_value=0,
native_max_value=32,
icon="mdi:current-ac",
native_unit_of_measurement=const.UnitOfElectricCurrent.AMPERE,
cls=ZaptecSettingNumber,
setting="CurrentInMaximum",
),

And value is set here (with focus on L89):

async def async_set_native_value(self, value: float) -> None:
"""Update to Zaptec."""
_LOGGER.debug(
"Setting %s.%s to <%s> %s (in %s)",
self.__class__.__qualname__,
self.key,
type(value).__qualname__,
value,
self.zaptec_obj.id,
)
try:
await self.zaptec_obj.set_settings({self.entity_description.setting: value})
except Exception as exc:
raise HomeAssistantError(
f"Setting {self.entity_description.setting} to {value} failed"
) from exc
await self.coordinator.async_request_refresh()

And it seems like its using settings, not update:

async def set_settings(self, settings: dict[str, Any]):
"""Set settings on the charger"""
values = [
{"id": ZCONST.settings.get(k), "value": v} for k, v in settings.items()
]
if any(d for d in values if d["id"] is None):
raise ValueError(f"Unknown setting '{settings}'")
_LOGGER.debug("Settings %s", settings)
# NOTE: Undocumented API call
data = await self._account._request(
f"chargers/{self.id}/settings", method="post", data=values
)
return data

So I'm starting to believe this is an issue that should be fixed in our end. I'm going to travel the next couple of weeks, so I won't have any opportunity to look at this thou.

@paulzaptec
Copy link
Author

Ah, that would explain it! If HA is using settings, then the results are not guaranteed.
It should always work from the /api/chargers/{id}/update endpoint.

Certainly not an urgent issue. However it's very helpful to understand a bit more about how HA is (currently) doing this.
Thanks for the pointers above! That gives me some good insights to discuss with the API team at Zaptec...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants