Constants for properties
aivus opened this issue · 3 comments
Now we have constants like Gree.VALUE.power.on
which is equal to 1, but during polling process we are getting parameters in string representations.
For example
client.on('update', (updatedProperties, properties) => {
...
const value = updatedProperties[Gree.PROPERTY.power] === 'on';
...
});
For now we need to use on
string value.
Do we need to add constants for such values, what do you think?
Hi Ilya, you're right. This isn't consistent to have 1/0 and 'on'/'off' while getting and setting properties if I understand the issue right. This seems to be a bug.
I think this could be easily fixed by making constants to be 'on'/'off'. This should work by default since PropertyTransformer
expects exactly those string values.
But in fact I would like to make it configurable, since some users would like to get/set the original vendor 1/0 and their original property names like SetTem: 25
instead of temperature: 25
or WdSpd:2
instead of fanSpeed:mediumLow
for some reasons.
I'm on a vacation right now but I will get to this in a week.
Thanks for feedback.
This has to be added since v1.2.3.
Thanks.