updates2mqtt 1.3.7__tar.gz → 1.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/.github/dependabot.yml +6 -0
  2. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/.github/workflows/docker-publish.yml +1 -1
  3. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/.github/workflows/pypi-publish.yml +3 -3
  4. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/.github/workflows/python-package.yml +3 -1
  5. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/.pre-commit-config.yaml +5 -5
  6. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/CHANGELOG.md +5 -0
  7. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/Dockerfile +1 -1
  8. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/PKG-INFO +65 -23
  9. updates2mqtt-1.4.0/README.md +124 -0
  10. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/docs/configuration.md +50 -19
  11. updates2mqtt-1.4.0/docs/home_assistant.md +34 -0
  12. updates2mqtt-1.4.0/docs/images/ha_entities.png +0 -0
  13. updates2mqtt-1.4.0/docs/images/ha_update_dialog.png +0 -0
  14. updates2mqtt-1.4.0/docs/images/logo-blank-256x256.png +0 -0
  15. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/docs/installation.md +15 -0
  16. updates2mqtt-1.4.0/docs/troubleshooting.md +93 -0
  17. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/examples/config.yaml.maximal +1 -0
  18. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/mkdocs.yml +24 -1
  19. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/pyproject.toml +6 -1
  20. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/src/updates2mqtt/config.py +1 -0
  21. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/src/updates2mqtt/integrations/docker.py +1 -1
  22. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/src/updates2mqtt/integrations/git_utils.py +3 -1
  23. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/src/updates2mqtt/mqtt.py +48 -4
  24. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/tests/test_docker.py +8 -7
  25. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/tests/test_mqtt.py +3 -2
  26. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/uv.lock +265 -126
  27. updates2mqtt-1.3.7/README.md +0 -82
  28. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/.dockerignore +0 -0
  29. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/.gitignore +0 -0
  30. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/.hintrc +0 -0
  31. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/.python-version +0 -0
  32. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/.safety-project.ini +0 -0
  33. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/LICENSE +0 -0
  34. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/SECURITY.md +0 -0
  35. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/common_packages.yaml +0 -0
  36. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/conftest.py +0 -0
  37. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/docs/examples/config_maximal.md +0 -0
  38. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/docs/examples/config_minimal.md +0 -0
  39. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/docs/examples/docker_compose.md +0 -0
  40. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/docs/images/ha_mqtt_discovery.png +0 -0
  41. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/docs/images/ha_update_detail.png +0 -0
  42. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/docs/images/ha_update_page.png +0 -0
  43. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/docs/index.md +0 -0
  44. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/docs/local_builds.md +0 -0
  45. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/examples/config.yaml.minimal +0 -0
  46. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/examples/docker-compose.yaml +0 -0
  47. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/no_config.yaml +0 -0
  48. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/refresh-deps.sh +0 -0
  49. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/scripts/healthcheck.sh +0 -0
  50. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/src/updates2mqtt/__init__.py +0 -0
  51. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/src/updates2mqtt/__main__.py +0 -0
  52. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/src/updates2mqtt/app.py +0 -0
  53. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/src/updates2mqtt/hass_formatter.py +0 -0
  54. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/src/updates2mqtt/integrations/__init__.py +0 -0
  55. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/src/updates2mqtt/model.py +0 -0
  56. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/src/updates2mqtt/py.typed +0 -0
  57. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/tests/__init__.py +0 -0
  58. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/tests/test_config.py +0 -0
  59. {updates2mqtt-1.3.7 → updates2mqtt-1.4.0}/tests/test_git_utils.py +0 -0
@@ -9,16 +9,22 @@ updates:
9
9
  directory: "/" # Location of package manifests
10
10
  schedule:
11
11
  interval: "weekly"
12
+ cooldown:
13
+ default-days: 7
12
14
 
13
15
  - package-ecosystem: "github-actions"
14
16
  directory: "/"
15
17
  schedule:
16
18
  interval: "monthly"
19
+ cooldown:
20
+ default-days: 7
17
21
 
18
22
  - package-ecosystem: "docker"
19
23
  directory: "/"
20
24
  schedule:
21
25
  interval: "weekly"
26
+ cooldown:
27
+ default-days: 7
22
28
 
23
29
 
24
30
 
@@ -42,7 +42,7 @@ jobs:
42
42
  uses: docker/setup-buildx-action@v3
43
43
  - name: Extract metadata (tags, labels) for Docker
44
44
  id: meta
45
- uses: docker/metadata-action@032a4b3bda1b716928481836ac5bfe36e1feaad6
45
+ uses: docker/metadata-action@8d8c7c12f7b958582a5cb82ba16d5903cb27976a
46
46
  with:
