Closed kobbejager closed 6 years ago
It does work on python2, still better than on python3. On python3 there remains an interpretation issue for true and false, which has probably something to do with str <-> byte conversions. This is new stuff for me, and I'm kind of struggling with it.
You should probably not merge my code until I have this remaining issue ironed out and have tested it thoroughly on both py2 and py3.
OK, please let me know when you’re done
I think it's ready. Tested with my otgw directly connected (via usb) with both python 2.7 and 3.5.
Besides python 3 compatibility, I slightly changed how this script interprets the set-values received by mqtt, to more closely follow the description of the otgw serial commands
if room setpoint temperature override (temporary or constant) cannot be converted to a float value, 0 is sent to the otgw. This disables this setpoint override.
if the outside temperature override cannot be converted to a float value, 99 is sent to the otgw, which effectively disables the temperature override.
if the hot water temperature setting cannot be converted to a float value, 60 is sent to the otgw. I suppose this is more or less the default value?
if the central heating enable value can be interpreted as false, central heating will be disabled. In all other cases, it will be enabled. (Before it was the other way around)
if the hot water enable value can be interpreted as false, HW will be disabled (override). If it can be interpreted as true, HW will be enabled (override). In all other cases 'T' will be sent to the otgw, which will remove the override and give back the control to the thermostat.
Looks good! I think there may be some room for improvement by making the float conversions a bit more EAFP, but as this already works I'm not going to put much time into it.
This looks pretty good. Have you tested it in Python 2.7?