wubbl0rz / FiatChamp

FIAT (uconnect) Home Assistant Addon 🚗
https://github.com/wubbl0rz/FiatChamp
MIT License
91 stars 17 forks source link

Pressure units kpa -> psi #41

Closed cliffbry closed 1 year ago

cliffbry commented 1 year ago

I note that there is a flag to switch units from km to miles. Is there a way to switch pressure units from kpa to psi? I am a novice user of homeassistant but an experienced (old!) programmer so any help would be appreciated, For the record my vehicle is a Jeep.

EDIT

Never mind, I discovered templates so can modify the values myself.

bigstevehardy commented 1 year ago

can you point me towards this so i can change km to miles (the toggle does not work)

cliffbry commented 1 year ago

Sure

I added the following code to configuration.yaml in order to convert totalRange on my Jeep (battery miles+petrol miles) using the existing entity car_evinfo_battery_totalRange.

template:

This creates a new 'entity; (not sure exactly what it should be called [sensor?]) in the drop down list when I create a card with the km value converted to miles (km*5/8) and that value is rounded to 1 decimal place.

I do the same for the tyre pressures by multiplying them by 0.1450377 (kPa to PSI) and rounding to 0 decimal places.

I'm now learning how to change icon colours according to state of a variable.

EDIT

The webpage appeared to have kindly formatted what I typed but you should be able to work out the proper formatting. There are some examples on the web in any case.

wubbl0rz commented 1 year ago

the automatic unit converting like km -> miles is a bit buggy i guess. i think the reason is that it only works where the fiat api explicitly returns a unit for the value. because otherwise its unknown in which unit the value is retrieved. could be that "totalRange" has no unit attached to it. some parts are a bit "hot glued" but idk how to improve this because the uconnect apis have no public documentation and i can only reverse engineer it from the fiat app and the way fiat does things is confusing sometimes 🥴 when i start to work again on fiatchamp i can add unit conversion for pressure and fix some buggy range units. until then i think its better to use a template sensor.

mattdevo1 commented 7 months ago

I know this is closed, but I just wanted to add +1 for enabling the conversion of kpa to psi.

For now, I just created a template sensor, but it would be great if it would change automatically if we switch the flag to miles (or more specifically, maybe there should be a flag for US/Imperial as some countries use some metric measures but miles for distance).