47
47
  images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
48
48
  tags: |
@@ -22,7 +22,7 @@ jobs:
22
22
  - name: Build a binary wheel and a source tarball
23
23
  run: uv build
24
24
  - name: Store the distribution packages
25
- uses: actions/upload-artifact@v4
25
+ uses: actions/upload-artifact@v5
26
26
  with:
27
27
  name: python-package-distributions
28
28
  path: dist/
@@ -42,7 +42,7 @@ jobs:
42
42
 
43
43
  steps:
44
44
  - name: Download all the dists
45
- uses: actions/download-artifact@v4
45
+ uses: actions/download-artifact@v6
46
46
  with:
47
47
  name: python-package-distributions
48
48
  path: dist/
@@ -64,7 +64,7 @@ jobs:
64
64
 
65
65
  steps:
66
66
  - name: Download all the dists
67
- uses: actions/download-artifact@v4
67
+ uses: actions/download-artifact@v6
68
68
  with:
69
69
  name: python-package-distributions
70
70
  path: dist/
@@ -25,6 +25,7 @@ jobs:
25
25
  python-version-file: "pyproject.toml"
26
26
  - name: Install dependencies
27
27
  run: uv sync --all-extras --dev
28
+
28
29
  - name: Ruff
29
30
  uses: chartboost/ruff-action@v1
30
31
  - name: Test with pytest
@@ -32,11 +33,12 @@ jobs:
32
33
  - name: Build a binary wheel and a source tarball
33
34
  run: uv build
34
35
  - name: Prep for mkdocs
35
- run: uv pip compile pyproject.toml -o requirements_docs.txt --group mkdocs
36
+ run: uv pip compile pyproject.toml -o requirements_docs.txt --group mkdocs
36
37
  - name: Deploy docs
37
38
  uses: mhausenblas/mkdocs-deploy-gh-pages@master
38
39
  env:
39
40
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41
+ EXTRA_PACKAGES: pngquant
40
42
  REQUIREMENTS: requirements_docs.txt
41
43
  CUSTOM_DOMAIN: updates2mqtt.rhizomatics.org.uk
42
44
 
@@ -1,6 +1,6 @@
1
1
  repos:
2
2
  - repo: https://github.com/asottile/pyupgrade
3
- rev: v3.21.1
3
+ rev: v3.21.2
4
4
  hooks:
5
5
  - id: pyupgrade
6
6
  args: [--py313-plus]
@@ -17,11 +17,11 @@ repos:
17
17
  - id: check-shebang-scripts-are-executable
18
18
  name: Check shell scripts are executable
19
19
  - repo: https://github.com/astral-sh/uv-pre-commit
20
- rev: 0.9.9
20
+ rev: 0.9.13
21
21
  hooks:
22
22
  - id: uv-lock
23
23
  - repo: https://github.com/astral-sh/ruff-pre-commit
24
- rev: v0.14.4
24
+ rev: v0.14.7
25
25
  hooks:
26
26
  # Run the linter.
27
27
  - id: ruff-check
@@ -39,7 +39,7 @@ repos:
39
39
  exclude_types: [csv, json]
40
40
 
41
41
  - repo: https://github.com/pre-commit/mirrors-mypy
42
- rev: v1.18.2
42
+ rev: v1.19.0
43
43
  hooks:
44
44
  - id: mypy
45
45
  args:
@@ -64,7 +64,7 @@ repos:
64
64
  - usingversion
65
65
 
66
66
  - repo: https://github.com/PyCQA/bandit
67
- rev: '1.8.6'
67
+ rev: '1.9.2'
68
68
  hooks:
69
69
  - id: bandit
70
70
  args: ["-c", "pyproject.toml"]
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.4.0
4
+ - MQTT protocol can now be set, to one of `3.1`,`3.11` or `5`
5
+ - Debug messages now provided for `on_subscribe` and `on_unsubscribe` callbacks
6
+ - Troubleshooting, installation, configuration docs updated, images optimized
7
+
3
8
  ## 1.3.7
4
9
  - Improved initial setup when run without config or env vars for MQTT
5
10
  - Minor test deps update and pyproject docs
@@ -30,7 +30,7 @@ ADD scripts/healthcheck.sh /app
30
30
  RUN chmod ug+x /app/healthcheck.sh
31
31
  ADD README.md /app/README.md
32
32
  ADD common_packages.yaml /app
33
-
33
+ RUN mkdir /app/.cache && chmod a+rw /app/.cache
34
34
 
35
35
  RUN uv sync --locked
36
36
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: updates2mqtt
3
- Version: 1.3.7
3
+ Version: 1.4.0
4
4
  Summary: System update and docker image notification and execution over MQTT
