-
Notifications
You must be signed in to change notification settings - Fork 24
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
mixed units of measurement #56
Comments
Thanks for the feedback. This a weird bug. I don't manipulate the statistics data, so what you see in the statistic sensor is the raw data from Toyota. But i will take a look at it in the next couple of days and see if I can figure something out, because it shouldn't be mixed like this. |
I was 100% sure you take the data from MyT but again: I checked on their www and it shows EVERYTHING in miles. |
I have thought about it and I think i have a solution, but i need to implement it in the python modul, so it is gonna take a couple of days. And yes, Toyota's API is a bit strange, lets just say that. 😂 |
I have all the time :-) |
Looking through the code, it seems that both average speed and max speed should also be in km/h, can you double check these for me? So i can be sure want I a can trust from Toyota and want not to trust 😅 |
🤣 🤣 |
Do you want average fuel consumed to be in MPG instead of l/100 miles? Are this the norm in England? |
I don't care - I am NOT a Brit although living here |
I have now implemented both in the underlying module. I gonna make it default to mpg when the car is using the imperial system (As i believe this is the norm in countries that uses imperial system), with an option to use L/100 miles. How does that sound? And MPG is of course in UK gallons 😄 |
it makes sense completely |
Can you please test this branch? #59 And report back over there 😃 |
can you help me please? how to install the new branch? |
https://github.com/DurgNomis-drol/ha_toyota/tree/bugfix Click this link and press the button called Extract the zip's content and copy the the folder |
Can you try again, I believe I just fixed bug you were encountering 😃 |
you mean: repeat again the download? |
Yes |
Are you sure you you are downloading this branch and not the master? Because it works on my end when i am testing it 🤔 |
It is the rights files. I not sure why i does not work |
do we have to wait for new pull from MyT? |
No, as all the conversion is done in underlying module on the fly. And after you restart when you have installed the new version, it will pull data again (And this time converting it). Can you please try to download from this again. I just pushed an update that will enable better debugging. You need to enable the debugging by adding this to your logger:
default: info
logs:
custom_components.toyota: debug
mytoyota: debug After this please post the logs only relevant to this integration from the log file 😃 |
see below (now orange) but I doubt some data is ok: 84 mpg (UK) = 3.36 l/100km - it should be around 5.4-5.6l/100km (as per simple calculation how many litres I fuelled / by km done, also the previous version of your add-on showed 5.4) |
It defaults to MPG and not L/100 miles. You can change this by going to |
that is ok, let it be MPG but 5.5l/100km is for sure NOT 84mpg but around 52mpg |
Yeah something is wrong with that conversion. Can you confirm it is the only thing not showing correctly? |
no, not only
|
First of all, i not trying to mix them. I am trying to correct this issue. Secondly, everything is shown correctly for you vehicle except the average consumption attribute. The car denotes want you are gonna see. My car reports in To shorten this, it works correctly when in L/100 miles. For you it is NOT in L/100 km. WHY the average consumption is wrong when using MPG I don't know right now. |
fine, let it be - I will stay with l/100km |
I don't get anything for my car model, there for your help is need to implement this. But if you are willing to run a script we can test the |
I am willing to help and contribute ;-) |
Create a file called import json
import asyncio
from mytoyota.client import MyT
username = "jane@doe.com"
password = "MyPassword"
client = MyT(username=username, password=password, locale="en-gb", region="europe")
async def get_information():
print("Logging in...")
await client.login()
print("Retrieving cars...")
cars = await client.get_vehicles()
for car in cars:
vehicle = await client.get_vehicle_status(car)
statistics = await client.get_driving_statistics(vehicle.vin)
print(json.dumps(statistics, indent=3))
statistics_imp = await client.get_driving_statistics(vehicle.vin, unit="imperial")
print(json.dumps(statistics_imp, indent=3))
statistics_mpg = await client.get_driving_statistics(vehicle.vin, unit="imperial_mpg")
print(json.dumps(statistics_mpg, indent=3))
loop = asyncio.get_event_loop()
loop.run_until_complete(get_information())
loop.close() Run the file like this in a terminal |
that was fast: |
You need to install the |
no private data in the output I think: |
I have found the problem i believe. I will need you to test it when i made a fix 😃 |
I am just around the corner ;-) |
Please update the module like this If it errors out when updating, wait a few minutes and try again. |
I forgot, you all so have to change |
Can i get you to do it again doing the following?
|
here you are: |
It should be working now. I have pushed an update to https://github.com/DurgNomis-drol/ha_toyota/tree/bugfix and it should now be working, please report back |
on 2nd: set to mpg - there is only 1 problem: consumption is in l/100km (all of them) - all distances are in miles - OK |
I just pushed a fix that should fix it BUT you need to understand that it is not L/100 KM but L/100 MILES instead. |
there is NO such measure in use as L/100 MILES |
Use MPG then, there's is no sense in having L/100km if all the other measurements are in miles. This is not discussion. I have worked hard to implement this feature for you and I don't have any use for it personally. Please test if the latest commit fixed your issue so I can meget this PR og fix the problem. |
Thanks for testing. I will merge the PR and release a new version very soon to HACS. Tip: If you still want L/100 km, you can make a template sensor that converts the value. 😃 |
Describe the bug
the attributes of the sensors have mixed up units: miles and km - I have RAV4 registered in UK (so Europe)
setup of my toyota is in miles
but the sensors from this integration are mixed up - sometimes km sometimes miles
To Reproduce
check the sensor: sensor.rav4_YOUR-PLATE_current_year_statistics
1: the sensor output is: amount of km in current year but the unit of measurements is "mi" - so wrong
2: some attributes are in miles some in km
example:
Average_fuel_consumed: 5.40 - that is in liters/100km
but another one is in miles:
Max_speed: 135 - that is in miles/h
unit_of_measurement: mi - miles
Average_speed: 26.4 - miles
Expected behaviour
![Screenshot 2021-09-13 at 22 27 07](https://user-images.githubusercontent.com/46562447/133159418-ded3fda5-df41-42fb-8751-57071cfa125a.jpg)
![Screenshot 2021-09-13 at 22 31 58](https://user-images.githubusercontent.com/46562447/133159429-1945b40b-2d57-472c-bcbe-764b332764c2.jpg)
the sensors should be consistent and either all in miles or all in km
I checked with MyToyota web page - all there is correct - in miles
The text was updated successfully, but these errors were encountered: