michaelwoods / onstar2mqtt

OnStarJS wrapper for MQTT
MIT License
106 stars 38 forks source link

Fuel Level In Gallons is returning Liters #178

Open Quiqui64 opened 2 years ago

Quiqui64 commented 2 years ago

First of all, thank you for this wrapper. Here are my results from MQTT Explorer. Notice that "fuel_amount" and "fuel_level_in_gal" have the same result.

Topic = homeassistant/sensor/1GNSCAKC3Hxxxxxxxx/fuel_tank_info/state { "fuel_amount": 23.04, "fuel_capacity": 99.75, "fuel_level": 23.1, "fuel_level_in_gal": 23.04 }

Topic = homeassistant/sensor/1GNSCAKC3Hxxxxxxxx/fuel_level_in_gal/config { "name": "Fuel Level In Gal", "device": { "identifiers": [ "1GNSCAKC3Hxxxxxxxx" ], "manufacturer": "Chevrolet", "model": "2017", "name": "2017 Chevrolet Tahoe" }, "availability_topic": "homeassistant/GNSCAKC3Hxxxxxxxx/available", "payload_available": "true", "payload_not_available": "false", "state_topic": "homeassistant/sensor/GNSCAKC3Hxxxxxxxx/fuel_tank_info/state", "value_template": "{{ value_json.fuel_level_in_gal }}", "unique_id": "GNSCAKC3Hxxxxxxxx-fuel-level-in-gal", "unit_of_measurement": "L" } I believe "unit_of_measurement": should be "G"

Thank You, Jason

BennyDaBee commented 2 years ago

Hello,

How are you running this? Docker or NPM?

Quiqui64 commented 2 years ago

Docker, but now i'm having the same issue as https://github.com/michaelwoods/onstar2mqtt/issues/190

Thanks

BennyDaBee commented 2 years ago

I have identified a fix in #190, but it does require moving off of docker, and my security approach for it is not great. I think I need to work with Michael on creating a gas branch as I think this issue is with some of the variables in the measurement conversion.

fragglehunter commented 2 years ago

I created a separate sensor template to convert liters to gallons and it seems to be accurate for my truck:

- platform: template
  sensors:
    trailboss_gas_gallons_state:
      friendly_name: "Gallons Remaining" 
      value_template: >
        {% set tbgp = states('sensor.fuel_level_in_gal') %}
        {% set value = tbgp | multiply(1) / 3.785  %} 
        {{ value | round(1) }}
      unit_of_measurement: "Gallons"
      icon_template: >-
        {% if is_state('sensor.trailboss_gas_gallons_state', '0') %}
           mdi:help-rhombus
        {% else %}
          mdi:speedometer
        {% endif %}
BigThunderSR commented 1 year ago

My proposed changes in the above PR should work with all types of vehicles (Electric/Gas/Hybrid) as long as GM doesn't change the type of the units that are reported by the vehicle.

michaelwoods commented 1 year ago

Please try the latest build, thanks to @BigThunderSR.