Quarantine has got me ready for a new project. I’m pretty experienced with RPI, python and restful apis. Not so much with OpenHAB. My home automation setup is strictly homebrew, so i was wondering how will I be able to send api requests to change temperature to hestia pi, or is MQTT the only way to control it? I’ve had alot of success with zigbee through deconz, but no experience with MQTT.
Thanks for any insight,
MQTT would be easiest since pretty much everything is already set up for you. The HestiaPi even comes with it’s own MQTT broker so all you would need to do is figure out an MQTT client library, which is pretty easy (I’ve used Paho in Python before and it’s super simple. You can see that at GitHub - rkoshak/sensorReporter: A python based service that receives sensor inputs and publishes them over REST (should work with any API but mainly tested with openHAB) or MQTT. It can also receive commands and perform an action (e.g. set a GPIO pin to HIGH). It currently supports Bluetooth, GPIO on Raspberry Pi, Amazon Dash buttons, command line scripts, and Roku IP address discovery. (look in the mqttCommunicator.py file).
But it’s not your only option. OH has a pretty extensive REST API that you can use. It has a swagger page that provides an interactive set of docs showing all the REST API calls and lets you make the calls right there in the browser.
Bring up http://hestiapi:8080 (or IP address) and select PaperUI.
Click on “Add-ons” and then the “User Interfaces” tab.
At the bottom of the list you will find “REST Documentation”. Click on “Install”.
Occasionally PaperUI may get stuck and not see that the add-on has been installed. If the spinning circle continues for a long time refresh the page and it will show “Uninstall” instead of “Install”. It can be helpful to tail /var/log/openhab2/openhab.log or log into the karaf console to watch the logs to see what’s going on. You can also just watch the dashboard and when it’s done a new entry will appear.
Once it’s installed, return to the dashboard at http://hestiapi:8080. There will be a new entry called REST API.
You will mainly care about updating and commanding Items so click on “items” in the list. Click on the row corresponding with what you want to do and it will open up into a form you can fill out and submit. Once submitted you will get the result and it will tell you the curl command to make the same request. The following screen shots will show commanding the TempSetpoint Item to 70 which is what you would want to do to change the target heating/cooling temp.
An third approach is using ssh and issuing commands in the Karaf console itself. I won’t go into details on that one, more information can be found at The Console | openHAB. The default username is openhab and the default password is habopen. You might need to change the settings to allow connections outside of localhost if you go down this path. Instructions for all of that stuff is at the link above.
Very nice information @rlkoshak!
I was also thinking on how to connect a GNOME application in my kitchen computer, that is running the main OH instance, to show a panel similar to HestiaPi’s
I was also interested in subscribing to temperature, humidity, etc… updates.
An obvious approach was using
mosquitto_sub command with HestiaPi’s MQTT instance, but the main OH is already subscribed to those topics. So I would have 2 connections from the same machine, overloading HestiaPi’s MQTT server.
I was wondering if I could subscribe somehow to OH item changes, besides sending commands.
You are an angel, that’s exactly what i was looking for. It’s basically a request constructor.
Mosquitto and MQTT are very light weight. Even on a constrained machine like an RPi 0 there should not be much notice if any if you added another connection. If using MQTT makes the most sense for your implementation I wouldn’t worry about the added load. I doubt you would be able to even tell the difference by looking at htop in terms of CPU or memory usage.
You can but I don’t know as much about that or how to use it. Much like the touch screen UI on the HestiaPi talks to MQTT using a websocket, openHAB provides a websocket where all the events that take place on the event bus are received. This is how BasicUI, HABPanel and all the rest of the UIs receive updates when Items change state. Unfortunately, beyond that I’m not going to be much help. I know that it’s possible but have no idea how to do it.
That’s one reason why I do recommend MQTT for stuff like this. Not only is it super light weight but you can very easily, in just a few lines of code, set up OH to pub/sub all of it’s Items in a standardized way so that anything can see and interact with just about anything you have in OH. See https://community.openhab.org/t/mqtt-2-5-event-bus/76938. I have it pretty high on my list to create a JSONDB set of Rules to do this in addition to the Rules DSL and Python versions at that link.
Thank you for the information @rlkoshak
I had concerns because some interference in my wifi signals, but I will give MQTT I try
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.