GithubHelp home page GithubHelp logo

Comments (28)

hostcc avatar hostcc commented on June 5, 2024 2

@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 by vcgencmd (temperatures and throttling on RPi), and --group-add video allows the regular user (the process in the container runs as nobody) to interact with the /dev/vcio device

from rpi-reporter-mqtt2ha-daemon.

andersnorlin avatar andersnorlin commented on June 5, 2024 2

Looks like this for me

image

from rpi-reporter-mqtt2ha-daemon.

andersnorlin avatar andersnorlin commented on June 5, 2024 1

@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
getNetworkIFs() # this will fill-in rpi_mac
File "/usr/local/bin/rpi-mqtt-daemon", line 799, in getNetworkIFs
getNetworkIFsUsingIP(ip_cmd)
File "/usr/local/bin/rpi-mqtt-daemon", line 679, in getNetworkIFsUsingIP
loadNetworkIFDetailsFromLines(trimmedLines)
File "/usr/local/bin/rpi-mqtt-daemon", line 747, in loadNetworkIFDetailsFromLines
newTuple = (imterfc, 'mac', lineParts[4])
IndexError: list index out of range
[2023-09-13 21:08:58] * NOTIFY: * MQTT connection lost

from rpi-reporter-mqtt2ha-daemon.

bsimmo avatar bsimmo commented on June 5, 2024 1

from rpi-reporter-mqtt2ha-daemon.

hostcc avatar hostcc commented on June 5, 2024 1

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

from rpi-reporter-mqtt2ha-daemon.

hostcc avatar hostcc commented on June 5, 2024 1

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 !

from rpi-reporter-mqtt2ha-daemon.

mvcaaa avatar mvcaaa commented on June 5, 2024

I can write a Dockerfile for this, but which capabilities/mounts its needed from RPi host ?

from rpi-reporter-mqtt2ha-daemon.

Tankdoz avatar Tankdoz commented on June 5, 2024

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.

from rpi-reporter-mqtt2ha-daemon.

jgeorge1983 avatar jgeorge1983 commented on June 5, 2024

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?

from rpi-reporter-mqtt2ha-daemon.

simowilso avatar simowilso commented on June 5, 2024

This looks like a really nice tool - I would love to see a docker container for this

from rpi-reporter-mqtt2ha-daemon.

hostcc avatar hostcc commented on June 5, 2024

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)

from rpi-reporter-mqtt2ha-daemon.

andersnorlin avatar andersnorlin commented on June 5, 2024

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?

from rpi-reporter-mqtt2ha-daemon.

andersnorlin avatar andersnorlin commented on June 5, 2024

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

from rpi-reporter-mqtt2ha-daemon.

hostcc avatar hostcc commented on June 5, 2024

@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

from rpi-reporter-mqtt2ha-daemon.

andersnorlin avatar andersnorlin commented on June 5, 2024

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
getNetworkIFs() # this will fill-in rpi_mac
File "/usr/local/bin/rpi-mqtt-daemon", line 799, in getNetworkIFs
getNetworkIFsUsingIP(ip_cmd)
File "/usr/local/bin/rpi-mqtt-daemon", line 679, in getNetworkIFsUsingIP
loadNetworkIFDetailsFromLines(trimmedLines)
File "/usr/local/bin/rpi-mqtt-daemon", line 747, in loadNetworkIFDetailsFromLines
newTuple = (imterfc, 'mac', lineParts[4])
IndexError: list index out of range

from rpi-reporter-mqtt2ha-daemon.

hostcc avatar hostcc commented on June 5, 2024

@andersnorlin , to address the issue below running the daemon in container I've submitted #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

from rpi-reporter-mqtt2ha-daemon.

hostcc avatar hostcc commented on June 5, 2024

@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

from rpi-reporter-mqtt2ha-daemon.

andersnorlin avatar andersnorlin commented on June 5, 2024

@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}}"

from rpi-reporter-mqtt2ha-daemon.

andersnorlin avatar andersnorlin commented on June 5, 2024

@hostcc

šŸ„³ I got it up and running now did some rookie mistakes in the configuration files but now it works.

Thanks šŸ™

image

from rpi-reporter-mqtt2ha-daemon.

andersnorlin avatar andersnorlin commented on June 5, 2024

Why do I get this ?

UserWarning: Can not find any timezone configuration, defaulting to UTC.

from rpi-reporter-mqtt2ha-daemon.

bsimmo avatar bsimmo commented on June 5, 2024

from rpi-reporter-mqtt2ha-daemon.

hostcc avatar hostcc commented on June 5, 2024

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.

from rpi-reporter-mqtt2ha-daemon.

hostcc avatar hostcc commented on June 5, 2024

@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.

from rpi-reporter-mqtt2ha-daemon.

andersnorlin avatar andersnorlin commented on June 5, 2024

@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

from rpi-reporter-mqtt2ha-daemon.

andersnorlin avatar andersnorlin commented on June 5, 2024

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

image

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}}"

from rpi-reporter-mqtt2ha-daemon.

hostcc avatar hostcc commented on June 5, 2024

@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.

from rpi-reporter-mqtt2ha-daemon.

andersnorlin avatar andersnorlin commented on June 5, 2024

@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
getNetworkIFs() # this will fill-in rpi_mac
File "/usr/local/bin/rpi-mqtt-daemon", line 799, in getNetworkIFs
getNetworkIFsUsingIP(ip_cmd)
File "/usr/local/bin/rpi-mqtt-daemon", line 679, in getNetworkIFsUsingIP
loadNetworkIFDetailsFromLines(trimmedLines)
File "/usr/local/bin/rpi-mqtt-daemon", line 747, in loadNetworkIFDetailsFromLines
newTuple = (imterfc, 'mac', lineParts[4])
IndexError: list index out of range

from rpi-reporter-mqtt2ha-daemon.

hostcc avatar hostcc commented on June 5, 2024

@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.

from rpi-reporter-mqtt2ha-daemon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.