Lately I’ve started to get annoyed with Openhab’s rules and the way it deals with items and numbers, such as having to do things like the following, just to convert the temperature from the ESP board.
var newTemp1 = LivingRoomTemp0.state as DecimalType postUpdate(LivingRoomTemp1, (LivingRoomTemp0.state as DecimalType) * 0.0625)
Therefore I’ve been looking at different options. For now I’m going to continue to use Openhab as the gui for my home automation system (as I’ve yet to find something that’s easier to use that still has similar interface), but I’m looking at different backends.
I’ve looked at node-red but couldn’t really figure out how to do quite simple things like compare if the current temperature is higher than my set temperature, so that’s out of the question for now.
I also looked at node.js, but not really in the mood to learn a whole new language!
So I looked at Python. I’ve done a bit of python in the past, and looking at other examples, it seemed like it might be a good way to go.
There’s also a really good Python library for MQTT called paho, which seems quite easy to use for what I’m wanting to do right now.
So here’s my current setup that I’m experimenting with:
- Send all data from the ESP boards via MQTT (no change there)
- The ESP temperature values are received via Python (not Openhab!) and converted to their correct value by * 0.0625
- This new value is then sent via MQTT, which is picked up by Openhab
So far this seems to work much better!
I’ve also created a simple thermostat test where I’ve created a simple button which represents the boiler and have set the desired temperature in Openhab. This desired temperature is sent to Python via mqtt which then calculates if the boiler needs to be switched on or off. The value for the boiler (“ON” or “OFF”) is then sent out via mqtt.
The above seems to be working well, so I’m going to experiment more with this setup and then at it to my github project folder.