Pressure units kpa -> psi
Closed this issue · 4 comments
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.
can you point me towards this so i can change km to miles (the toggle does not work)
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:
- sensor:
- name: "Range Miles"
unit_of_measurement: "mi"
state: "{{ (states('sensor.car_evinfo_battery_totalRange')|float * (5/8))|round(1)}}"
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.
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.
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).