netbeast / api

:rocket: Node.js wrapper for the resources Netbeast Router HTTP API.
http://netbeast.co
11 stars 7 forks source link

Temperature method in API should also allow other measurement systems #10

Open Joncy opened 8 years ago

Joncy commented 8 years ago

Considering that the whole US and UK use Farenheit degrees instead of Celsius, support for such system should be provided.

Example proposal:

temperature.get/set(value, "measuring system")

┆Issue is synchronized with this Asana task

abhiche commented 8 years ago

Just a slight enhancement to @joncy suggestion. How about setting it unit once rather than specifying it everytime: temperature.setUnits(TEMP_UNIT.CELCIUS)

jsdario commented 8 years ago

This is tricky: each device / plugin may announce the measured temperature in a different format. For that, what about implementing it through a JSON common format?

If temperature is a string, it can be interpreted as CELSIUS, but in JSON:

{ farenheit: 451 }

We do like this with colors. Then we can transform between different systems as you guys mentioned above.

abhiche commented 8 years ago

Hope I get your point. But if you provide {fahrenheit : x} as result, and if at a later stage, to switch to celcius will need the developer to refactor the code. Instead I would recommend to provide {temperature :x} as the result. Since the developer knows which unit he has set already.

jsdario commented 8 years ago

The problem is that the data is shared across the plugin ecosystem, thus is not only matter of the developer only, and the rest of plugins must understand the data and the format. Having the netbeast npm package a suite of temperature functions to change scales is not big deal, but the scale must go beside the data.

So our best options are JSON { farenheit: 451 } or strings 451Fº which I do not really like... In any case this as you pointed @abhiche must be wrapped:

{ temperature: { celsius: 36 } }
Joncy commented 8 years ago

I feel that doing it with JSON and with the implementation @jsdario last proposed would be the best way