openHAB Persistence Not Working — Complete Guide
In this tutorial, you'll learn about openhab persistence not working. We cover key concepts, practical examples, and best practices.
Hook
You configure a persistence service (MapDB, InfluxDB, or SQL) in openHAB. You check the Charts UI and see "No data available." Items are updating in the log, but nothing is being saved to the database.
The Wrong Way
Installing every persistence add-on at once and enabling them all creates conflicts — only one persistence service can be the default.
# BAD: Installing multiple persistence services
openhab-cli install org.openhab.persistence.influxdb
openhab-cli install org.openhab.persistence.mapdb
openhab-cli install org.openhab.persistence.jdbc
[Persistence] Multiple default persistence services detected
[Persistence] Using MapDB — ignoring InfluxDB and JDBC
Only one service acts as the default. The others are ignored unless explicitly referenced.
The Right Way
Configure a single persistence service and ensure items are included.
# 1. Choose and install one persistence service
openhab-cli install org.openhab.persistence.influxdb
# 2. Configure InfluxDB connection
cat /etc/openhab/services/influxdb.cfg
# InfluxDB configuration
url=http://localhost:8086
user=openhab
password=securepassword
database=openhab
# 3. Create the persistence strategy file
cat /etc/openhab/persistence/influxdb.persist
// Persist all items to InfluxDB
Strategies {
default = everyChange, everyMinute
}
Items {
* : strategy = everyChange, everyMinute
}
# 4. Restart openHAB
sudo systemctl restart openhab
# 5. Check that data is flowing
tail -f /var/log/openhab/openhab.log | grep -i "influx\|persist"
2026-06-24 10:00:00.000 [INFO ] [ersistence.influxdb] - Stored 45 items in InfluxDB
# 6. Verify in the Charts UI
# Main UI → Analysis → Charts → Select item
Chart shows data points ✓
Prevention
- Use only one persistence service as the default.
- Specify item strategies explicitly with
* : <a href="/design-patterns/strategy/">strategy</a> = everyChange, everyMinute. - Test persistence with a single item before enabling for all items.
- Keep InfluxDB or your database service running before openHAB starts.
- Use
restoreOnStartupfor critical items (like light switches) to recall previous states.
Common Mistakes with persistence
- Forgetting
deriving (Show, Eq)on custom data types needed for debugging - Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
- Using
headandtailinstead of pattern matching, causing runtime errors on empty lists
These mistakes appear frequently in real-world OPENHAB code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
DodaTech — persistence that remembers everything.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro