Closed Mrten closed 3 years ago
While it would be possible, I'm not convinced that it's a good idea. pyotgw
is meant to be a python layer to interact with the gateway, so we should just deal with connection handling and pass all values on exactly as we receive them from the gateway. We only perform some input checks in the command functions, but this is done with the sole purpose of avoiding to send a command to the gateway which we know is going to fail.
As I see it, there would be two ways to handle sanity checks on values from the gateway. We either discard them or clip them to the closest "valid" value, in both cases either with or without a warning. In either case, if we don't log a warning we are hiding a possible real issue with the hardware or the manufacturer's implementation. If we do log them then we may cause other undesired side effects as explained in my next point:
It is well known that not all (read: almost none) of the manufacturers stick with the protocol. By implementing something like this we may generate a lot of false warnings and/or invalid readings in case a manufacturer decides to use certain messages for purposes other than specified in the protocol.
Finally, as you mentioned yourself, these values indicate a broken gateway. We can (and try to) handle most connection-related issues, but working around all possible cases of broken hardware is not doable.
I'm closing this for now. Please feel free to comment with some counterarguments if you disagree with the above.
You know that you have a buggy gateway when you get negative values for the waterpressure. Would it be doable to have simple sanity checks on the presented values; like percentages have to be 0-100, and pressure 0-5 bar?