[TOPIC UNIQUE] Units of measurement

Hello

I’m preparing a PR to add missing units in Gladys, knowing that many users use node-red to integrate various equipment (and therefore various units of measurement), I’m fishing for needs.

@pierre-gilles I’m taking the opportunity to reorganize by unit type for more clarity if you’re okay

The planned additions:

  • VA - VAR - MWh - mA (Energy/Power) => in anticipation of the lixee TIC
  • km - m (Distance)
  • € $ (Currency)
  • bar psi (Pressure)
  • Kelvin (Temperature)
  • l, ml, m3 (Volume)
  • ° (Angle)
const DEVICE_FEATURE_UNITS = {
  // Temperature units
  CELSIUS: 'celsius',
  FAHRENHEIT: 'fahrenheit',
  KELVIN: 'kelvin',
  // Percentage units
  PERCENT: 'percent',
  // Pressure units
  PASCAL: 'pascal',
  HECTO_PASCAL: 'hPa',
  BAR: 'bar',
  PSI: 'psi',
  // Light units
  LUX: 'lux',
  // Concentration units
  PPM: 'ppm',
  // Power units
  WATT: 'watt',
  KILOWATT: 'kilowatt',
  WATT_HOUR: 'watt-hour',
  KILOWATT_HOUR: 'kilowatt-hour',
  MEGAWATT_HOUR: 'megawatt-hour',
  AMPERE: 'ampere',
  MILLI_AMPERE: 'milliampere',
  MILLI_VOLT: 'millivolt',
  VOLT: 'volt',
  VOLT_AMPERE: 'volt-ampere',
  VOLT_AMPERE_REACTIVE: 'volt-ampere-reactive',
  // Length units
  MM: 'mm',
  CM: 'cm',
  M: 'm',
  KM: 'km',
  // Degree units
  DEGREE: 'degree',
  // Volume units
  LITER: 'liter',
  MILLILITER: 'milliliter',
  CUBIC_METER: 'cubicmeter',
  // Currency units
  EURO: 'euro',
  DOLLAR: 'dollar',
  // Speed units
  METER_PER_SECOND: 'meter-per-second',
  KILOMETER_PER_HOUR: 'kilometer-per-hour',
  // Precipitation units
  MILLIMETER_PER_HOUR: 'millimeter-per-hour',
  // UV Units
  UV_INDEX: 'uv-index',
};

I’m thinking in particular of @Einstein8854, do you have any needs for your weather station? Speed, for example?

hello @VonOx,
thanks for thinking of me.
in the lists you present it seems quite complete:
-hPa (rather than Pa I think) for the station pressure
-cm (for height measurements of tank, pond, pond level…) and even mm (for rain measurement)
-w and kW for the meter but also for electrical production measurements (yes I try to produce my electricity: PV but also mini wind)
-A and V for the same reason
-UV measures the UV level of the station
-w/m²: my station measures the light power…
% for humidity
°c for temperature
l, m3
and euro as you put it it’s true that it makes sense
but also ° (not temperature but angle for the compass), and even n-s-e W because the ideal would be a conversion of degrees into orientation
but also being able to plan the implementation of the date and time in order to timestamp the displayed data on the screen…
if you need help, testing …(I have set up a dev environment on my windows with a wsl for ubuntu, docker, nodejs, vsc.. but I haven’t used it yet)

Most of the units you list already exist

Are UV the index you’re referring to?

W/m² is solar irradiance according to Wikipedia

Yes, the UV index is that, it’s an index that apparently ranges from 0 to 7 or 8,
W/m² is also used for solar panels (thermal and photovoltaic)

And for the angular degrees, to convert to N E S W, does that exist too? Weather Underground via the API transmits degrees

Here is a data stream from the API below

09/03/2022, 11:55:00
node: wug output
msg.payload: Object
object
observations: array[1]
0: object
stationID: "IPUCEU1"
obsTimeUtc: "2022-03-09T10:52:11Z"
obsTimeLocal: "2022-03-09 11:52:11"
neighborhood: "Puceul"
softwareType: "EasyWeatherV1.5.9"
country: "FR"
solarRadiation: 55.9
lon: -1.609633
realtimeFrequency: null
epoch: 1646823131
lat: 47.531745
uv: 0
winddir: 218
humidity: 76
qcStatus: 1
metric: object
temp: 12
heatIndex: 12
dewpt: 8
windChill: 12
windSpeed: 4
windGust: 5
pressure: 1000.14
precipRate: 0
precipTotal: 0
elev: 67

No, it doesn’t exist, to develop, but it’s not a unit of measurement.

Yes, you are right that it is not a unit, just like uv,
but for the common people and visually, or in everyday language, this is what is used.
or maybe in nodered a small conversion function to send a flow via mqtt in the form s, e, w…
but in this case, gladys must be able to restore the info.
for a first help or contribution to gladys, I would be happy to try to create the script on the nodered side if it can help you…

Great! Good idea :slight_smile:

No problem, you’re right it’s clearer :slight_smile:

I think we indeed need speed measurement units:

  • km/h
  • m/s
  • MPH

Surely there are others I don’t know

Just a clarification for this PR: units alone are not enough to be used in Gladys afterwards.

You need to create the right categories/types of features, and map these categories to the units.

So in my opinion, there is a bit of reflection needed for each category/type of features…

Of course :grinning_face_with_smiling_eyes:

I will also propose a mapping here.

Hi @VonOx,
When we worked on Netatmo, I added a lot of missing units as well as others I had in mind with mapping. If you’re interested, I can share the files with you. Let me know and I’ll try to send them to you tomorrow. Everything was functional and tested… but it was a year ago ^^

Yes go ahead if it’s missing

Hello terdious!
As you speak Netatmo, I allow myself to ask you where the subject is at?
I admit that the thermostat head part is missing compared to the v3!

Good evening,
@VonOx,
Following our exchange about units, based on the extraction via Weatherunderground API and the small NodeRed function that allows me to integrate data from my station via MQTT into Gladys, I have therefore completed the NodeRed function to obtain literal information of type n, s, e, w… instead of ° to be more user-friendly. So, I am missing in the unknown device or another a feature that allows me to retrieve Alpha information and not numerical, and therefore in this case no min-max…

Thank you

The PR => https://github.com/GladysAssistant/Gladys/pull/1479

@Terdious I looked at the netatmo branch of @damalgos but I didn’t find any additional units.

Hello @VonOx,

Indeed, it had been removed from the PR to integrate it into a different PR that hasn’t been done yet (to separate it into small PRs as recommended).
I just took a look at your PR, I think everything is there for now. Would it be possible for you to also add the \"watt-hour\": \"Watt hour (Wh)\" for energy. Being in three-phase, my hourly production per phase varies between 0 and 900 Wh ^^.

Thanks in advance for this PR!!

Yes I’ll add that no problem

Edit: It’s done

@pierre-gilles if you’ve got time this week to take a look at this PR, there are quite a few new units and it’ll make people happy about the dashboards :slight_smile:

@VonOx review done, great work — I don’t have much to add, just naming details :slight_smile:

I’m just following up on @Terdious’s feedback, I don’t think it’s a good idea to include heating in this PR. I believe the idea of this PR was for it to be merged now; if we start adding the heating discussion, we’ll add 2 months to the PR, not sure that’s what we want.

That said, if you want to tackle heating afterwards, absolutely, but in a separate PR so as not to block this awesome PR :slight_smile: