getwud / wud

WUD (aka What's up Docker?) gets you notified when a new version of your Docker Container is available.
https://getwud.github.io/wud/
MIT License
1.29k stars 39 forks source link

MQTT sensors in HA doesn't survive a reboot ? #113

Open Tyrian81 opened 2 years ago

Tyrian81 commented 2 years ago

Got WUD up and running and it's great for keeping up with potential container updates. But whenever I reboot the system the containers come up again , but the mqtt HA sensors do not ?

version: '3'

services:
  whatsupdocker:
    image: fmartinou/whats-up-docker
    container_name: wud
    restart: unless-stopped    
    volumes:
      - /home/*******/docker/WUD/store:/store      
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 3331:3000
    environment:
        - WUD_TRIGGER_MQTT_MOSQUITTO_URL=tcp://*.*.*.*:1883
        - WUD_TRIGGER_MQTT_MOSQUITTO_HASS_ENABLED=true
        - WUD_TRIGGER_MQTT_MOSQUITTO_HASS_PREFIX=homeassistant
        - WUD_TRIGGER_MQTT_MOSQUITTO_TOPIC=wud/container
        - WUD_TRIGGER_MQTT_MOSQUITTO_USER=********
        - WUD_TRIGGER_MQTT_MOSQUITTO_PASSWORD=*******

When I delete the /WUD/store/wud.json and restart the container the sensors are available again . Mosquitto broker ,HA, Wud all running in containers on the same host.

fmartinou commented 2 years ago

Hi,

@Tyrian81 , Did you try to persist the state of Mosquito as I explained on the HA thread?

Tyrian81 commented 2 years ago

I have setup persistence in mosquitto container

version: '3.3'
services:
    eclipse-mosquitto:
        container_name: eclipse-mosquitto
        ports:
            - '1883:1883'
            - '9001:9001'
        volumes:
            - '/home/********/docker/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf'
            - '/home/********/docker/mosquitto/data:/mosquitto/data'
        restart: always
        image: eclipse-mosquitto

it is now saving a *.db file in /mosquitto/data/

did a full reboot of the system still the mqtt sensors are unavailable ?

08:38:50.186  INFO whats-up-docker/api: Server listening on port 3000 (HTTP)
08:38:48.377  INFO whats-up-docker/registry.ghcr: Register with configuration {}
08:38:58.416  INFO whats-up-docker/watcher.docker.local: Cron finished (21 containers watched, 0 errors, 8 available updates)
08:38:51.206  INFO whats-up-docker/trigger.mqtt.mosquitto: Remove hass device [id=wud_container_local_watchtower]
08:38:51.149  INFO whats-up-docker/watcher.docker.local: Listening to docker events
08:38:51.142  INFO whats-up-docker/watcher.docker.local: Cron started (0 * * * *)
08:38:50.178  WARN whats-up-docker: Anonymous authentication is enabled; please make sure that the app is not exposed to unsecure networks
08:38:50.168  INFO whats-up-docker/authentication.anonymous.anonymous: Register with configuration {}
08:38:50.148  INFO whats-up-docker/registry: No authentication configured => Allow anonymous access
08:38:50.107  INFO whats-up-docker/watcher.docker.local: Cron scheduled (0 * * * *)
08:38:50.106  INFO whats-up-docker/watcher.docker.local: Register with configuration {"socket":"/var/run/docker.sock","port":2375,"cron":"0 * * * *","watchbydefault":true,"watchall":false,"watchevents":true}
08:38:48.395  INFO whats-up-docker/registry: No Watcher configured => Init a default one (Docker with default options)
08:38:48.392  INFO whats-up-docker/registry.quay: Register with configuration {}
08:38:48.387  INFO whats-up-docker/registry.lscr: Register with configuration {}
08:38:48.383  INFO whats-up-docker/registry.hub: Register with configuration {}
08:38:47.280  INFO whats-up-docker/trigger.mqtt.mosquitto: Register with configuration {"url":"tcp://192.168.188.***:1883","user":"******","topic":"wud/container","password":"*********","hass":{"prefix":"homeassistant","enabled":true},"threshold":"all","mode":"single","once":true,"simpletitle":"New ${kind} found for container ${name}","simplebody":"Container ${name} running with ${kind} ${local} can be updated to ${kind} ${remote}\n${link}","batchtitle":"${count} updates available","key":"R************!"}
08:38:46.950  INFO whats-up-docker/registry: Register all components of kind trigger for provider mqtt
08:38:46.718  INFO whats-up-docker/prometheus: Init Prometheus module
08:38:46.603  INFO whats-up-docker/store: Load store from (/store/wud.json)

Strange thing is only one container sensor survived the reboot , the mosquitto broker is still available in HA ? I will have to delete /store/wud.json restart container and they are all back ?

Tyrian81 commented 2 years ago

after i delete the /store/wud.json and a WUD container restart it does this :


08:54:14.774  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_portainer]
09:00:04.814  INFO whats-up-docker/watcher.docker.local: Cron finished (21 containers watched, 0 errors, 8 available updates)
09:00:00.423  INFO whats-up-docker/watcher.docker.local: Cron started (0 * * * *)
08:54:14.775  INFO whats-up-docker/watcher.docker.local: Cron finished (21 containers watched, 0 errors, 8 available updates)
08:54:14.725  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_plex]
08:54:14.658  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_homeassistant]
08:54:14.714  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_duplicati]
08:54:13.915  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_vaultwarden]
08:54:13.845  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_dsmr]
08:54:13.841  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_npm]
08:54:13.821  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_wud]
08:54:13.783  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_zigbee2mqtt]
08:54:13.808  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_adguardhome]
08:54:13.764  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_eclipse-mosquitto]
08:54:13.762  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_double-take]
08:54:12.058  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_flame]
08:54:11.334  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_dsmrdb]
08:54:11.314  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_compreface-postgres-db]
08:54:11.291  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_uptime-kuma]
08:54:11.269  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_compreface-ui]
08:54:11.266  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_compreface-admin]
08:54:11.263  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_frigate]
08:54:11.249  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_compreface-core]
08:54:11.244  INFO whats-up-docker/trigger.mqtt.mosquitto: Add hass device [id=wud_container_local_compreface-api]
08:54:10.365  INFO whats-up-docker/watcher.docker.local: Listening to docker events
08:54:10.360  INFO whats-up-docker/watcher.docker.local: Cron started (0 * * * *)
08:54:09.358  INFO whats-up-docker/api: Server listening on port 3000 (HTTP)
08:54:09.354  WARN whats-up-docker: Anonymous authentication is enabled; please make sure that the app is not exposed to unsecure networks
08:54:09.349  INFO whats-up-docker/authentication.anonymous.anonymous: Register with configuration {}
08:54:09.348  INFO whats-up-docker/registry: No authentication configured => Allow anonymous access
08:54:09.343  INFO whats-up-docker/watcher.docker.local: Cron scheduled (0 * * * *)
08:54:09.342  INFO whats-up-docker/watcher.docker.local: Register with configuration {"socket":"/var/run/docker.sock","port":2375,"cron":"0 * * * *","watchbydefault":true,"watchall":false,"watchevents":true}
08:54:08.999  INFO whats-up-docker/registry: No Watcher configured => Init a default one (Docker with default options)
08:54:08.999  INFO whats-up-docker/registry.quay: Register with configuration {}
08:54:08.998  INFO whats-up-docker/registry.lscr: Register with configuration {}
08:54:08.997  INFO whats-up-docker/registry.hub: Register with configuration {}
08:54:08.996  INFO whats-up-docker/registry.ghcr: Register with configuration {}
08:54:08.850  INFO whats-up-docker/trigger.mqtt.mosquitto: Register with configuration {"url":"tcp://192.168.188.***:1883","user":"******","topic":"wud/container","password":"******","hass":{"prefix":"homeassistant","enabled":true},"threshold":"all","mode":"single","once":true,"simpletitle":"New ${kind} found for container ${name}","simplebody":"Container ${name} running with ${kind} ${local} can be updated to ${kind} ${remote}\n${link}","batchtitle":"${count} updates available","key":"*********"}
08:54:08.792  INFO whats-up-docker/registry: Register all components of kind trigger for provider mqtt
08:54:08.786  INFO whats-up-docker/prometheus: Init Prometheus module
08:54:08.786  INFO whats-up-docker/store: Create Collection containers
08:54:08.786  INFO whats-up-docker/store: Migrate data from version undefined to version latest
08:54:08.785  INFO whats-up-docker/store: Create Collection app
08:54:08.783  INFO whats-up-docker/store: Load store from (/store/wud.json)
08:54:08.782  INFO whats-up-docker: What's up Docker? is starting (version = latest)
fmartinou commented 2 years ago

