Item change state after Docker stop-start

  • Platform information:
    • Hardware: x86/8GB/256GB SSD
    • OS: Debian GNU/Linux 12 (bookworm)
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: openhab:4.0.4
    • Docker Engine - Community Version: 24.0.7 API version: 1.43

I run openhab in a Docker container with a few ohter containers. I use portainer for managing the containers.

I have a smal script that stop every container start borg backup and start the container. Everythin works fine but wenn OH ist starting after the backup a few Items change their state to ON. A zigbee light (controlled with MQTT over zigbee2mqtt) and my recever (controlled with Logitech Harmony Hub Binding).
Since the backup runs at night, it is very annoying.

I have tried a many things in the last few days, I suspected that it was due to the OH container stopping.
If I stop an start OH with Portainer, everthing everything works as it should. I read a little bit in the docker docs and found on this site, docker stop, that the contaner after a certain period will be killed. So I have defined the time.
Now on some days I dont´t get the problem, but sometimes it doesn´t work.

I could now increase the time until it no longer occurs, but I would rather fix the problem that the status changes.

This is the part of my script, it is based on the instructions of Ubuntu Users

# USB-Stick einhaengen
mount /dev/sdb1 /media/backup

# Alle laufenden Container in eine Variable speichern
running_containers=$(docker ps -q)

# Alle laufenden Container stoppen
echo "Docker Container werden gestoppt:"
docker stop -t 10 $running_containers

repopfad="$zielpfad"/"$repository"

# check for root
if [ $(id -u) -ne 0 ] && [ "$rootuser" == "ja" ]; then
  echo "Sicherung muss als Root-User ausgeführt werden."
  exit 1
fi

# Init borg-repo if absent
if [ ! -d $repopfad ]; then
  borg init --encryption=$verschluesselung $repopfad
  echo "Borg-Repository erzeugt unter $repopfad"
fi

# backup data
SECONDS=0
echo "Start der Sicherung $(date)."

borg create --compression $kompression --exclude-caches --one-file-system -v --stats --progress \
            $repopfad::'{hostname}-{now:%Y-%m-%d-%H%M%S}' $sicherung

echo "Ende der Sicherung $(date). Dauer: $SECONDS Sekunden"

# prune archives
borg prune -v --list $repopfad --prefix '{hostname}-' $pruning


# Alle in der Variable gespeicherten Container neu starten
echo "gestoppte Docker Container werden gestartet:"
docker start $running_containers

# USB-Stick aushaengen
umount /dev/sdb1

If someone could give me a tip as to what the problem could be, I would be very grateful
Greetings an Merry Christmas!

I think more needs to be looked into to figure this out

When OH starts up, the Items will update under three circumstances.

  1. restoreOnStartup
  2. The binding
  3. A rule

1 will not cause the light to actually turn on. It only changes the state of the Item internal to OH. 2 is going to be just an update to the Item to reflect the Item’s actual state. So the most likely culprit is a rule.

Thank you for your reply!

1 - restoreOnStartup wasn´t used for this items in the past, so I would definitely rule that out
2 - the problem occurs across all bindings, so probably not
3 - that will be easy for checking, I only hve text based rules, so I turn them one after the other off and do restarts.

I will get back to you when I know more