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

Fixed calculations on AC charging #39

Merged
merged 19 commits into from
Oct 20, 2023
Merged

Fixed calculations on AC charging #39

merged 19 commits into from
Oct 20, 2023

Conversation

jheredianet
Copy link

Added a control to estimate power con AC charging

@fetzu fetzu self-requested a review October 20, 2023 17:54
@fetzu fetzu self-assigned this Oct 20, 2023
Copy link
Owner

@fetzu fetzu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the fix @jheredianet 😃 !

I will add a commit with my suggested fixes and merge this to main.

🚀

@@ -28,6 +28,7 @@
import os
import paho.mqtt.client as mqtt
import requests
import json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to import json here, our only use of json ("response.json()") is part of request imported above.

@@ -215,7 +216,7 @@ def on_message(client, userdata, message):
#print("Unneeded topic:", message.topic, payload)

# Calculate acurrate power on AC charging
if data["power"] != 0.0 and data["is_charging"] == True and "voltage" in data and "current" in data:
if data["is_charging"]==True and data["is_dcfc"]==False and "voltage" in data and "current" in data:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple formatting fix to keep in line with the rest.

Comment on lines 283 to 284
msgDetails = "Data object to send:"
print(msgDetails, data)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think moving the print of the data object to the updateABRP() function is a great idea; but I would rather have the print happen when the message is actually sent, I'll move some stuff around to accommodate for this.

try:
headers = {"Authorization": "APIKEY "+APIKEY}
body = {"tlm": data}
response = requests.post("https://api.iternio.com/1/tlm/send?token="+USERTOKEN, headers=headers, json=body)
resp = response.json()
if resp["status"] != "ok":
print("Response from ABRP:", response.text)
else:
print("Response from ABRP:", resp["status"])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here the message should be more explicit, and signal that where was an issue with the POST request to the API.

~ Changes in logging/print of API request success/error
~ Fixes in formatting
@fetzu fetzu merged commit bc57749 into fetzu:main Oct 20, 2023
fetzu added a commit that referenced this pull request Oct 20, 2023
fetzu added a commit that referenced this pull request Oct 20, 2023
~ Changes in logging/print of API request success/error
~ Fixes in formatting
fetzu added a commit that referenced this pull request Oct 20, 2023
@jheredianet
Copy link
Author

Great job!

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

Successfully merging this pull request may close these issues.

2 participants