RPi-Reporter-MQTT2HA-Daemon
RPi-Reporter-MQTT2HA-Daemon copied to clipboard
how to install in docker
I'm using docker to keep applications contained (IOTstack) and easily maintainable.
It would be great if you can explain how to run this from Docker or have your deamon be part of the IOTstack-project
I can write a Dockerfile for this, but which capabilities/mounts its needed from RPi host ?
Hi mvcaaa, thx for your reply. I’m not sure what you mean with capabilities/mounts. Currently I’m using the IOTstack provided docker-compose file. It would be nice if I can add the RPI-monitor to that file.
Did anything come of this in Docker? I run HA via docker, but if i follow your instructions to install in the opt directory, which isnt where my docker files are, could it still pass through to my MQTT docker install?
This looks like a really nice tool - I would love to see a docker container for this
For those interested in Docker images still I've added an automation that produced unofficial Docker images out of latest release, https://github.com/hostcc/RPi-Reporter-MQTT2HA-Daemon-docker.
Using that is as simple as doing docker pull ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:v1.8.5
(as of writing)
doing docker pull ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:v1.8.5
Hi, I did docker pull ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:v1.8.5. Whats the next step to run this in docker?
@andersnorlin , apologies for omitting that - I thought I've added some instructions.
You could run it using the command:
docker run -d /dev/vcio:/dev/vcio -v <path to directory where you put the configuration file>:/etc/rpi-mqtt-daemon/:ro --security-opt="systempaths=unconfined" --group-add video ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:v1.8.5
Explanation on specific options:
-
--security-opt="systempaths=unconfined
is needed to unblock access to/proc/device-tree/
from within the container (for model identification) -
-d /dev/vcio:/dev/vcio
exposes the/dev/vcio
device to container since it is required byvcgencmd
(temperatures and throttling on RPi), and--group-add video
allows the regular user (the process in the container runs asnobody
) to interact with the/dev/vcio
device
You could run it using the command:
docker run -d /dev/vcio:/dev/vcio -v <path to directory where you put the configuration file>:/etc/rpi-mqtt-daemon/:ro --security-opt="systempaths=unconfined" --group-add video ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:v1.8.5
I have the config here from trying the install out of docker
/opt/RPi-Reporter-MQTT2HA-Daemon/config.ini
Should I use that location for "path to directory where you put the configuration file"
Tried this
sudo docker run -d /dev/vcio:/dev/vcio -v /opt/RPi-Reporter-MQTT2HA-Daemon/config.ini:/etc/rpi-mqtt-daemon/:ro --security-opt="systempaths=unconfined" --group-add video ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:v1.8.5
Got docker: invalid reference format.
Thank's Anders
@andersnorlin
have the config here from trying the install out of docker
/opt/RPi-Reporter-MQTT2HA-Daemon/config.ini
Should I use that location for "path to directory where you put the configuration file"
Basically the source and destination in volume mount should be same type of entities (file to file, or path to path).
So it'd be -v /opt/RPi-Reporter-MQTT2HA-Daemon/config.ini:/etc/rpi-mqtt-daemon/config.ini:ro
or -v /opt/RPi-Reporter-MQTT2HA-Daemon/:/etc/rpi-mqtt-daemon/:ro
. I'm using the latter, in case I'd need more than one file exposed from the directory on the host (e.g. certificates). But either would work for an initial attempt
Tried this
sudo docker run -d /dev/vcio:/dev/vcio -v /opt/RPi-Reporter-MQTT2HA-Daemon/config.ini:/etc/rpi-mqtt-daemon/:ro --security-opt="systempaths=unconfined" --group-add video ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:v1.8.5
I provided wrong command initially (was too reliant on my memory for -d
that in fact should be --device
, sorry), the correct one is
sudo docker run --device /dev/vcio:/dev/vcio -v /opt/RPi-Reporter-MQTT2HA-Daemon/config.ini:/etc/rpi-mqtt-daemon/:ro --security-opt="systempaths=unconfined" --group-add video ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:v1.8.5
This started the docker container.
sudo docker run -itd --restart=unless-stopped --net=host --device /dev/vcio:/dev/vcio -v /opt/RPi-Reporter-MQTT2HA-Daemon/:/etc/rpi-mqtt-daemon/:ro --security-opt="systempaths=unconfined" --group-add video ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:v1.8.5
But nothing comes through the mqtt service to homeassist?
sudo docker logs 0c1812348611
/usr/local/lib/python3.10/site-packages/tzlocal/unix.py:192: UserWarning: Can not find any timezone configuration, defaulting to UTC.
warnings.warn("Can not find any timezone configuration, defaulting to UTC.")
[2023-09-13 19:58:40] * NOTIFY: * MQTT connection established
[2023-09-13 19:58:40]
[2023-09-13 19:58:40] * NOTIFY: MQTT subscription to home/nodes/command/rpi-{hostname}/+ enabled
Traceback (most recent call last):
File "/usr/local/bin/rpi-mqtt-daemon", line 1342, in
@andersnorlin , to address the issue below running the daemon in container I've submitted https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon/pull/107 once - I'll look at publishing the image off of that. I'm running that version for some weeks already with pretty good results
@andersnorlin , I've prepared the image out of #107 (corresponds to d1168a5
below) - you could give it a try:
ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:d1168a5
@andersnorlin , I've prepared the image out of #107 (corresponds to
d1168a5
below) - you could give it a try:
ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:d1168a5
Thanks, I have updated and get this log, connection lost
andersnorlin@raspberrypi:~ $ sudo docker logs 0c1812348611
/usr/local/lib/python3.10/site-packages/tzlocal/unix.py:192: UserWarning: Can not find any timezone configuration, defaulting to UTC.
warnings.warn("Can not find any timezone configuration, defaulting to UTC.")
[2023-09-13 19:58:40] * NOTIFY: * MQTT connection established
[2023-09-13 19:58:40]
[2023-09-13 19:58:40] * NOTIFY: MQTT subscription to home/nodes/command/rpi-{hostname}/+ enabled
Traceback (most recent call last):
File "/usr/local/bin/rpi-mqtt-daemon", line 1342, in
@andersnorlin , I've prepared the image out of #107 (corresponds to
d1168a5
below) - you could give it a try:
ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:d1168a5
Hi,
My bad did a mistake when starting your new build. It looks like it should work from the logs but nothing gets propagated in to home assistant. See logs
andersnorlin@raspberrypi:~/hass/docker $ sudo docker logs f845448befac /usr/local/lib/python3.10/site-packages/tzlocal/unix.py:192: UserWarning: Can not find any timezone configuration, defaulting to UTC. warnings.warn("Can not find any timezone configuration, defaulting to UTC.") [2023-09-15 17:05:24] * NOTIFY: * MQTT connection established [2023-09-15 17:05:24] [2023-09-15 17:05:24] * NOTIFY: MQTT subscription to home/nodes/command/rpi-{hostname}/+ enabled [2023-09-15 17:05:25] Announcing RPi Monitoring device to MQTT broker for auto-discovery ... [2023-09-15 17:05:28] Publishing to MQTT topic "home/nodes/sensor/rpi-{hostname}/monitor, Data:{"info": {"timestamp": "2023-09-15T17:05:25+00:00", "rpi_model": "RPi 4 Model B r1.5\u0000", "ifaces": "e,w,b", "host_name": "raspberrypi", "fqdn": "raspberrypi", "ux_release": "N/A", "ux_version": "6.1.21-v8+", "ux_updates": -1, "up_time": " 7:37", "up_time_secs": 27420, "last_update": "", "fs_total_gb": 32, "fs_free_prcnt": 28, "fs_used_prcnt": 72, "networking": {"eth0": {"mac": "D8:3A:DD:36:B5:18", "IP": ""}, "wlan0": {"mac": "D8:3A:DD:36:B5:19"}}, "drives": {"root": {"size_gb": 32, "used_prcnt": 72, "device": "overlay", "mount_pt": "/"}, "dev-shm": {"size_gb": 0, "used_prcnt": 0, "device": "shm", "mount_pt": "/dev/shm"}, "etc-rpi-mqtt-daemon": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/rpi-mqtt-daemon"}, "etc-resolv.conf": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/resolv.conf"}, "etc-hostname": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/hostname"}, "etc-hosts": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/hosts"}}, "memory": {"size_mb": 3555, "free_mb": 1843, "size_swap": 500, "free_swap": 500}, "mem_used_prcnt": 48, "cpu": {"hardware": "BCM2835", "model": "", "number_cores": 4, "bogo_mips": "432.00", "serial": "10000000c0df56f7", "load_1min_prcnt": 29.5, "load_5min_prcnt": 29.8, "load_15min_prcnt": 31.2}, "temperature_c": 56.5, "temp_gpu_c": -1.0, "temp_cpu_c": 56.5, "reporter": "ISP-RPi-mqtt-daemon v1.8.5", "reporter_releases": "v1.8.5,v1.7.2,v1.7.3,v1.7.4,v1.8.3,v1.8.4", "report_interval": 5}}"
It's not getting a hostname, hardcode/set one or make sure you've checked the installation around hostname.
On Fri, 15 Sep 2023, 18:13 andersnorlin, @.***> wrote:
@andersnorlin https://github.com/andersnorlin , I've prepared the image out of #107 https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon/pull/107 (corresponds to d1168a5 below) - you could give it a try:
ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:d1168a5
Hi,
My bad did a mistake when starting tour new build. It looks like it should work from the logs but nothing gets propagated in to home assistant. See logs
@.***:~/hass/docker $ sudo docker logs f845448befac /usr/local/lib/python3.10/site-packages/tzlocal/unix.py:192: UserWarning: Can not find any timezone configuration, defaulting to UTC. warnings.warn("Can not find any timezone configuration, defaulting to UTC.") [2023-09-15 17:05:24] * NOTIFY: * MQTT connection established [2023-09-15 17:05:24] [2023-09-15 17:05:24] * NOTIFY: MQTT subscription to home/nodes/command/rpi-{hostname}/+ enabled [2023-09-15 17:05:25] Announcing RPi Monitoring device to MQTT broker for auto-discovery ... [2023-09-15 17:05:28] Publishing to MQTT topic "home/nodes/sensor/rpi-{hostname}/monitor, Data:{"info": {"timestamp": "2023-09-15T17:05:25+00:00", "rpi_model": "RPi 4 Model B r1.5\u0000", "ifaces": "e,w,b", "host_name": "raspberrypi", "fqdn": "raspberrypi", "ux_release": "N/A", "ux_version": "6.1.21-v8+", "ux_updates": -1, "up_time": " 7:37", "up_time_secs": 27420, "last_update": "", "fs_total_gb": 32, "fs_free_prcnt": 28, "fs_used_prcnt": 72, "networking": {"eth0": {"mac": "D8:3A:DD:36:B5:18", "IP": ""}, "wlan0": {"mac": "D8:3A:DD:36:B5:19"}}, "drives": {"root": {"size_gb": 32, "used_prcnt": 72, "device": "overlay", "mount_pt": "/"}, "dev-shm": {"size_gb": 0, "used_prcnt": 0, "device": "shm", "mount_pt": "/dev/shm"}, "etc-rpi-mqtt-daemon": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/rpi-mqtt-daemon"}, "etc-resolv.conf": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/resolv.conf"}, "etc-hostname": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/hostname"}, "etc-hosts": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/hosts"}}, "memory": {"size_mb": 3555, "free_mb": 1843, "size_swap": 500, "free_swap": 500}, "mem_used_prcnt": 48, "cpu": {"hardware": "BCM2835", "model": "", "number_cores": 4, "bogo_mips": "432.00", "serial": "10000000c0df56f7", "load_1min_prcnt": 29.5, "load_5min_prcnt": 29.8, "load_15min_prcnt": 31.2}, "temperature_c": 56.5, "temp_gpu_c": -1.0, "temp_cpu_c": 56.5, "reporter": "ISP-RPi-mqtt-daemon v1.8.5", "reporter_releases": "v1.8.5,v1.7.2,v1.7.3,v1.7.4,v1.8.3,v1.8.4", "report_interval": 5}}"
— Reply to this email directly, view it on GitHub https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon/issues/21#issuecomment-1721600144, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYAXNZDY3HMMPODYRVIRTLX2SEEDANCNFSM4TB5KY3Q . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>
@hostcc
🥳 I got it up and running now did some rookie mistakes in the configuration files but now it works.
Thanks 🙏
Why do I get this ?
UserWarning: Can not find any timezone configuration, defaulting to UTC.
Search the other posts, I'm sure it has cropped up before. Whatever you're using either doesn't have it set or cannot report it.
On Fri, 15 Sep 2023, 19:11 andersnorlin, @.***> wrote:
Why do I get this ?
UserWarning: Can not find any timezone configuration, defaulting to UTC.
— Reply to this email directly, view it on GitHub https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon/issues/21#issuecomment-1721662390, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYAXN7TKPZPZ5PBBQZPPTDX2SK3RANCNFSM4TB5KY3Q . You are receiving this because you commented.Message ID: @.***>
Why do I get this ?
UserWarning: Can not find any timezone configuration, defaulting to UTC.
I'll check, I think I might forgotten to add a tzinfo package or alike.
@hostcc
🥳 I got it up and running now did some rookie mistakes in the configuration files but now it works.
Thanks 🙏
@andersnorlin, congrats - glad it finally worked out for you!
You might want to add -v /etc/apt:/etc/apt:ro -v /var/lib/apt/:/var/lib/apt/:ro
to the Docker options to run the container, that should get you OS update information reported.
@hostcc
🥳 I got it up and running now did some rookie mistakes in the configuration files but now it works.
Thanks 🙏
@andersnorlin, congrats - glad it finally worked out for you!
You might want to add
-v /etc/apt:/etc/apt:ro -v /var/lib/apt/:/var/lib/apt/:ro
to the Docker options to run the container, that should get you OS update information reported.
Like this? Still get Updated = "invalid date"
sudo docker run -itd --restart=unless-stopped --net=host --device /dev/vcio:/dev/vcio -v /home/andersnorlin/hass/docker/RPi-Reporter-MQTT2HA-Daemon/:/etc/rpi-mqtt-daemon/:ro -v /etc/apt:/etc/apt:ro -v /var/lib/apt/:/var/lib/apt/:ro --security-opt="systempaths=unconfined" --group-add video ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:d1168a5
You might want to add
-v /etc/apt:/etc/apt:ro -v /var/lib/apt/:/var/lib/apt/:ro
to the Docker options to run the container, that should get you OS update information reported.Like this? Still get Updated = "invalid date"
sudo docker run -itd --restart=unless-stopped --net=host --device /dev/vcio:/dev/vcio -v /home/andersnorlin/hass/docker/RPi-Reporter-MQTT2HA-Daemon/:/etc/rpi-mqtt-daemon/:ro -v /etc/apt:/etc/apt:ro -v /var/lib/apt/:/var/lib/apt/:ro --security-opt="systempaths=unconfined" --group-add video ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:d1168a5
@andersnorlin, I did miss another mount, apologies
Just tested on my setup: you'll also need - /var/lib/dpkg/:/var/lib/dpkg/:ro
.
Resulting additions to detect package updates: - /var/lib/dpkg/:/var/lib/dpkg/:ro -v /etc/apt:/etc/apt:ro -v /var/lib/apt/:/var/lib/apt/:ro
.
Also, I verified a change to fix Can not find any timezone configuration, defaulting to UTC
warning - just add -v /usr/share/zoneinfo/UTC:/etc/localtime:ro
(it will default to UTC timezone to the daemon. You could use your local timezone if needed - just look at /usr/share/zoneinfo/
on the host, pick the timezone file and use it instead of /usr/share/zoneinfo/UTC
That fixed everything now it looks super. Many thank's 🙏
// RPI Monitor OK sudo docker run -itd --restart=unless-stopped --net=host --device /dev/vcio:/dev/vcio -v /home/andersnorlin/hass/docker/RPi-Reporter-MQTT2HA-Daemon/:/etc/rpi-mqtt-daemon/:ro -v /var/lib/dpkg/:/var/lib/dpkg/:ro -v /etc/apt:/etc/apt:ro -v /var/lib/apt/:/var/lib/apt/:ro -v /usr/share/zoneinfo/Europe/Stockholm:/etc/localtime:ro --security-opt="systempaths=unconfined" --group-add video ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:d1168a5
andersnorlin@raspberrypi:~/hass $ sudo docker logs dcad6ad9fb32 [2023-09-15 21:21:14] * NOTIFY: * MQTT connection established [2023-09-15 21:21:14] [2023-09-15 21:21:14] * NOTIFY: MQTT subscription to home/nodes/command/raspberrypi/+ enabled [2023-09-15 21:21:15] Announcing RPi Monitoring device to MQTT broker for auto-discovery ... [2023-09-15 21:21:18] Publishing to MQTT topic "home/nodes/sensor/raspberrypi/monitor, Data:{"info": {"timestamp": "2023-09-15T21:21:15+02:00", "rpi_model": "RPi 4 Model B r1.5\u0000", "ifaces": "e,w,b", "host_name": "raspberrypi", "fqdn": "raspberrypi", "ux_release": "bullseye", "ux_version": "6.1.21-v8+", "ux_updates": -1, "up_time": " 1:47", "up_time_secs": 6420, "last_update": "2023-09-15T20:35:50+02:00", "fs_total_gb": 32, "fs_free_prcnt": 28, "fs_used_prcnt": 72, "networking": {"eth0": {"mac": "D8:3A:DD:36:B5:18", "IP": ""}, "wlan0": {"mac": "D8:3A:DD:36:B5:19"}}, "drives": {"root": {"size_gb": 32, "used_prcnt": 72, "device": "overlay", "mount_pt": "/"}, "dev-shm": {"size_gb": 0, "used_prcnt": 0, "device": "shm", "mount_pt": "/dev/shm"}, "etc-rpi-mqtt-daemon": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/rpi-mqtt-daemon"}, "etc-apt": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/apt"}, "etc-localtime": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/localtime"}, "etc-resolv.conf": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/resolv.conf"}, "etc-hostname": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/hostname"}, "etc-hosts": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/etc/hosts"}, "var-lib-dpkg": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/var/lib/dpkg"}, "var-lib-apt": {"size_gb": 32, "used_prcnt": 72, "device": "/dev/root", "mount_pt": "/var/lib/apt"}}, "memory": {"size_mb": 3555, "free_mb": 2127, "size_swap": 500, "free_swap": 500}, "mem_used_prcnt": 40, "cpu": {"hardware": "BCM2835", "model": "", "number_cores": 4, "bogo_mips": "432.00", "serial": "10000000c0df56f7", "load_1min_prcnt": 34.8, "load_5min_prcnt": 34.8, "load_15min_prcnt": 33.2}, "temperature_c": 54.0, "temp_gpu_c": -1.0, "temp_cpu_c": 54.0, "reporter": "ISP-RPi-mqtt-daemon v1.8.5", "reporter_releases": "v1.8.5,v1.7.2,v1.7.3,v1.7.4,v1.8.3,v1.8.4", "report_interval": 5}}"
That fixed everything now it looks super. Many thank's 🙏
Very pleased to help! I'll now finally add some docs on how to run the Docker image - thanks for testing, @andersnorlin !
@andersnorlin , I've added support for APT packages to the image - when you'd pull it again, the daemon should be able to report on last update/pending updates status.
@andersnorlin , I've added support for APT packages to the image - when you'd pull it again, the daemon should be able to report on last update/pending updates status.
I did
docker pull ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:latest
Is that right? It does not work for me now it crashes at
sudo docker logs ed666172e9d4
[2023-09-16 20:29:09] * NOTIFY: * MQTT connection established
[2023-09-16 20:29:09]
[2023-09-16 20:29:09] * NOTIFY: MQTT subscription to home/nodes/command/raspberrypi/+ enabled
Traceback (most recent call last):
File "/usr/local/bin/rpi-mqtt-daemon", line 1342, in
@andersnorlin , I've added support for APT packages to the image - when you'd pull it again, the daemon should be able to report on last update/pending updates status.
I did
docker pull ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:latest
Is that right? It does not work for me now it crashes at
Until #107 would get merged we'll have to use ghcr.io/hostcc/rpi-reporter-mqtt2ha-daemon-docker:d1168a5 (which effectively built from #107), sorry for not highlighting that.
Looks like this for me