mvn23 / pyotgw

A library to interface with the OpenTherm Gateway through serial or network connection.
GNU General Public License v3.0
28 stars 16 forks source link

Simple sanity checks on returned values #31

Closed Mrten closed 3 years ago

Mrten commented 3 years ago

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?

Screenshot 2021-02-16 at 23 22 22

mvn23 commented 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.