I’m trying to set up a timescaledb
based persistence without any item names mapping.
No mapping means that I’d like to have an item name, as specified in the /etc/openhab/persistence/jdbc.persist
file, to be accessible in the database.
Setting up the timescaledb
persistence as follows:
$ grep -e '^[a-zA-Z]' /etc/openhab/services/jdbc.cfg | grep -v -e user -e password
url=jdbc:timescaledb://127.0.0.1:5432/openhab_db
tableUseRealItemNames=true
tableCaseSensitiveItemNames=true
tableIdDigitCount=0
and having defined in the /etc/openhab/persistence/jdbc.persist
file the Heat_Pump_Total_active_power
item, I still couldn’t find this item being stored in postgresql
:
openhab_db=# \dt Heat_Pump_Total_active_power
Did not find any relation named "Heat_Pump_Total_active_power".
Contrary to the above output, I can find it when I’m searching for item name with double quotes:
openhab_db=# \dt "Heat_Pump_Total_active_power"
List of relations
Schema | Name | Type | Owner
--------+----------------------------------------------+-------+---------
public | Heat_Pump_Total_active_power | table | openhab
(1 row)
Note that \dt
output does not contain those double quotes characters which might be very confusing for someone looking for a particular table.
The documentation (HEAD
of the main
branch at the time of writing) doesn’t mention anything about the fact that extra double quotes characters will be added:
openhab-addons$ git grep -i quot -- bundles/org.openhab.persistence.jdbc/README.md
openhab-addons$ git log --oneline -n 1
379b244b1f (HEAD -> main, origin/main, origin/HEAD) [boschshc] Use MAC address as default bridge thing ID (#18391)
Looking for \"
I found:
$ git grep -A 1 -B 2 '"\\"' -- bundles/org.openhab.persistence.jdbc
bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcPostgresqlDAO.java- @Override
bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcPostgresqlDAO.java- protected String formattedIdentifier(String identifier) {
bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcPostgresqlDAO.java: return "\"" + identifier + "\"";
bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcPostgresqlDAO.java- }
Unfortunately, it’s hard coded and doesn’t depend on any configuration option.
So far, I exclusively used influxdb
persistence and I could connect directly to the database and use exactly those names as specified in the /etc/openhab/persistence/influxdb.persist
file.
I wonder, why the jdbc
persistence service is so special and why there is no option to disable mapping at all or even better to have it switched off, by default (like in aforementioned influxdb
)?