-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
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.
Thank you very much for the fix @jheredianet 😃 !
I will add a commit with my suggested fixes and merge this to main.
🚀
teslamate_mqtt2abrp.py
Outdated
@@ -28,6 +28,7 @@ | |||
import os | |||
import paho.mqtt.client as mqtt | |||
import requests | |||
import json |
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.
We don't need to import json here, our only use of json ("response.json()") is part of request imported above.
teslamate_mqtt2abrp.py
Outdated
@@ -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: |
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.
Simple formatting fix to keep in line with the rest.
teslamate_mqtt2abrp.py
Outdated
msgDetails = "Data object to send:" | ||
print(msgDetails, data) |
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.
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.
teslamate_mqtt2abrp.py
Outdated
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"]) |
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.
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
~ Changes in logging/print of API request success/error ~ Fixes in formatting
Great job! |
Added a control to estimate power con AC charging