Adding groovy libraries? (specifically groovy.sql for TimescaleDB)

I'm playing with building a logger similar to InfluxDB-Logger, but for Postgres/TimescaleDB.

A catch I'm sticking on is that I can't import groovy.sql.SQL, attempting to save the file yields a "Importing [groovy.sql.Sql] is not allowed" error message.

I do see that groovy.sql is not listed in the provided list as here:
docs2_hubitat_com/en/developer/allowed-imports
so that's probably the direct cause of the error

Is it possible for me to add groovy.sql as a driver? Or are those all only at the system level? There's no JDBC import on that list either, so limited options to try.

Although not really related, I'm using a C8-Pro, platform version 2.3.9.150 (current).

Thanks for your help guys!!!

1 Like

Yeah, it's my understanding the HE developers manage the list of allowed classes / packages we can import. Have you considered hosting something on another machine to handle the storage of the logs, like a node JS or similar application?

1 Like

Yes, for clarity, this is for hosting logs on some other machine.

TimescaleDB/Postgres is sitting in a Docker on the external Synology NAS. But to connect to it from Hubitat, that communication protocol is sitting in the groovy.sql code. It's not a http connection to accomplish that.

Then Grafana (again, off-Hubitat) can look at the Postgres database pretty easily.

Without groovy.sql it's going to be very difficult to export data directly to any traditional databases. I get that "storing a bunch of data on Hubitat is not what we want to shoot for" and correct, I'm not wanting to do that. But groovy.sql wouldn't enable storage locally anyway: it's not a database engine itself, it's just a connection/communication piece.

The driver / app I use to export device events to include actually uses a node JS app running on my rpu where infkuxdb is running, that's what made me ask whether you had considered a similar approach. It would remove the need for having to manage the db connection on HE.

1 Like

So you're using the InfluxDB logger on Hubitat, (and managing that database connection on Hubitat) then running an event checker off-Hubitat. It's clearly working, but I'd like to skip InfluxDB entirely. With their upcoming v3 being entirely different than v2 I don't want to get in, then have to rebuild the whole Grafana query set later.

I'm using a different setup on HE, I'll need to find it later tonight. Now that I think about it, I think it is using Maker API to post the events to the nose JS app.

1 Like

This is how I get my device events to InfluxDB:

Pro's and Con's aside re popularity / active user-base and activity on the topic.... The approach used was to have users setup an instance of Makler API on the HE hub, with the POST device events option configured as the target Node JS App host, then have the Node JS App interpret the built-in HE output of device events.

I mainly offer it now as an alternative design more than anything, if/how you choose to craft it into what you are trying to achieve may differ from this implementation, or you may choose to not use this approach at all.

Another way to go to get data out would be these two, but they're not on our list either. Just in case anyone official is making a list of libraries to increase outbound connectivity:

groovyx.net.http.RESTClient
java.io.OutputStreamWriter

So far the only outbound connection method that I've found is asynchttpPost() which InfluxDB-Logger uses.