More detailed context
As documented in the comment linked above, I got this setup fully working so that I was running openHAB (openhabian OS), influxDB and Grafana on the Raspberry Pi4.
Since this stuff is going to control the heating of our house, I was educating myself on the reliability of Raspberry. I managed to setup watchdog to automatically reboot when shit hits the fan and so on, but then I found one of the many threads about corrupted SD cards. And learnt that to lower the risk of corrupting the card (or to try to postpone the time when it eventually happens), one strategy would be to use a database hosted on another server so that the Raspberry would not have to have so many writes to the SD card.
What am I trying to achieve
I happen to have a NAS server in the same LAN so I
installed MariaDB on the NAS server (ready package from the NAS, influxDB was not available)
and created a database and user for openhab
installed the JDBC Persistence MariaDB add-on
configured jdbc.cfg and jdbc.persist
and observed that the normal item persistence was working as expected
So now I’m on the point where my javascript logic need to start writing points with future timestamps to the database (tomorrow’s electricity prices). As documented in the link above, using InfluxDB2 on the Raspberry, I was able to do this by using the REST API of the InfluxDB.
But what would be the most elegant way to do this with the MariaDB? Openhab definitely has the capability to connect, write and read to MariaDB via the JDBC service, but am I able to somehow call this service from my custom javascript code so that I can make my own insert, update and select queries?
Edit: Others have used the exec binding to execute a shell script that uses the command line client, but I would like to avoid installing the exec if I can.
You might be able to use the openHAB persistence REST API end point to push values with a future date to the database. Go to Developer Tools → API Explorer for more details.
The original poster tried to write to influxdb hosted on another server, I’m trying to write to a remote mariadb, but that should not be relevant
The original poster had misconfigured the influxdb so that it did not allow connections from another server and when they fixed that, their issue got resolved
That’s not my issue, because my MariaDB does allow connections from others hosts in the same LAN, as can be seen from the fact that I was able to query the GET /persistence/items endpoint…
I don’t use JDBC databases with OH so I’ve nothing to offer. It would be odd that it only errors when posting data through the REST API but not when the Items themselves are changing since it’s all activating the same code.
Meanwhile I’m “almost there” with installing InfluxDB on my Asustor NAS so that I could write to that with Influx DB’s REST API, just like I did with the Influx server on my Raspberry.
I was able to start Influx with the influxd binary, but the remaining part is to try to get the daemon to start automatically when my NAS reboots. I need to google that a bit more since my NAS doesn’t seem to have /lib/systemd/system/ where I could place influxdb2.service like I did on my Raspberry… But that’s not an OH problem, so I’ll have to figure some other mechanism for it…
I created a user influxdb so that I don’t have to run this as root. Also remember to create a home directory.
InfluxDB can be started with the influxd daemon as mentioned in the instructions above
To get influxd starting automatically when the Asustor NAS starts
You can place a simple script at /usr/local/etc/init.d/
The file name of the script needs to be like S99influx.sh, where S stands for ‘start’ and 99 means that everything else needs to be started before this.
The script does effectively sudo -u influxdb influxd > /var/log/influx.log