I’m working on this request but it raises a few questions. In the scale I had indicated the unit of measurement is in mg/m3 whereas for PM10 and PM2.5 it’s in µg/m3 (in my opinion it’s a choice by Dyson to avoid alarming people too much because it’s better to show 0.099 mg than 99 µg ^^).
Anyway, I see in the matterbridge-dyson-robot plugin that it indeed sends the value in µg, and that’s when I thought: how do I know it’s µg??
So I read the Matter docs and learned that it’s the MeasurementUnit attribute that is responsible for giving the unit:
And I wonder what prevents a device from sending values in mg/m3? It could perfectly do so if it correctly transmits the attribute MeasurementUnit = 3.
From there I look into Gladys to see how we transform this received value and I can’t understand at what point we check this MeasurementUnit attribute.
I have the impression that we hardcode that received PM10 and PM2.5 are necessarily in µg/m3, or there’s something I’m missing and I’d like to understand.
I had the impression that in some cases Matter imposed a fixed unit and that each manufacturer had to respect that unit when sending data, and that it was up to the consumer to handle displaying in other units.
But in the case of particles, there is indeed a unit (available in Matter.js as well, see doc here).
Do you think you could make a small PR for that?
Basically, we need to add a conversion function depending on the unit so that only µg/m3 is sent to Gladys
Either we store in the base unit and then do the conversion on the frontend: this is what we do for temperatures, for example, because on the same instance you can have one user who prefers to see °F and another who prefers °C.
Or we convert before saving the value: this is what we do for colors, for example, to have a unified color picker regardless of the brand.
In the case of fine particles, I admit I’m not really sure which types of sensors actually return the value in PPT or in PM3. Does it make sense to display these values in their base unit, or should they be converted?
I coded the conversion from the Matter unit to the Gladys unit automatically when adding Matter devices to Gladys. There are the eight units as described in the Matter docs, but honestly I doubt anyone would use the becquerel , which is why for Matter devices we can have all eight but for devices created manually I only included the three units (see previous screenshot). I’m writing the tests and I can make the PR for you
I saw that you noted « Matter: Add formaldehyde sensor » but this PR only concerns the unit conversion. I have another PR to submit regarding the addition of formaldehyde.