Creating customized dashboard and connect items via API?

I would like to have a customized dashboard. But in order to have that and “escape” the OH look, inside OH it’s proving not that easy.

So, I was thinking: since I’m a programmer, what if I just developed a webpage in my server, working in PHP to connect to my MySQL persist DB and then connect to OH API to get and post data, being able to also work with JS to animate things and relying on the old CSS to make things pretty?

Is this a “too much effort for the result” thing I’m thinking? Can we also have design autonomy with OH?

One other thing I’ve thought about was creating customized widgets for OH for those cases where I would prefer to have something nicer.

What your take on this?

It would be for me, but your mileage may vary. My feeling is that most other’s feel the same way or we would already see such 3rd party UIs around. Ultimately, however, only you can really answer whether is is worth your time.

There is really quite a bit that you can already do through the Main UI. Yes, the widget/page yaml syntax is very different from most other scripting languages you might use for this, and many find it less than ideal, but it does offer a substantial amount of flexibility. Pretty much the only thing you can’t do with it* is direct JS access to the underlying web app, but you wouldn’t get that with your proposal either.

(*- or can’t do with it easily, depending on the situation)

I’m curious to know, however, what you’ve wanted to do that you have been unable to accomplish.

This would be my suggestion. 1) that winds up being additive effort, not parallel effort and 2) more people will be able to share the fruits of your labors. If you are contributing new widget components to the UI codebase, there aren’t too many limits to what effects or functions you can get.

1 Like

It’s more due to the way I query the DB really. I would have a LOT more flexibility if I could query the DB however I wanted, using direct queries. I feel that I am very limited in using rules etc.

For instance, one thing that I am struggling to have, is simply an output of Kw/h for the current month, previous month, current year and last year. I have a register of the Kw/h in my DB each 5 minutes and I would like to grab that information, do the necessary calculations and show, for the correct times, the information but I’ve been “fighting” a lot with rules and cannot make this happen…

I know this is only my poor knowledge on how rules work though, but still it’s frustrating because I’ve already lost so many hours with trial and error and can never reach a functioning solution and that’s why I thought in this crazy idea of simply create my own dashboard.

This suggestion is good though, because I might end up creating something that the community can use as well, so I will instead dive into this option.

Thank you for sharing your opinion.

Have you looked at HabApp? It is an external “system” written in plain Python, outside of openHAB. It communicates with openHAB via REST API, the same way that openHAB’s MainUI web site communicates with openHAB. AFAIK MainUI does not have any “back channels” to openHAB other than through the REST API.

So this means if you decided to create your own PHP app, it can do everything that MainUI can.

In terms of rules, I can write openHAB JRuby rules that access any external database. I have only done this with sqlite for my purpose (logging licence plate recognition results) but I believe mysql, postgresql, etc are also possible. The drivers are provided through JDBC.

If you’re a bit lost, perhaps post a specific question about a specific goal/challenge so you can get specific suggestions, and go from there?

What look are you after?

I’ve read something about it yes, but to me it almost seems like a “different way” of working with OH, more flexible yes, but not necessarily easier. At least in my point of view.

Yes, I can do that and I actually have a lot of different rules polling information from my DB in different ways. But I find it somehow “buggy” because sometimes I use commands that were supposed to work, such changedSince and other alike and not always I get the results that I was expecting (or no results at all).

Again, most probably this is just me now knowing how to work properly with rules and the example I gave above that I want to achieve and where I’ve already invested a lot of hours, have proved very difficult for me to achieve.

This is one example I actually appreciate (with a different background, since this is just “too noisy”):

I don’t know what you did, but the standard openhab persistence is not “buggy”. It should work consistently, no glitches, otherwise you’d hear about it from many people.

I’m no expert when it comes to UI, but that seems very doable using mainui.

If I were to be brutally honest, this feels a whole lot like “I’ve been trying to hammer in this screw for awhile and it’s not working. So I’m going to switch to dovetail joints instead of stepping back and figure out how to use a screwdriver.”

That’s not necessarily a bad thing and a lot of good new things have been created from such things. But it’s definitely going to be a good deal more work than figuring things out within the platform itself.

What’s different is it’s a completely separate and full Python environment. It’s completely free from OH constraints. If you want to query a database from HABApp, you’d do so in the normal python way.

But I think it’s important to make a distinction here. None of the OH UIs will let you query the DB and calculate something from the results in the UI. You’ll need rules that update Items for this. Using HABApp, or much of everything else discussed here addresses the rules side of things. But if you want to do this from the UI, you’ll have to create your own UI.

Is this a HABPanel?

I agree with @JimT though, I see nothing here that cannot be done in MainUI. Several of these widgets already exist in some form or other on the Marketplace.

1 Like

This was kind of to create a discussion around the subject and get different opinions.

As of now, I’m fully convinced that I should just step back and learn a little bit more on how the “screw” actually works. :smiley:

I will go again into rules and see what I’m doing wrong there in order to make that happen. Let’s see what I can achieve.

No, it’s apparently an APP that someone created for Home Assistant that doesn’t seem to be available anymore.

If you run into problems, don’t spin your wheels. Post new threads with what you are stuck on and we can help most of the time. No one wants anyone to spin their wheels needlessly.