Accessing Raspberry web server concurrently with OH2

Tags: #<Tag:0x00007f3872b12fe0>

Hi,

Is it possible to access the default Raspberry web server after openhabian installation?
I need to use a custom web interface to automate the configuration of my home made sensors through a menu that generates mqtt commands via the same raspberry broker that is running OH2.
Is it a way to access the default raspberry web server or should I install a new one?
I did install the Nginx reverse proxy together with apach2, is it a way to activate this one?
One other possibility I see is creating an Habpanel widget.
What should be the best / simplest solution?
Thanks in advance
Robert

I think the solution is the openhab static page

Hi,

The key is understanding what you are trying to do via MQTT, and if there is a way of achieving it directly via OpenHAB without the need for external web access?

The core function of OpenHAB is to give a single interface (web, rule code, REST, etc) to different devices including via MQTT.

To turn a Sonoff Basic running Tasmota on or off via MQTT, I use a ‘standard’ ON/OFF button on a ‘standard’ OpenHAB sitemap.

With a little more rule code, I use the same ‘standard’ OpenHAB GUI to check if MQTT devices are reachable, query firmware, or even trigger firmware upgrades. The web GUI triggers code in a rule to send commands out via MQTT - all without a separate webserver.

The MQTT binding (bear in mind v1 is rather different from v2 in architecture), gives access to any MQTT topic by mapping it to an OpenHAB Thing with Channels, allowing you to then define native Items like a Switch, String or Item. You can then write abstracted rule code to act when MQTT publish sets a value, which the binding subscribes, to and changes the state of a corresponding OpenHAB Item.

The point of this mapping is to give an abstracted model of any device, be it linked via MQTT, Z-Wave, web sockets, etc. Using Python or a shell script with ‘mosquitto_sub’ is quicker and more direct - but doesn’t scale across many different device types and protocols.

For a quick hack, you can even create a Switch Item in OpenHAB and have it shell-out to a ‘mosquitto_pub’ command, but that completely ignores the power of OpenHAB bindings.

Raw access to MQTT is normally only needed for debug - such as a Raspbian command line or a client like:

Thanks for your answers.
Maybe I was not clear enough. I perfectly manage MQTT states and commands via OH1/2.
However my “Motes” parameters are configured via a RF Coordinator/Gateway which reports state and basic ON/OFF commands using MQTT to the OH broker MQTT binding on one hand and with RF “Home made messages” with the Motes at the other hand. Typically Mote specific configurations parameters ( I have at least hundred of them to cope wit the different types of sensors) are also mapped to MQTT structured messages relayed by the Coordinator via RF to the Motes.
I currently sent these configuration commands from the MQTT.fx application scripts or from Raspberry MQTT Client python scripts command line interface (Raspberry which is also running OH2).

I am old school, so things like WEB Server, HTML, JavaScripts are Chinese for me, but anyway it is time to learn.
So my goal is to now make the configuration interface little bit more professional and I was thinking to:

  1. Customize a WEB server interface with the configuration options; so my question was, can I or should I install a WEB server on top of OH.
    After doing some search I have found that OH2 static pages may be used for that purpose
  2. I still have some doubt about HABpanel usage, and using “intelligent” rules will not covers all the needs, so for the time being I will go for
  3. Learning HTML/JavaScripts and probably Node.js to implement my custom WEB interface
    and now … thanks Tomas perhaps
  4. The MQTT Exploration APP , that I will now test to see if it is the magic solution

Thanks for your ideas, and please comments because I still have a lot to learn.
Robert

Hi tramlaan,

I’m an old Unix Greybeard so recognise that sometimes you just want to keep what you have and know works, rather than re-implement using a different tool.

Here are a few links and ideas which might help…

As mentioned, I’ve used the ‘standard’ OH user interface elements (such as a switch or string) as a means of interacting with custom code (e.g. create a dummy Switch item, and a rule triggered when it changes state to shell out to a Bash script or Python using executeCommandLine("/path/script" + Variable)). This half-and-half approach might get you a prototype faster than writing a fully custom Node or JS GUI. It also allows custom code to be triggered and display results from all OpenHAB interfaces including the mobile apps.

I’ve not tried creating a custom GUI, but for instance, you can draw a custom control panel in SVG and have it automatically update using OH variables:

SVG might be more customisable than HABpanel, but easier than full-custom JavaScript.

There is a way to use native Python in OpenHAB rules, rather than using eXtend - search for JSR223 and Jython.

As mentioned, you can interact directly with MQTT without using a shell command from a rule - here’s an example I use to update Tasmota devices which might be of use:

All the best,

James