5
5
  Project-URL: Homepage, https://updates2mqtt.rhizomatics.org.uk
6
6
  Project-URL: Repository, https://github.com/rhizomatics/updates2mqtt
@@ -49,9 +49,14 @@ Description-Content-Type: text/markdown
49
49
 
50
50
  ## Summary
51
51
 
52
- Use Home Assistant to notify you of updates to Docker images for your containers and optionally perform the *pull* (or optionally *build*) and *update*.
52
+ Let Home Assistant tell you about new updates to Docker images for your containers.
53
+
54
+ ![Example Home Assistant update page](images/ha_update_detail.png "Home Assistant Updates")
55
+
56
+ Read the release notes, and optionally click *Update* to trigger a Docker *pull* (or optionally *build*) and *update*.
57
+
58
+ ![Example Home Assistant update dialog](images/ha_update_dialog.png "Home Assistant Updates"){width=480}
53
59
 
54
- ![Example Home Assistant update dialog](images/ha_update_detail.png "Home Assistant Updates")
55
60
 
56
61
  ## Description
57
62
 
@@ -59,7 +64,7 @@ updates2mqtt perioidically checks for new versions of components being available
59
64
 
60
65
  Currently only Docker containers are supported, either via an image registry check, or a git repo for source (see [Local Builds](local_builds.md)). The design is modular, so other update sources can be added, at least for notification. The next anticipated is **apt** for Debian based systems.
61
66
 
62
- Components can also be updated, either automatically or triggered via MQTT, for example by hitting the *Install* button in the HomeAssistant update dialog. Icons and release notes can be specified for a better HA experience.
67
+ Components can also be updated, either automatically or triggered via MQTT, for example by hitting the *Install* button in the HomeAssistant update dialog. Icons and release notes can be specified for a better HA experience. See [Home Assistant Integration](home_assistant.md) for details.
63
68
 
64
69
  To get started, read the [Installation](installation.md) and [Configuration](configuration.md) pages.
65
70
 
@@ -71,8 +76,7 @@ docker run -e MQTT_USER=user1 -e MQTT_PASS=pass1 -e MQTT_HOST=192.168.1.5 ghcr.i
71
76
 
72
77
  ## Release Support
73
78
 
74
- Presently only Docker containers are supported, although others are planned,
75
- probably with priority for `apt`.
79
+ Presently only Docker containers are supported, although others are planned, probably with priority for `apt`.
76
80
 
77
81
  | Ecosystem | Support | Comments |
78
82
  |-----------|-------------|----------------------------------------------------------------------------------------------------|
@@ -82,31 +86,57 @@ probably with priority for `apt`.
82
86
 
83
87
  A heartbeat JSON payload is optionally published periodically to a configurable MQTT topic, defaulting to `healthcheck/{node_name}/updates2mqtt`. It contains the current version of updates2mqtt, the node name, a timestamp, and some basic stats.
84
88
 
85
- A `healthcheck.sh` script is included in the Docker image, and can be used as a Docker healthcheck, if the container environment variables are set for `MQTT_HOST`, `MQTT_PORT`, `MQTT_USER` and `MQTT_PASS`.
89
+ A `healthcheck.sh` script is included in the Docker image, and can be used as a Docker healthcheck, if the container environment variables are set for `MQTT_HOST`, `MQTT_PORT`, `MQTT_USER` and `MQTT_PASS`. It uses the `mosquitto-clients` Linux package which provides `mosquitto_sub` command to subscribe to topics.
86
90
 
87
- TIP: Check healthcheck is working using `docker inspect --format "{{json .State.Health }}" updates2mqtt | jq`
88
-
89
- ## HomeAssistant integration
91
+ !!! tip
92
+
93
+ Check healthcheck is working using `docker inspect --format "{{json .State.Health }}" updates2mqtt | jq`
94
+
95
+ Another approach is using a restarter service directly in Docker Compose to force a restart, in this case once a day:
90
96
 
