Skip to content

Commit

Permalink
Added mileage info entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Anonym-tsk committed Jan 9, 2024
1 parent dbee0a9 commit 55708bd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion info.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resources:
| title | False | _string_ | The heading to display. Don't set to hide header
| dark | False | _bool_ | Dark mode
| controls | False | _list_ | List of used controls (select 3 from `arm`, `ign`, `horn`, `webasto`, `out`)
| info | False | _list_ | List of information tiles (allowed values: `balance`, `battery`, `ctemp`, `etemp`, `gps`, `fuel`)
| info | False | _list_ | List of information tiles (allowed values: `balance`, `battery`, `ctemp`, `etemp`, `gps`, `fuel`, `mileage`)
| entity_id | False | _string_ | Automatic card configuration by one entity_id (e.g. `device_tracker.audi_location`)
| device_id | False | _string_ | Automatic card configuration by device_id
| entities | False | _map_ | Map of used entities (see below)
Expand All @@ -40,6 +40,7 @@ resources:
| entities.gsm_lvl | True | _string_ | GSM signal level _sensor_ entity_id
| entities.gps | False | _string_ | GPS satellites count _sensor_ entity_id
| entities.fuel | False | _string_ | Fuel volume _sensor_ entity_id
| entities.mileage | False | _string_ | Mileage _sensor_ entity_id
| entities.hbrake | False | _string_ | Hand brake _binary_sensor_ entity_id
| entities.hood | True | _string_ | Hood _binary_sensor_ entity_id
| entities.horn | True | _string_ | Horn _button_ entity_id
Expand Down Expand Up @@ -107,6 +108,7 @@ entities:
gsm_lvl: sensor.audi_gsm_signal
gps: sensor.audi_gps_satellites
fuel: sensor.audi_fuel_volume
mileage: sensor.audi_mileage
hbrake: binary_sensor.audi_hand_brake
hood: binary_sensor.audi_hood
horn: switch.audi_horn
Expand Down
4 changes: 4 additions & 0 deletions src/starline.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
<ha-icon icon="mdi:fuel"></ha-icon>
<span class="info-i-cnt"></span>
</div>
<div class="info-i info-mileage">
<ha-icon icon="mdi:counter"></ha-icon>
<span class="info-i-cnt"></span>
</div>
</div>

<ha-icon class="gsm-lvl icon-btn" icon="mdi:signal-cellular-outline"></ha-icon>
Expand Down
7 changes: 6 additions & 1 deletion src/ts/StarlineCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {ClickPosition, Config, ConfigEntity, ConfigInfo, UIElement} from '.
export class StarlineCard extends HTMLElement {
private _config: Config = {
controls: ['arm', 'ign', 'horn', 'webasto', 'out'],
info: ['balance', 'battery', 'ctemp', 'etemp', 'gps'],
info: ['balance', 'battery', 'ctemp', 'etemp', 'gps', 'mileage'],
dark: false
};

Expand Down Expand Up @@ -42,6 +42,10 @@ export class StarlineCard extends HTMLElement {
fuel: {
element: null,
value: null
},
mileage: {
element: null,
value: null
}
};

Expand Down Expand Up @@ -121,6 +125,7 @@ export class StarlineCard extends HTMLElement {
this._info.etemp.element = this.$wrapper.querySelector<HTMLElement>('.info-engine'!);
this._info.gps.element = this.$wrapper.querySelector<HTMLElement>('.info-gps')!;
this._info.fuel.element = this.$wrapper.querySelector<HTMLElement>('.info-fuel')!;
this._info.mileage.element = this.$wrapper.querySelector<HTMLElement>('.info-mileage')!;

this._gsm_lvl.element = this.$wrapper.querySelector<HTMLElement>('.gsm-lvl')!;
this._handsfree.element = this.$wrapper.querySelector<HTMLElement>('.handsfree')!;
Expand Down
5 changes: 5 additions & 0 deletions src/ts/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,9 @@ export const STARLINE_ENTITIES: {[key in ConfigEntity]: {name: string, required:
required: false,
regex: /^binary_sensor\.(.+)_moving_ban(_[0-9]+)?$/,
},
'mileage': {
name: 'Mileage',
required: false,
regex: /^sensor\.(.+)_mileage(_[0-9]+)?$/,
},
};
4 changes: 2 additions & 2 deletions src/ts/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export type ConfigEntity = 'battery' | 'balance' | 'ctemp' | 'etemp'
| 'gps' | 'gsm_lvl' | 'fuel' | 'hbrake' | 'hood' | 'horn' | 'trunk'
| 'alarm' | 'door' | 'engine' | 'webasto' | 'out' | 'security'
| 'location' | 'handsfree' | 'neutral' | 'moving_ban';
| 'location' | 'handsfree' | 'neutral' | 'moving_ban' | 'mileage';

export type ConfigInfo = 'balance' | 'battery' | 'ctemp' | 'etemp' | 'gps' | 'fuel'; // TODO: Extract?
export type ConfigInfo = 'balance' | 'battery' | 'ctemp' | 'etemp' | 'gps' | 'fuel' | 'mileage'; // TODO: Extract?

export type ConfigControls = 'arm' | 'ign' | 'horn' | 'webasto' | 'out'; // TODO: Extract?

Expand Down

0 comments on commit 55708bd

Please sign in to comment.