Hi!
I got openhab 3.1M4 together with MariaDB persistence on a Synology running. I use this configuration because of the new BMW ConnectedDrive binding coming up with 3.1. There are several values which I would like to save in a “real” DB, so I setup the persistence with a MariaDB on my synology while openHab is running on a RPi4.
The problem is now that the persisted data is not useable for my purpose. The BMW ConnectedDrive binding is offering last trip values which I would like to save in the DB. It’s a set of 7 values which is each time updated when the trip has finished (TripEndTime, Duration, Distance since last charge, …)
Since each value is now saved in an own table and there is no link between I cannot restore the complete set of data. The timestamp is different in all tables and some values are not updated, because there is no change. If I drive from point A to B, make a break and drive back from B to A the duration is the same and so there is no entry done.
My idea was no to bypass this problem and save the complete recordset with all 7 values in a row but I got always the same error 36 filename too long. Anyone has an idea what’s wrong?
This is my rule
rule “testrule”
when
Item TestSwitch changed from OFF to ON
then
var string mysql_host=“192.168.178.44”
var string mysql_db=“openhabuser”
var string mysql_user=“openhabuser”
var string mysql_pw=“XXXXXXX”
logInfo("testrule", "Starting testrule")
//var string sql_query = "mysql@@-h@@" + mysql_host + "@@-P@@3307@@-u@@" + mysql_user + "@@-p" + mysql_pw + "@@-e@@\"INSERT INTO BMWLastTrip(TripDate,TripDurationMinutes,Distance,DistanceSinceLastCharge,AverageConsumption,AverageRecuperation,Efficiency) VALUES (" + i3TripDateTime.state.toString + "," + i3TripDuration.state.toString + "," + i3TripDistance.state.toString + "," + i3TripDistanceSinceCharge.state.toString + "," + i3AvgTripConsumption.state.toString + "," + i3AvgTripRecuperation.state.toString + ",0);\"@@-D@@" + mysql_db
var string sql_query = "mysql -h " + mysql_host + " -P 3307 -u " + mysql_user + " -p" + mysql_pw + " -e \"INSERT INTO BMWLastTrip(TripDate,TripDurationMinutes,Distance,DistanceSinceLastCharge,AverageConsumption,AverageRecuperation,Efficiency) VALUES (" + i3TripDateTime.state.toString + "," + i3TripDuration.state.toString + "," + i3TripDistance.state.toString + "," + i3TripDistanceSinceCharge.state.toString + "," + i3AvgTripConsumption.state.toString + "," + i3AvgTripRecuperation.state.toString + ",0);\" -D " + mysql_db
logInfo("SQL","SQL query to be executed: " + sql_query)
var String mysql = executeCommandLine(sql_query)
if(mysql!="") {
logInfo("SQL","Result SQL query: " + mysql)
}
logInfo("testrule", "done")
end
And this is the result:
2021-05-19 20:43:08.936 [INFO ] [org.openhab.core.model.script.SQL ] - SQL query to be executed: mysql -h 192.168.178.44 -P 3307 -u openhabuser -pXXXXXXX -e “INSERT INTO BMWLastTrip(TripDate,TripDurationMinutes,Distance,DistanceSinceLastCharge,AverageConsumption,AverageRecuperation,Efficiency) VALUES (2021-05-19T19:46:00.000+0200,12.0 min,9.0 km,51.0 km,13.1 kWh,8.0 kWh,0);” -D openhabuser
2021-05-19 20:43:08.945 [WARN ] [rg.openhab.core.io.net.exec.ExecUtil] - Error occurred when executing commandLine ‘[mysql -h 192.168.178.44 -P 3307 -u openhabuser -pXXXXXXX -e “INSERT INTO BMWLastTrip(TripDate,TripDurationMinutes,Distance,DistanceSinceLastCharge,AverageConsumption,AverageRecuperation,Efficiency) VALUES (2021-05-19T19:46:00.000+0200,12.0 min,9.0 km,51.0 km,13.1 kWh,8.0 kWh,0);” -D openhabuser]’
java.io.IOException: Cannot run program “mysql -h 192.168.178.44 -P 3307 -u openhabuser -pXXXXXXX -e “INSERT INTO BMWLastTrip(TripDate,TripDurationMinutes,Distance,DistanceSinceLastCharge,AverageConsumption,AverageRecuperation,Efficiency) VALUES (2021-05-19T19:46:00.000+0200,12.0 min,9.0 km,51.0 km,13.1 kWh,8.0 kWh,0);” -D openhabuser”: error=36, File name too long