Dielee / volvo2mqtt

Home Assistant addon for connecting AAOS Volvos
MIT License
143 stars 30 forks source link

Please add metrics for energy consumption, average speed and trip meter #237

Closed leijonatm closed 2 weeks ago

leijonatm commented 2 weeks ago

Is your feature request related to a problem? Please describe. No, it is not related to a problem.

Describe the solution you'd like I would like to receive the available statistics from the car i.e. averageEnergyConsumption, averageSpeed and tripMeter.

Describe alternatives you've considered I am unable to think of an alternative right now

Additional context the URL to visit is curl -X GET 'https://api.volvocars.com/connected-vehicle/v2/vehicles/{vin}/statistics. I tried it and works for my EX30. Thanks for your efforts!

Dielee commented 2 weeks ago

This is already supported by volvo2mqtt. If these sensors are not appearing for you, please send debug logs.

leijonatm commented 2 weeks ago

Sep 20 09:33:13 volvo2mqtt [1] - INFO: Using login from token file Sep 20 09:33:13 volvo2mqtt [1] - INFO: Refreshing credentials Sep 20 09:33:13 volvo2mqtt [1] - INFO: Using VCCAPIKEY: XXXXXXXXX Sep 20 09:33:13 volvo2mqtt [1] - INFO: Vin: [''] found! Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Battery Charge Level is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Battery Capacity is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Electric Range is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Estimated Charging Time is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Charging System Status is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Charging Connection Status is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Estimated Charging Finish Time is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Odometer is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Last Data Update is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Active schedules is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Window Front Left is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Window Front Right is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Window Rear Left is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Window Rear Right is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Door Front Left is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Door Front Right is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Door Rear Left is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Door Rear Right is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Tailgate is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Engine Hood is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Tank Lid is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Sunroof is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Air Conditioning is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Lock state is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Force Update Data is supported by your vehicle. Sep 20 09:33:14 volvo2mqtt [1] - INFO: Success! Location is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! Tire Front Left is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! Tire Front Right is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! Tire Rear Left is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! Tire Rear Right is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! Engine State is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Failed, Fuel Level is unfortunately not supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Failed, Average Fuel Consumption is unfortunately not supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Failed, Average Energy Consumption is unfortunately not supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Failed, Distance to Empty Tank is unfortunately not supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! Distance to Empty Battery is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Failed, Average Speed is unfortunately not supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Failed, Hours to Service is unfortunately not supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! Distance to Service is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! Time to Service is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! Service warning status is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! Washer Fluid Level warning is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! API Backend status is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Success! Update Interval is supported by your vehicle. Sep 20 09:33:15 volvo2mqtt [1] - INFO: Failed, Warnings is unfortunately not supported by your vehicle. Sep 20 09:33:17 volvo2mqtt [1] - INFO: Sending mqtt update... Sep 20 09:33:18 volvo2mqtt [1] - INFO: Mqtt update done. Next run in 300 seconds.

Indeed logs say is not supported although I am able to curl it from the URL I sent you

Dielee commented 2 weeks ago

So, as said, enable debug and send some logs

leijonatm commented 2 weeks ago

Sorry, my bad So it seems to get the info but thinks it fails

Sep 20 09:40:17 volvo2mqtt [1] - INFO: Failed, Fuel Level is unfortunately not supported by your vehicle. Sep 20 09:40:17 volvo2mqtt [1] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/statistics Sep 20 09:40:17 volvo2mqtt [1] - DEBUG: Response status code: 200 Sep 20 09:40:17 volvo2mqtt [1] - DEBUG: { "data" : { "averageEnergyConsumptionAutomatic" : { "value" : 18.700000762939453, "unit" : "kWh/100km", "timestamp" : "2024-09-20T06:40:17.500Z" }, "averageSpeedAutomatic" : { "value" : 46, "unit" : "km/h", "timestamp" : "2024-09-20T05:45:20.174Z" }, "tripMeterManual" : { "value" : 1873.4, "unit" : "km", "timestamp" : "2024-09-20T05:45:20.174Z" }, "tripMeterAutomatic" : { "value" : 28.2, "unit" : "km", "timestamp" : "2024-09-20T05:45:20.174Z" }, "distanceToEmptyBattery" : { "value" : 252, "unit" : "km", "timestamp" : "2024-09-20T05:45:20.174Z" } } }

Dielee commented 2 weeks ago

Would you please upload your complete log ?

Dielee commented 2 weeks ago

Ha, they chaned the naming... The "old" data key where average_speed for ex30 it is averageSpeedAutomatic

leijonatm commented 2 weeks ago

debug.log see attached

Dielee commented 2 weeks ago

Please try v1.10.0

leijonatm commented 2 weeks ago

Still getting failure to read, I see the new version in the logs

leijonatm commented 2 weeks ago

I could be wrong , I see _Failed, Fuel Level is unfortunately not supported by your vehicle. Failed, Average Fuel Consumption is unfortunately not supported by your vehicle_ but I am getting the values

Dielee commented 2 weeks ago

No, Fuel Level and Average Fuel isn't Energy level and Average Energy Consumption, so everything works as expected.

leijonatm commented 2 weeks ago

Great, thanks!!