Sending data to OH from mySQL/linux

I have a perle script which stores my solar data into a mysql database, and I would like to make that available to openhab, ie send items ( power/energy) to Openhab.
There a probably a few ways to do this but what is the best way of doing this?
ie can I call a API to do this or use a specific binding?

I’m running OH3 on Ubuntu LTS

openHAB itself is able to use MySQL as a persistence Service, but no other option (e.g. to query freely some sort of database - would be a very handsome feature, though…)

So the first option would be to use the REST API of openHAB.

  • Please open Main UIAdministrationDeveloper ToolsAPI Explorer.
  • It’s the Items which you are looking for, so open items and see all options to manipulate an Item (and its status).
  • Go to PUT items/{itemname}/state and click Try it out.
  • Set an existing Itemname and set the status you want to send to the Item. Click Execute, and you will (hopefully) get the curl call to set the item state.
  • Best practice is, to create a unique token for access, this is to be found in Main UIUsername (left down corner) → Create API-Token.

Another option is to use some sort of binding, e.g. create a script to send the values in question as a mqtt topic payload, then you will be able to create a corresponding mqtt thing to receive those messages in openHAB. There are many other options, but I tend to find mqtt one of the easiest ways to be integrated in existing scripts. As I don’t know perl at all (well, at least the name is familiar…), I have no idea if mqtt is an easy one here :slight_smile:

1 Like