Time and Database setup

Hello openHAB community,

I’m currently working on a projekt at my university in Stuttgart and would like to get some help.

Im working on a projekt called smart charging station for electric bycicles. Therefor i need to develop a accounting system. In case of developing i want to get the start- and endtime of people charging their bicycle, so im abel to find out how long people charged their bicycle and create a check .

Also im trying to embed a database for staff identification. They should be abel to get a discount on their charging bill.

For the realization of this project i need some help in:

  • how i get the time (start- and endtime)?
  • how to embed a database?

Feel free to comment your thoughts, ideas and details. If your having any questions feel free to ask. Im pleased to answer your questions.

Thank you.

All things considered, this is not a problem that openHAB is well suited to solve. openHAB is designed to address home automation problems, not time and billing problems. I think you would end up spending nearly as much effort trying to make the above work in OH as you would coding it from scratch

For one thing, there really is no way to embed a database like you need. There are all sorts of hacks one can use to work around this limitation including:

  • using executeCommandLine to use the command line based database client to query the database
  • using a .map file in the transform folder to get a true for those who are employees and a null for those who are not
  • hardcode the database into the Rules in a Map file
  • encode the names into a String Item and parse the Item for the names
  • create a new Item for each employee and add them to a Group, then look up to see if the Item exists in the Group

The problem is none of these are particularly easy and with the exception of executeCommandLine, none of them are nearly secure enough to trust for something that has monetary implications (i.e. too easy to hack).

Then you have the problem of the time tracking. That isn’t as difficult to record into a database but there is nothing in OH that will let you generate an itemized invoice in a reasonable fashion. You can set up persistence to record when events occur (i.e. started charging, ended charging). And then from outside OH you could query the database to generate the invoice. Of course, if you do that then the database of employees needs to be implemented there, not in OH.

So at this point, why use OH in the first place? The only thing that OH is actually providing for you is the ability to detect the events on when a bike starts and stops charging. You don’t say anything about how that works but I’m certain that there is a Python library or the like out there that will do it for you.

1 Like