Hi,

I 'm still not able to reproduce your issue on my end :/ To help me figure out what is happening, can you:

1. Check the state before stopping your system

a. Check that the last message on all homeassistant/binary_sensor/wud_container_xxx topics contain a JSON configuration file looking like

{
   "unique_id":"wud_container_local_traefik_latest",
   "name":"traefik_latest",
   "device":{
      "identifiers":[
         "wud"
      ],
      "manufacturer":"Fmartinou",
      "model":"Wud",
      "name":"What's up docker?",
      "sw_version":"5.16.1"
   },
   "device_class":"update",
   "icon":"mdi:docker",
   "force_update":true,
   "state_topic":"wud/container/local/traefik_latest",
   "value_template":"{{ value_json.update_available }}",
   "payload_off":false,
   "payload_on":true,
   "json_attributes_topic":"wud/container/local/traefik_latest"
}

b. Check that all the wud/container/xxx topics are present c. Check that all HA sensors are present

2. Stop all your system

3. Start your system without WUD

4. Check that MQTT topics & HA sensors are recovered as expected Same tests as in 1.

5. Start WUD in debug mode- _WUD_LOGLEVEL=debug

6. Check that MQTT topics & HA sensors are still present Same tests as in 1.

And then please log here your observations & your logs. Thank you!

Tyrian81 commented 2 years ago

solved, a few reboots later it survives reboots

zsamiatt commented 2 years ago

What had to be restarted?

Tyrian81 commented 2 years ago

Rebooted pc few times and was working

Tyrian81 commented 2 years ago

Persisted mosquito data and wud data

zsamiatt commented 2 years ago

I delete the json file and every working good. The reboot can not solve the problem.

dougmaitelli commented 1 year ago

@fmartinou Could this issue be due to MQTT container restarting and wud not handling the connection exception properly an recovering / re-connecting? I have the same issue, over time the MQTT trigger just disappears and then just rebooting wud fixes it.