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
Phasechange #23
Phasechange #23
Conversation
custom_components/zaptec/services.py
Outdated
_LOGGER.debug("update current single phase") | ||
installation_id = service_call.data["installation_id"] | ||
available_current = service_call.data["available_current"] | ||
return await acc.map[installation_id].limit_amps(available_current) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
limit_amps uses keyword arguments so the correct way to call this would be.
limit_amps(**{"keyword": value}) or limit_amps(keyword=value, keyword2=value)
Thanks for the feedback. Does it look better now? I'm not sure how to read the loop that you are doing: zaptec/custom_components/zaptec/api.py Line 185 in b5b4870
Will I able to set the three phases differently, e.g 16, 12, 4? Because as mentioned, the API says "Provide either AvailableCurrent or AvailableCurrentPhase1, AvailableCurrentPhase2 and AvailableCurrentPhase3." @ https://api.zaptec.com/help/index.html#/Installation/post_api_installation__id__update |
We are checking what keyword arguments that is used. If if one of AvailableCurrentPhase1, AvailableCurrentPhase2, AvailableCurrentPhase3 and availableCurrent. We remove availableCurrent. So to all 3 phase: limit_amps(availableCurrent=20)
|
Ah ok, thanks.
And:
|
Other service calls (but those are two the charger, not installation) seems to be working. Could it have to do with that? |
Its because partial isn’t defined. I have forgotten to add the import: from functools import partial |
Seems that, that did the trick. No errors now, but it is not working. I checked through the Swagger UI at https://api.zaptec.com/help/index.html#/Installation/get_api_installation__id_ and it appears to be updated when I use it there. But something in the code is off. |
Hi, will this PR be merged? I've started to implement Zaptec as chargertype in my peak-avoiding integration Peaqev and even if i can do it without letting the charger update its amps, the experience is greatly improved if the possibility exists. Also, I see that you've made two separate calls for one and three-phase. Shouldn't it just be possible to have one call as user and not having to know what it currently is charging at? Given the comment here stating |
Not in its current state no, i dont want to have two different api service calls. I cant remember what was needed but i think its just to register the service call and its ready as it is. I need to test it |
I don't have the technical skills to do development. Needs some basics in python - so I am pursuing a python course currently so I hopefully can continue it. I intend to solve the amps feature. |
Understood. I'll implement it without amp-changes for now then (and if i'm not mistaken you are contributor on that branch of mine as well) and upgrade later. |
@gustafssone I think you have done a really good job! . Basically, you just remove one of the service calls. If you want to finish it, I can do a quick code review so you can get it merged? |
Is this pr-change in the planning being released soon? |
@elden1337 not until the pr is updated. Logging needs to be cleaned up, i want one service call and somebody needs to test it. (I dont have a zaptec charger) |
Got it! I dont have one myself either. But maybe I can help pointing a user in this direction if @gustafssone isnt available. |
I have a couple of them so i'm willing to test. |
Sent it out among my peaqev-users. Perhaps someone volunteers to help testing it. We'll see. |
So much to do, so little time. If you have any testers/developers please go forward with it. |
Hello again, I got around to try to fix this. Perhaps @Hellowlol have some feedback? Before changing no of servicecalls and logging, need to get the thing working at all, and seems to be communication issues towards their API. Verified that it still works with their own Zaptec.ZapCloud.WebAPI which it does. Some debug logging and responses: |
@Hellowlol great that you cleaned up the code. I still get the parent error when actually trying to change the amps. Perhaps with your experience you have some insight on where to look? |
Hi, Unfortunately, I only cleaned it up. I didn’t have a charger to test with. Can you try to edit zaptec/custom_components/zaptec/api.py Line 389 in 55f3c84
Replace data=data with json=data Let me know if works |
I got it to work 😃
A few points: |
@Hellowlol any input on above? |
Just check the path and set the correct headerd json + patch, before you attemot to load rhe result you should checl the path again so you use the correct way for loading the response |
💪🏼💪🏼 |
It’s released as a prelease as I didn’t have time to do proper testing. If ppl test and it’s ok I’ll promote it to a normal version |
@gustafssone great work! can you ping me somehow once you feel it's good and i'll start updating peaqev to accommodate it asap. |
Lets continue discussion on #35 . |
Added service calls.
Not at all familiar with python so this is a trial and error, might need help with the correct syntax.
Will the available_current arguments pass correct in json?
I.e. will:
return await acc.map[installation_id].limit_amps(available_current)
pass as "AvailableCurrent": 16 or similar?
Also, not sure if the strings are correct, I wonder if it is case sensitive, availableCurrent instead of AvailableCurrent