Skip to content

Commit

Permalink
Merge pull request #129 from BigThunderSR/update-device-classes-and-f…
Browse files Browse the repository at this point in the history
…ix-litres

Updated some state classes and changed "lit" to "L"
  • Loading branch information
BigThunderSR authored Mar 1, 2024
2 parents d66e043 + 322993f commit 818aabc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
15 changes: 11 additions & 4 deletions src/measurement.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ class Measurement {
case 'Volts':
return 'V';
case 'l':
return 'lit';
return 'L';
case 'L':
return 'lit';
return 'L';
//case 'l':
//return 'lit';
//case 'L':
// return 'lit';
// these are states
case 'Stat':
case 'N/A':
Expand Down Expand Up @@ -79,8 +83,11 @@ class Measurement {
// km/L = (1.609344 / 3.785411784) * MPG
value = _.round(value / (1.609344 / 3.785411784), 1);
break;
case 'lit':
case 'L':
value = _.round(value / 3.785411784, 1);
//case 'lit':
// value = _.round(value / 3.785411784, 1);

break;
}
return value;
Expand All @@ -103,7 +110,7 @@ class Measurement {
return 'mpg(e)';
case 'km/l':
return 'mpg';
case 'lit':
case 'L':
return 'gal';
default:
return unit;
Expand Down
23 changes: 20 additions & 3 deletions src/mqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,30 @@ class MQTT {
case 'PRIORITY CHARGE INDICATOR': // FALSE/TRUE
case 'PRIORITY CHARGE STATUS': // NOT_ACTIVE/ACTIVE
return this.mapBinarySensorConfigPayload(diag, diagEl);
// no device class, camel case name
// new device class, camel case name
case 'GAS RANGE':
case 'GAS RANGE MI':
case 'EV RANGE':
case 'EV RANGE MI':
case 'ODOMETER':
case 'ODOMETER MI':
case 'LAST TRIP TOTAL DISTANCE':
case 'LAST TRIP TOTAL DISTANCE MI':
return this.mapSensorConfigPayload(diag, diagEl, 'distance');
case 'LIFETIME FUEL USED':
case 'LIFETIME FUEL USED GAL':
return this.mapSensorConfigPayload(diag, diagEl, 'volume');
case 'FUEL AMOUNT':
case 'FUEL AMOUNT GAL':
case 'FUEL CAPACITY':
case 'FUEL CAPACITY GAL':
case 'FUEL LEVEL IN GAL':
case 'FUEL LEVEL IN GAL GAL':
return this.mapSensorConfigPayload(diag, diagEl, 'volume_storage');
// no device class, camel case name
case 'LAST TRIP ELECTRIC ECON':
case 'LIFETIME MPGE':
case 'CHARGER POWER LEVEL':
case 'LIFETIME MPGE':
case 'CHARGER POWER LEVEL':
default:
return this.mapSensorConfigPayload(diag, diagEl);
}
Expand Down

0 comments on commit 818aabc

Please sign in to comment.