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

Some API tweaking for openevse integration. #394

Open
KipK opened this issue Nov 29, 2024 · 5 comments
Open

Some API tweaking for openevse integration. #394

KipK opened this issue Nov 29, 2024 · 5 comments

Comments

@KipK
Copy link

KipK commented Nov 29, 2024

Following up #402, I create an issue here as its more appropriated.

1/ If a claim or an override is already present, API should add the property on it, instead of creating a new claim/override with only the latest property.

example: EVSE is manually set to enabled, user change the charge_rate, it then just create a new override with only "charge_current" , state is removed.
should instead create a new override with "charge_current" and "state"

2/ Same as above, If a claim/override have more than one property ( but auto_release ), removing a property should keep the other properties but not delete the claim/override. If there's only one property, it then should remove the override/claim.

3/ setting charge rate to its max value ( aka "max_current_soft" ) should remove the charge_current property from the override if there's other properties, or remove the override if there's only the "charge_current" one.

In all cases, it should not consider "auto_release" if set to "true" , as this one is always added to a claim/override by default. You can just ignore this property like it does on OpenEVSE UI side as there's no use case for override. But probably better to test the boolean state and just ignore it if it's true.

@firstof9
Copy link
Owner

1/ If a claim or an override is already present, API should add the property on it, instead of creating a new claim/override with only the latest property.

As I understand it the override API is just a single setting, and calling it again should just add to the override that's in place currently. As for the claims, a similar thing as long as the client is the same. Please do correct me if I am wrong.

3/ setting charge rate to its max value ( aka "max_current_soft" ) should remove the charge_current property from the override if there's other properties, or remove the override if there's only the "charge_current" one.

This shouldn't be too hard.

@KipK
Copy link
Author

KipK commented Nov 29, 2024

/override endpoint is an abstraction of /claim endpoint but only for "manual override" service id.
It just works the same as claims, can have all the claim properties too. ( state, charge_current, max_current )

When you create an override you can see it in /claim endpoint too.

For the claims, yes it should only consider the properties of the same service ID you use of course.

@firstof9
Copy link
Owner

Looking at the code for make_claim

async def make_claim(
self,
state: str | None = None,
charge_current: int | None = None,
max_current: int | None = None,
auto_release: bool = True,
client: int = CLIENT,
) -> Any:
"""Make a claim."""
if not self._version_check("4.1.0"):
_LOGGER.debug("Feature not supported for older firmware.")
raise UnsupportedFeature
if state not in ["active", "disabled", None]:
_LOGGER.error("Invalid claim state: %s", state)
raise ValueError
url = f"{self.url}claims/{client}"
data: dict[str, Any] = {}
data["auto_release"] = auto_release
if state is not None:
data["state"] = state
if charge_current is not None:
data["charge_current"] = charge_current
if max_current is not None:
data["max_current"] = max_current
_LOGGER.debug("Claim data: %s", data)
_LOGGER.debug("Setting up claim on %s", url)
response = await self.process_request(
url=url, method="post", data=data
) # noqa: E501
return response

I'm only adjusting the claim the library makes and only adjusting whatever variables are passed, but that only piles on the current claim then I assume right or would it wipe what's currently in the claim and use what's been passed to it?

@KipK
Copy link
Author

KipK commented Nov 29, 2024

On OpenEvse each time you make a new claim with same service ID or an override, you have to resend all the properties yes.

@firstof9
Copy link
Owner

Thanks for confirming.

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