Replies: 1 comment 2 replies
-
I have somewhat strong feelings about this topics. e.g. there is also Perfect vs Imperfect Representation
This can lead to issues or unpredictable behavior in various scenarios when mixing integer and float and just specifying something as a "number". If I pass a 1.0 to the property it is not the same as if I pass a 1. With regards to the spec: In my opinion we took a questionable turn with the spec for the numbers when we defined that the device should perform not only input validation based on the format but actually "round/correct" wrong input. IMHO a float property that defines a 0:10:1 format should discard all input that is not 0,1,2,3,4,5,6,7,8,9,10. As it clearly defines what a valid input is. The burden of providing proper values as input is on the sender side, that is what the format description is for. --> It is not the job of a devices to correct the input coming in. We do not do this for any other property value, e.g. we do not convert a rgb color value passed to a device to xy when the device only accepts xy. Why do we round a 1.4 to a 1 in a float that only accepts numbers 0 to 10 on 1 steps intervals? A 1.4 is simply an invalid value and should be discarded. |
Beta Was this translation helpful? Give feedback.
-
Since I've started implementing Homie5 devices, I find my self doing this:
instead of:
Internally it is still an integer, it is just more permissive to the user. By using the float with step
1
, it automatically rounds, drops extraneous zeros, etc.If I were using integers all I can do is drop the value, and report an error.
Beta Was this translation helpful? Give feedback.
All reactions