Can I integrate a file selector in Openhab?

Hello!

So this is a slightly off topic question and as I cannot find anything related to it on the community so I would not be surprised if it cannot be implemented.

So what I plan to do is not for home automation but another sophisticated application. The basic idea is:

If I press a button on the openhab user interface (Lets say the basic UI) then a file explorer window should open and then I should be able to select a file from my computer and this file path should be forwarded to a script (Lets say a python script).

The other steps are involved within the python script so I will not blast you with the details regarding that. So the basic problem or the question is that can such a system be implemented or integrated with the OPENHAB?

Thank you!

1 Like

I would think launching a file explorer is trivial. Getting back the file you click on; worse.

How about this approach:
Write a python script that monitors the files in your folder, and POST them to Text items in openHAB via REST.
Then you can present the options in Basic UI, and send the filename selected to your python script.

OR (on second though)
The file you click on/select in the file explorer could call you python script directly and kill the explorer.

Nothing like this has been implemented to my knowledge.

In BasicUI you could write your own html files and place them into $OH_CONF/html and then load the page into your sitemap using a Webview element. You could probably implement something natively in HABPanel as a widget. But as Ole says, the file browser probably won’t be all that hard. The hard part is moving the file to a place where the Python script can execute it.

One possibility would be to create a separate web app using python and a lightweight web server then link to it from within OH. This way you can create any buttons you like that can run anything you want on the backend.

Or maybe, you can create a buttton on an OH page to call into a webservice using python/flask for example?? Again, you would get full control over the backend.

1 Like