91
- Any updates that have support for automated install will automatically show in the
92
- Home Assistant settings page if the [MQTT Integration](https://www.home-assistant.io/integrations/mqtt/) is installed and automatic discovery is not disabled.
97
+ ```yaml title="Example Compose Service"
98
+ restarter:
99
+ image: docker:cli
100
+ volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
101
+ command: ["/bin/sh", "-c", "while true; do sleep 86400; docker restart updates2mqtt; done"]
102
+ restart: unless-stopped
103
+ environment:
104
+ - UPD2MQTT_UPDATE=AUTO
105
+ ```
106
+
107
+ ## Target Containers
108
+
109
+ While `updates2mqtt` will discover and monitor all containers running under the Docker daemon,
110
+ there are some options to make to those containers to tune how it works.
93
111
 
94
- ![Home Assistant MQTT Integraion configuration](images/ha_mqtt_discovery.png "Home Assistant MQTT Discovery")
112
+ These happen by adding environment variables to the containers, typically inside an `.env`
113
+ file, or as `environment` options inside `docker-compose.yaml`.
95
114
 
96
- The `homeassistant` default topic prefix matches the default updates2mqtt config, if its changed in HomeAssistant, then the updates2mqtt config must be changed to match.
115
+ ### Automated updates
97
116
 
98
- ![Home Assistant updates in Settings](images/ha_update_page.png "Home Assistant Updates")
117
+ If Docker containers should be immediately updated, without any confirmation
118
+ or trigger, *e.g.* from the HomeAssistant update dialog, then set an environment variable `UPD2MQTT_UPDATE` in the target container to `Auto` ( it defaults to `Passive`)
99
119
 
100
- For Home Assistant integration, updates2mqtt represents each component being managed as a [MQTT Update](https://www.home-assistant.io/integrations/update.mqtt/) entity, and uses [MQTT discovery(https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery)] so that HomeAssistant automatically picks up components discovered by updates2mqtt with zero configuration on HomeAssistant itself.
120
+ ```yaml title="Example Compose Snippet"
121
+ restarter:
122
+ image: docker:cli
123
+ command: ["/bin/sh", "-c", "while true; do sleep 86400; docker restart mailserver; done"]
124
+ environment:
125
+ - UPD2MQTT_UPDATE=AUTO
126
+ ```
127
+
128
+ ### Environment Variables
101
129
 
102
- There are 3 separate types of MQTT topic used for HomeAssisstant integration:
130
+ The following environment variables can be used to configure containers for `updates2mqtt`:
103
131
 
104
- - *Config* to support auto discovery. A topic is created per component, with a name like `homeassistant/update/dockernuc_docker_jellyfin/update/config`. This can be disabled in the config file, and the `homeassistant` topic prefix can also be configured.
105
- - *State* to report the current version and the latest version available, again one topic per component, like `updates2mqtt/dockernuc/docker/jellyfin`.
106
- - *Command* to support triggering an update. These will be created on the fly by HomeAssistant when an update is requested, and updates2mqtt subscribes to pick up the changes, so you won't typically see these if browsing MQTT topics. Only one is needed per updates2mqtt agent, with a name like `updates2mqtt/dockernuc/docker`
132
+ | Env Var | Description | Default |
133
+ |---------| ------------|----------|
134
+ | `UPD2MQTT_UPDATE` | Update mode, either `Passive` or `Auto`. If `Auto`, updates will be installed automatically. | `Passive` |
135
+ | `UPD2MQTT_PICTURE` | URL to an icon to use in Home Assistant. | Docker logo URL |
136
+ | `UPD2MQTT_RELNOTES` | URL to release notes for the package. | |
137
+ | `UPD2MQTT_GIT_REPO_PATH` | Relative path to a local git repo if the image is built locally. | |
138
+ | `UPD2MQTT_IGNORE` | If set to `True`, the container will be ignored by updates2mqtt. | False |
107
139
 
108
- If the package supports automated update, then *Skip* and *Install* buttons will appear on the Home Assistant
109
- interface, and the package can be remotely fetched and the component restarted.
110
140
 
111
141
  ## Related Projects
112
142
 
@@ -114,6 +144,18 @@ Other apps useful for self-hosting with the help of MQTT:
114
144
 
115
145
  - [psmqtt](https://github.com/eschava/psmqtt) - Report system health and metrics via MQTT
116
146
 
147
+ Find more at [awesome-mqtt](https://github.com/rhizomatics/awesome-mqtt)
148
+
117
149
  ## Development
118
150
 
119
- Access to Docker APIs uses the Python [docker-py](https://docker-py.readthedocs.io/en/stable/) SDK for Python. [Eclipse Paho](https://eclipse.dev/paho/files/paho.mqtt.python/html/client.html) is used for MQTT access, and [OmegaConf](https://omegaconf.readthedocs.io) for configuration.
151
+ This component relies on several open source packages:
152
+
153
+ - [docker-py](https://docker-py.readthedocs.io/en/stable/) SDK for Python for access to Docker APIs
154
+ - [Eclipse Paho](https://eclipse.dev/paho/files/paho.mqtt.python/html/client.html) MQTT client
155
+ - [OmegaConf](https://omegaconf.readthedocs.io) for configuration and validation
156
+ - [structlog](https://www.structlog.org/en/stable/) for structured logging and [rich](https://rich.readthedocs.io/en/stable/) for better exception reporting
157
+ - [hishel](https://hishel.com/1.0/) for caching metadata
158
+ - [httpx](https://www.python-httpx.org) for retrieving metadata
159
+ - The Astral [uv](https://docs.astral.sh/uv/) and [ruff](https://docs.astral.sh/ruff/) tools for development and build
160
+ - [pytest](https://docs.pytest.org/en/stable/) and supporting add-ins for automated testing
161
+ - [usingversion](https://pypi.org/project/usingversion/) to log current version info
@@ -0,0 +1,124 @@
1
+ [![Rhizomatics Open Source](https://avatars.githubusercontent.com/u/162821163?s=96&v=4)](https://github.com/rhizomatics)
2
+
3
+ # updates2mqtt
4
+
5
+ [![PyPI - Version](https://img.shields.io/pypi/v/updates2mqtt)](https://pypi.org/project/updates2mqtt/)
6
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/rhizomatics/supernotify)
7
+ [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/rhizomatics/updates2mqtt/main.svg)](https://results.pre-commit.ci/latest/github/rhizomatics/updates2mqtt/main)
8
+ [![Publish Python 🐍 distribution 📦 to PyPI and TestPyPI](https://github.com/rhizomatics/updates2mqtt/actions/workflows/pypi-publish.yml/badge.svg)](https://github.com/rhizomatics/updates2mqtt/actions/workflows/pypi-publish.yml)
9
+ [![Github Deploy](https://github.com/rhizomatics/updates2mqtt/actions/workflows/python-package.yml/badge.svg?branch=main)](https://github.com/rhizomatics/updates2mqtt/actions/workflows/python-package.yml)
10
+ [![CodeQL](https://github.com/rhizomatics/updates2mqtt/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/rhizomatics/updates2mqtt/actions/workflows/github-code-scanning/codeql)
11
+ [![Dependabot Updates](https://github.com/rhizomatics/updates2mqtt/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/rhizomatics/updates2mqtt/actions/workflows/dependabot/dependabot-updates)
12
+
13
+ ## Summary
14
+
15
+ Let Home Assistant tell you about new updates to Docker images for your containers.
16
+
17
+ ![Example Home Assistant update page](images/ha_update_detail.png "Home Assistant Updates")
18
+
19
+ Read the release notes, and optionally click *Update* to trigger a Docker *pull* (or optionally *build*) and *update*.
20
+
21
+ ![Example Home Assistant update dialog](images/ha_update_dialog.png "Home Assistant Updates"){width=480}
22
+
23
+
24
+ ## Description
25
+
26
+ updates2mqtt perioidically checks for new versions of components being available, and publishes new version info to MQTT. HomeAssistant auto discovery is supported, so all updates can be seen in the same place as Home Assistant's own components and add-ins.
27
+
28
+ Currently only Docker containers are supported, either via an image registry check, or a git repo for source (see [Local Builds](local_builds.md)). The design is modular, so other update sources can be added, at least for notification. The next anticipated is **apt** for Debian based systems.
29
+
30
+ Components can also be updated, either automatically or triggered via MQTT, for example by hitting the *Install* button in the HomeAssistant update dialog. Icons and release notes can be specified for a better HA experience. See [Home Assistant Integration](home_assistant.md) for details.
31
+
32
+ To get started, read the [Installation](installation.md) and [Configuration](configuration.md) pages.
33
+
34
+ For a quick spin, try this:
35
+
36
+ ```yaml
37
+ docker run -e MQTT_USER=user1 -e MQTT_PASS=pass1 -e MQTT_HOST=192.168.1.5 ghcr.io/rhizomatics/updates2mqtt:release
38
+ ```
39
+
40
+ ## Release Support
41
+
42
+ Presently only Docker containers are supported, although others are planned, probably with priority for `apt`.
43
+
44
+ | Ecosystem | Support | Comments |
45
+ |-----------|-------------|----------------------------------------------------------------------------------------------------|
46
+ | Docker | Scan. Fetch | Fetch is ``docker pull`` only. Restart support only for ``docker-compose`` image based containers. |
47
+
48
+ ## Healthcheck
49
+
50
+ A heartbeat JSON payload is optionally published periodically to a configurable MQTT topic, defaulting to `healthcheck/{node_name}/updates2mqtt`. It contains the current version of updates2mqtt, the node name, a timestamp, and some basic stats.
51
+
52
+ A `healthcheck.sh` script is included in the Docker image, and can be used as a Docker healthcheck, if the container environment variables are set for `MQTT_HOST`, `MQTT_PORT`, `MQTT_USER` and `MQTT_PASS`. It uses the `mosquitto-clients` Linux package which provides `mosquitto_sub` command to subscribe to topics.
53
+
54
+ !!! tip
55
+
56
+ Check healthcheck is working using `docker inspect --format "{{json .State.Health }}" updates2mqtt | jq`
57
+
58
+ Another approach is using a restarter service directly in Docker Compose to force a restart, in this case once a day:
59
+
60
+ ```yaml title="Example Compose Service"
61
+ restarter:
62
+ image: docker:cli
63
+ volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
64
+ command: ["/bin/sh", "-c", "while true; do sleep 86400; docker restart updates2mqtt; done"]
65
+ restart: unless-stopped
66
+ environment:
67
+ - UPD2MQTT_UPDATE=AUTO
68
+ ```
69
+
70
+ ## Target Containers
71
+
72
+ While `updates2mqtt` will discover and monitor all containers running under the Docker daemon,
73
+ there are some options to make to those containers to tune how it works.
74
+
75
+ These happen by adding environment variables to the containers, typically inside an `.env`
76
+ file, or as `environment` options inside `docker-compose.yaml`.
77
+
78
+ ### Automated updates
79
+
80
+ If Docker containers should be immediately updated, without any confirmation
81
+ or trigger, *e.g.* from the HomeAssistant update dialog, then set an environment variable `UPD2MQTT_UPDATE` in the target container to `Auto` ( it defaults to `Passive`)
82
+
83
+ ```yaml title="Example Compose Snippet"
84
+ restarter:
85
+ image: docker:cli
86
+ command: ["/bin/sh", "-c", "while true; do sleep 86400; docker restart mailserver; done"]
87
+ environment:
88
+ - UPD2MQTT_UPDATE=AUTO
89
+ ```
90
+
91
+ ### Environment Variables
92
+
93
+ The following environment variables can be used to configure containers for `updates2mqtt`:
94
+
95
+ | Env Var | Description | Default |
96
+ |---------| ------------|----------|
97
+ | `UPD2MQTT_UPDATE` | Update mode, either `Passive` or `Auto`. If `Auto`, updates will be installed automatically. | `Passive` |
98
+ | `UPD2MQTT_PICTURE` | URL to an icon to use in Home Assistant. | Docker logo URL |
99
+ | `UPD2MQTT_RELNOTES` | URL to release notes for the package. | |
100
+ | `UPD2MQTT_GIT_REPO_PATH` | Relative path to a local git repo if the image is built locally. | |
101
+ | `UPD2MQTT_IGNORE` | If set to `True`, the container will be ignored by updates2mqtt. | False |
102
+
103
+
104
+ ## Related Projects
105
+
106
+ Other apps useful for self-hosting with the help of MQTT:
107
+
108
+ - [psmqtt](https://github.com/eschava/psmqtt) - Report system health and metrics via MQTT
109
+
110
+ Find more at [awesome-mqtt](https://github.com/rhizomatics/awesome-mqtt)
111
+
112
+ ## Development
113
+
114
+ This component relies on several open source packages:
115
+
116
+ - [docker-py](https://docker-py.readthedocs.io/en/stable/) SDK for Python for access to Docker APIs
117
+ - [Eclipse Paho](https://eclipse.dev/paho/files/paho.mqtt.python/html/client.html) MQTT client
118
+ - [OmegaConf](https://omegaconf.readthedocs.io) for configuration and validation
119
+ - [structlog](https://www.structlog.org/en/stable/) for structured logging and [rich](https://rich.readthedocs.io/en/stable/) for better exception reporting
120
+ - [hishel](https://hishel.com/1.0/) for caching metadata
121
+ - [httpx](https://www.python-httpx.org) for retrieving metadata
122
+ - The Astral [uv](https://docs.astral.sh/uv/) and [ruff](https://docs.astral.sh/ruff/) tools for development and build
123
+ - [pytest](https://docs.pytest.org/en/stable/) and supporting add-ins for automated testing
124
+ - [usingversion](https://pypi.org/project/usingversion/) to log current version info
@@ -4,7 +4,8 @@ Create file `config.yaml` in `conf` directory. If the file is not present, a def
4
4
 
5
5
  ### Example configuration file
6
6
 
7
- This is a maximal config file, the minimum is no config file at all, which will generate a default config file. The only mandatory values are the MQTT user name and password, everything else can be omitted.
7
+ This is a maximal config file, the minimum is no config file at all, which will generate a default config file. The only mandatory values are the MQTT user name and password, everything else can be omitted ( although
8
+ its best to have at least a `node` `name` value so HomeAssistant doesn't show some ugly generated Docker host name).
8
9
 
9
10
  ```yaml
10
11
 
@@ -21,6 +22,7 @@ mqtt:
21
22
  password: ${oc.env:MQTT_PASS}$ # Use an environment variable for secrets
22
23
  port: ${oc.env:MQTT_PORT}
23
24
  topic_root: updates2mqtt
25
+ protocol: 3.11 # Can be changed to 5 if your broker supports it
24
26
  homeassistant:
25
27
  discovery:
26
28
  prefix: homeassistant # Matches the default MQTT discovery prefix in Home Assistant
@@ -44,6 +46,8 @@ log:
44
46
  level: INFO
45
47
  ```
46
48
 
49
+ ## Improving Security
50
+
47
51
  ### Moving Secrets Out of Config
48
52
 
49
53
  Example use of environment variables, e.g. for secrets:
@@ -52,7 +56,50 @@ Example use of environment variables, e.g. for secrets:
52
56
  mqtt:
53
57
  password: ${oc.env:MQTT_PASS}
54
58
  ```
55
- ### Customizing images and release notes
59
+
60
+ ### Running as non-root
61
+
62
+ It is good practice not to run Docker containers as root, and `updates2mqtt` will
63
+ work with any user so long as it has Docker permissions, usually as a result
64
+ of being a member of the `docker` group.
65
+
66
+ To create a suitable use, use the shell command below - it will create a user
67
+ that can only be used for this purpose, and can't otherwise login. It assumes there is already a group called `docker` with access to the Docker Daemon, if you dont
68
+ have one, follow the [Docker Post Install Steps](https://docs.docker.com/engine/install/linux-postinstall/) which explain how and why to do it.
69
+
70
+ ```bash
71
+ sudo adduser --system --ingroup docker --no-create-home -shell /sbin/nologin updates2mqtt
72
+ ```
73
+
74
+ Note the `uid` that is reported here. If you don't know the `gid` for the `docker` group, use `grep docker /etc/group`. In this example, our `uid` is `130` and the `gid` of `docker` group is `119`.
75
+
76
+ In the `docker-compose.yaml`, set the user and group using [user](https://docs.docker.com/reference/compose-file/services/#user) attribute:
77
+
78
+ ```yaml
79
+ services:
80
+ updates2mqtt:
81
+ container_name: updates2mqtt
82
+ image: ghcr.io/rhizomatics/updates2mqtt:release
83
+ user: 130:119
84
+ ```
85
+
86
+ If you're using Updates2MQTT to update local git repos, then the user created above will also need `rw` access to those, which you can do by making it a member of the
87
+ same group as owns the repos and making sure they have group `rw` access configured.
88
+
89
+ For more information, see the [Understanding the Docker USER Instruction](https://www.docker.com/blog/understanding-the-docker-user-instruction/) article from Docker.
90
+
91
+ ### MQTT Access Control
92
+
93
+ Its best to have a dedicated MQTT user for Updates2MQTT, for security and debug. For most
94
+ secure installations, only use secure ports with validated certificates, although this will
95
+ require more complicated setup and ongoing support, including using host names rather than
96
+ IP addresses, and with [LetsEncrypt](https://letsencrypt.org) to update certificates.
97
+
98
+ The two brokers most commonly used with Home Assistant, **Mosquitto** and **EMQX**, both have
99
+ access control mechanisms, so you can restrict the user account for Updates2MQTT to only be able
100
+ to read and write its own topics.
101
+
102
+ ## Customizing images and release notes
56
103
 
57
104
  Individual docker containers can have customized entity pictures or release notes, using env variables, for example in the `docker-compose.yaml` or in a separate `.env` file:
58
105
 
@@ -65,6 +112,7 @@ Individual docker containers can have customized entity pictures or release note
65
112
  The images will show up in the *Update* section of *Settings* menu in HomeAssistant,
66
113
  as will the release notes link. SVG icons should be used.
67
114
 
115
+
68
116
  #### Icon Sources
69
117
 
70
118
  Updates look nicer in Home Assistant with a suitable icon. Updates2mqtt comes
@@ -79,20 +127,3 @@ If you have something not covered, here are some good places to look for self-ho
79
127
  - [Papirus Icons](https://github.com/PapirusDevelopmentTeam/papirus-icon-theme)
80
128
  - [Homelab SVG Assets](https://github.com/loganmarchione/homelab-svg-assets)
81
129
 
82
- ### Automated updates
83
-
84
- If Docker containers should be immediately updated, without any confirmation
85
- or trigger, *e.g.* from the HomeAssistant update dialog, then set an environment variable `UPD2MQTT_UPDATE` in the target container to `Auto` ( it defaults to `Passive`)
86
-
87
-
88
- ### Environment Variables
89
-
90
- The following environment variables can be used to configure updates2mqtt:
91
-
92
- | Env Var | Description | Default |
93
- |---------| ------------|----------|
94
- | `UPD2MQTT_UPDATE` | Update mode, either `Passive` or `Auto`. If `Auto`, updates will be installed automatically. | `Passive` |
95
- | `UPD2MQTT_PICTURE` | URL to an icon to use in Home Assistant. | Docker logo URL |
96
- | `UPD2MQTT_RELNOTES` | URL to release notes for the package. | |
97
- | `UPD2MQTT_GIT_REPO_PATH` | Relative path to a local git repo if the image is built locally. | |
98
- | `UPD2MQTT_IGNORE` | If set to `True`, the container will be ignored by updates2mqtt. | False |
@@ -0,0 +1,34 @@
1
+ # HomeAssistant Integration
2
+
3
+ `updates2mqtt` represents each component being managed as a [MQTT Update](https://www.home-assistant.io/integrations/update.mqtt/) entity, and uses [MQTT discovery](https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery) so that HomeAssistant automatically picks up components discovered by updates2mqtt with zero configuration on HomeAssistant itself.
4
+
5
+ ## Configuration
6
+
7
+ If Home Assistant is already running with MQTT, and the defaults haven't been changed, then
8
+ `updates2mqtt` will likely work as is, so long as its publishing to the same broker.
9
+
10
+ Any updates that have support for automated install will automatically show in the
11
+ Home Assistant settings page if the [MQTT Integration](https://www.home-assistant.io/integrations/mqtt/) is installed and automatic discovery is not disabled.
12
+
13
+ ![Home Assistant MQTT Integration configuration](images/ha_mqtt_discovery.png "Home Assistant MQTT Discovery")
14
+
15
+ The `homeassistant` default topic prefix matches the default updates2mqtt config, if its changed in HomeAssistant, then the updates2mqtt config must be changed to match.
16
+
17
+ ![Home Assistant updates in Settings](images/ha_update_page.png "Home Assistant Updates")
18
+
19
+ ## MQTT Topics
20
+
21
+ There are 3 separate types of MQTT topic used for HomeAssisstant integration:
22
+
23
+ - *Config* to support auto discovery. A topic is created per component, with a name like `homeassistant/update/dockernuc_docker_jellyfin/update/config`. This can be disabled in the config file, and the `homeassistant` topic prefix can also be configured.
24
+ - *State* to report the current version and the latest version available, again one topic per component, like `updates2mqtt/dockernuc/docker/jellyfin`.
25
+ - *Command* to support triggering an update. These will be created on the fly by HomeAssistant when an update is requested, and updates2mqtt subscribes to pick up the changes, so you won't typically see these if browsing MQTT topics. Only one is needed per updates2mqtt agent, with a name like `updates2mqtt/dockernuc/docker`
26
+
27
+ If the package supports automated update, then *Skip* and *Install* buttons will appear on the Home Assistant interface, and the package can be remotely fetched and the component restarted.
28
+
29
+ ## More Home Assistant information
30
+
31
+ - [MQTT Integration](https://www.home-assistant.io/integrations/mqtt/)
32
+ - Includes setting up a MQTT broker, MQTT Discovery, and trouble-shooting
33
+ - [MQTT Update](https://www.home-assistant.io/integrations/update.mqtt/)
34
+ - [Update Integration](https://www.home-assistant.io/integrations/update/)
@@ -4,6 +4,8 @@
4
4
 
5
5
  updates2mqtt prefers to be run inside a Docker container, though can run standalone, for example scripted via cron or systemd.
6
6
 
7
+ The only mandatory configuration is the MQTT broker host, user name and password, which can be set by environment variable, or the config file. See [Configuration](configuration.md).
8
+
7
9
  ### Docker
8
10
 
9
11
  See `examples` directory for a working `docker-compose.yaml`.
@@ -27,3 +29,16 @@ uv run --with updates2mqtt updates2mqtt
27
29
  pip install updates2mqtt
28
30
  python3 -m updates2mqtt
29
31
  ```
32
+
33
+ ## Verifying it Works
34
+
35
+ Rather than wait for a container to need an update, you can check right away that
36
+ Home Assistant has recognized the containers as MQTT Update targets.
37
+
38
+ From the [Entities View](https://www.home-assistant.io/docs/configuration/entities_domains/), or the
39
+ [Developer Tools](https://www.home-assistant.io/docs/tools/dev-tools/), filter
40
+ the entities by `update.` If there are lots of other updates (HassOS apps, Zigbee
41
+ device firmware etc), then pick one of the container names you know.
42
+
43
+ ![Home Assistant Entities](images/ha_entities.png){width=640}
44
+