tsathishkumar / MySController-rs

Controller for MySensors, exposes WoT APIs for the sensors. It supports OTA firmware updates, and also acts as proxy for all requests.
GNU Affero General Public License v3.0
20 stars 9 forks source link

Is UnitPrefix implemented in the best way? #33

Open flatsiedatsie opened 6 years ago

flatsiedatsie commented 6 years ago

I don't know what I'm talking about, but currently the "UnitPrefix" data type seems a bit strange. Right now it can be a property of a thing. This results in something like "pressure" being displayed as a separate string in the interface (in the cases that a MySensors device actually sends a prefix along)

When I looked at set.rs I noticed that there actually is a way to set the pre/postfix of a device.

    pub fn unit(&self) -> &'static str {
        match *self {
            SetReqType::Temp => "celsius",
            SetReqType::Percentage => "%",
            _ => "",
        }
    }

Shouldn't the UnitPrefix data (if MySensors sends it at all) end up in that list?

From my limited understanding, for a device that measures barometric pressure it should send the string "mBar" as the V_UNIT_PREFIX.

V_UNIT_PREFIX is only sent once I think, when the device starts. It has the same child ID as the actual sensor data that will be coming in after it.

flatsiedatsie commented 6 years ago

(totally not a priority I would say, things will work just fine if this whole V_UNIT_PREFIX thing is not implemented at all.)

tsathishkumar commented 6 years ago

This is interesting idea. For this the controller needs to store the unit prefix of sensor while it is presented and that has to be exposed in WoT api. I'll think about how to handle it better.