GithubHelp home page GithubHelp logo

ironsheep / rpi-reporter-mqtt2ha-daemon Goto Github PK

View Code? Open in Web Editor NEW
427.0 19.0 61.0 1.8 MB

Linux service to collect and transfer Raspberry Pi data via MQTT to Home Assistant (for RPi Monitoring)

License: GNU General Public License v3.0

Python 86.35% Shell 13.51% JavaScript 0.13%
home-assistant hassio sensor rpi daemon raspberry-pi mqtt mqtt-discovery systemd-service linux-daemon

rpi-reporter-mqtt2ha-daemon's Introduction

RPi Reporter MQTT2HA Daemon

Project Maintenance

GitHub Activity

License: GPL v3

GitHub Release

A simple Linux python script to query the Raspberry Pi on which it is running for various configuration and status values which it then reports via via MQTT to your Home Assistant installation. This allows you to install and run this on each of your RPi's so you can track them all via your own Home Assistant Dashboard.

Discovery image

This script should be configured to be run in daemon mode continuously in the background as a systemd service (or optionally as a SysV init script). Instructions are provided below.

Table of Contents

On this Page:

Additional pages:

Features

  • Tested on Raspberry Pi's zero, 2, 3, and 4 with Jessie, Stretch, Buster, and Bullseye
  • Tested with Home Assistant v0.111.0 -> 2023.4.6
  • Tested with Mosquitto broker
  • Data is published via MQTT
  • MQTT discovery messages are sent so RPi's are automatically registered with Home Assistant (if MQTT discovery is enabled in your HA installation)
  • MQTT authentication support
  • No special/root privileges are required by this mechanism (unless you activate remote commanding from HA)
  • Linux daemon / systemd service, sd_notify messages generated

RPi Device

Each RPi device is reported as:

Name Description
Manufacturer Raspberry Pi (Trading) Ltd.
Model RPi 4 Model B v1.1
Name (fqdn) pimon1.home
sofware ver OS Name, Version (e.g., Buster v4.19.75v7l+)

RPi MQTT Topics

Each RPi device is reported as five topics:

Name Device Class Units Description
~/monitor 'timestamp' n/a Is a timestamp which shows when the RPi last sent information, carries a template payload conveying all monitored values (attach the lovelace custom card to this sensor!)
~/temperature 'temperature' degrees C Shows the latest system temperature
~/disk_used none percent (%) Shows the percent of root file system used
~/cpu_load none percent (%) Shows CPU load % over the last 5 minutes
~/mem_used none percent (%) Shows the percent of RAM used

RPi Monitor Topic

The monitored topic reports the following information:

Name Sub-name Description
rpi_model tinyfied hardware version string
ifaces comma sep list of interfaces on board [w,e,b]
temperature_c System temperature, in [°C] (0.1°C resolution) Note: this is GPU temp. if available, else CPU temp. (used by HA sensor)
temp_gpu_c GPU temperature, in [°C] (0.1°C resolution)
temp_cpu_c CPU temperature, in [°C] (0.1°C resolution)
up_time duration since last booted, as [days]
last_update updates last applied, as [date]
fs_total_gb / (root) total space in [GBytes]
fs_free_prcnt / (root) available space [%]
fs_used_prcnt / (root) used space [%] (used by HA sensor)
host_name hostname
fqdn hostname.domain
ux_release os release name (e.g., buster)
ux_version os version (e.g., 4.19.66-v7+)
reporter script name, version running on RPi
networking lists for each interface: interface name, mac address (and IP if the interface is connected)
drives lists for each drive mounted: size in GB, % used, device and mount point
cpu lists the model of cpu, number of cores, etc.
hardware - typically the Broadcom chip ID (e.g. BCM2835)
model - model description string (e.g., ARMv7 Processor rev 4 (v7l))
number_cores - number of cpu cores [1,4]
bogo_mips - reported performance of this RPi
serial - serial number of this RPi
load_1min_prcnt - average % cpu load during prior minute (avg per core)
load_5min_prcnt - average % cpu load during prior 5 minutes (avg per core)
load_15min_prcnt - average % cpu load during prior 15 minutes (avg per core)
memory shows the RAM configuration in MB for this RPi
size_mb - total memory Size in MBytes
free_mb - available memory in MBytes
size_swap - total swap size in MBytes
free_swap - available swap size in MBytes
mem_used_prcnt shows the amount of RAM currently in use (used by HA sensor)
reporter name and version of the script reporting these values
reporter_releases list of latest reporter formal versions
report_interval interval in minutes between reports from this script
throttle reports the throttle status value plus interpretation thereof
timestamp date, time when this report was generated

NOTE: cpu load averages are divided by the number of cores

Prerequisites

An MQTT broker is needed as the counterpart for this daemon.

MQTT is huge help in connecting different parts of your smart home and setting up of a broker is quick and easy. In many cases you've already set one up when you installed Home Assistant.

Installation

On a modern Linux system just a few steps are needed to get the daemon working. The following example shows the installation under Debian/Raspbian below the /opt directory:

First install extra packages the script needs (select one of the two following commands)

Packages for Ubuntu, Raspberry pi OS, and the like

sudo apt-get install git python3 python3-pip python3-tzlocal python3-sdnotify python3-colorama python3-unidecode python3-apt python3-paho-mqtt python3-requests

Additional Packages for pure Ubuntu

NOTE if you are running a pure Ubuntu not Raspberry pi OS then you may need to install additional packages to get the binary we use to get the core temperatures and tools to inspec the network interfaces. (If you are NOT seeing temperatures in your Lovelace RPI Monitor Card this is likely the cause. Or if some of your RPis don't show up in Home Assistant) Do the following in this case:

sudo apt-get install libraspberrypi-bin net-tools

Packages for Arch Linux

sudo pacman -S python python-pip python-tzlocal python-notify2 python-colorama python-unidecode python-paho-mqtt python-requests inetutils

NOTE: for users of Arch Linux the number of updates available will NOT be reported (will always show as '-1'.) This is due to Arch Linux not using the apt package manager.

With these extra packages installed, verify access to network information

The Daemon script needs access to information about how your RPi connects to the network. It uses ifconfig(8) to look up connection names and get the RPi IP address, etc.

Let's run ifconfig to insure you have it installed.

# run ifconfig(8) to see your RPi networking info
ifconfig
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 41342  bytes 2175319 (2.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 41342  bytes 2175319 (2.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet xxx.xxx.xxx.xxx  netmask 255.255.255.0  broadcast xxx.xxx.xxx.xxx
        inet6 ... {omitted} ...
        inet6 ... {omitted} ...
        ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 1458134  bytes 344599963 (328.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 299694  bytes 51281531 (48.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

If you are seeing output from the ifconfig tool then continue on with the following steps. If you don't you may have missed installing net-utils in an earlier step.

Now finish with the script install

Now that the extra packages are installed let's install our script and any remaining supporting python modules.

--> NEW!! These instructions adjusted to use the latest released version! See "Why" below.

# Get a copy of the repository
sudo git clone https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon.git /opt/RPi-Reporter-MQTT2HA-Daemon

# move into your new local repository
cd /opt/RPi-Reporter-MQTT2HA-Daemon

# (NEW) Move to the latest official release:
sudo git checkout v1.8.5 # (you want to replace v1.8.5 with the latest if this isn't)

# Make sure any script requirement are installed (if they aren't aready)
sudo pip3 install -r requirements.txt

WARNING: If you choose to install these files in a location other than /opt/RPi-Reporter-MQTT2HA-Daemon, you will need to modify some of the control files which are used when setting up to run this script automatically. The following files:

  • rpi-reporter - Sys V init script
  • isp-rpi-reporter.service - Systemd Daemon / Service description file

... need to have any mention of /opt/RPi-Reporter-MQTT2HA-Daemon changed to your install location before you can run this script as a service.

Why are we checking-out the latest release?

When I'm developing new features I'll work on a different branch thereby not affecting master. When they are tested I'll merge the development brach into master. However it is much easier to merge pull requests directly into master. This action will, for a short period of time, make the master branch have possibly non-working code! You don't want this version until I've completed my testing of the new version and marked it as a new release. The clone gets you all versions while the checkout command moves your installation to the released version so you are running the latest fully tested code. You can always check the releases page to find out which is the latest. This also tells you what changes appeared in each release.

Configuration

To match personal needs, all operational details can be configured by modifying entries within the file config.ini. The file needs to be created first: (in the following: if you don't have vim installed you might try nano)

sudo cp /opt/RPi-Reporter-MQTT2HA-Daemon/config.{ini.dist,ini}
sudo vim /opt/RPi-Reporter-MQTT2HA-Daemon/config.ini

You will likely want to locate and configure the following (at a minimum) in your config.ini:

fallback_domain = {if you have older RPis that dont report their fqdn correctly}
# ...
hostname = {your-mqtt-broker}
# ...
discovery_prefix = {if you use something other than 'homeassistant'}
# ...
base_topic = {your home-assistant base topic}

# ...
username = {your mqtt username if your setup requires one}
password = {your mqtt password if your setup requires one}

Now that your config.ini is setup let's test!

NOTE: If you wish to support remote commanding of your RPi then you can find additional configuration steps in Setting up RPi Control from Home Assistant However, to simplifly your effort, please complete the following steps to ensure all is running as desired before you attempt to set up remote control.

Execution

Initial Test

A first test run is as easy as:

python3 /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py

NOTE: it is a good idea to execute this script by hand this way each time you modify the config.ini. By running after each modification the script can tell you through error messages if it had any problems with any values in the config.ini file, or any missing values. etc.``

Using the command line argument --config, a directory where to read the config.ini file from can be specified, e.g.

python3 /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py --config /opt/RPi-Reporter-MQTT2HA-Daemon

Preparing to run full time

In order to have your HA system know if your RPi is online/offline and when it last reported-in then you must set up this script to run as a system service.

NOTE: Daemon mode must be enabled in the configuration file (default).

But first, we need to grant access to some hardware for the user account under which the sevice will run.

Set up daemon account to allow access to temperature values

By default this script is run as user:group daemon:daemon. As this script requires access to the GPU you'll want to add access to it for the daemon user as follows:

# list current groups
groups daemon
$ daemon : daemon

# add video if not present
sudo usermod daemon -a -G video

# list current groups
groups daemon
$ daemon : daemon video
#                 ^^^^^ now it is present

NOTE: Yes, video is correct. This appears to be due to our accessing the GPU temperatures.

Choose Run Style

You can choose to run this script as a systemd service or as a Sys V init script. If you are on a newer OS than Jessie or if as a system admin you are just more comfortable with Sys V init scripts then you can use the latter style.

Let's look at how to set up each of these forms:

Run as Systemd Daemon / Service (for Raspian/Raspberry pi OS newer than 'jessie')

(Heads Up We've learned the hard way that RPi's running jessie won't restart the script on reboot if setup this way, Please set up these RPi's using the init script form shown in the next section.)

Set up the script to be run as a system service as follows:

sudo ln -s /opt/RPi-Reporter-MQTT2HA-Daemon/isp-rpi-reporter.service /etc/systemd/system/isp-rpi-reporter.service

sudo systemctl daemon-reload

# tell system that it can start our script at system startup during boot
sudo systemctl enable isp-rpi-reporter.service

# start the script running
sudo systemctl start isp-rpi-reporter.service

# check to make sure all is ok with the start up
sudo systemctl status isp-rpi-reporter.service

NOTE: Please remember to run the 'systemctl enable ...' once at first install, if you want your script to start up every time your RPi reboots!

Run as Sys V init script (your RPi is running 'jessie' or you just like this form)

In this form our wrapper script located in the /etc/init.d directory and is run according to symbolic links in the /etc/rc.x directories.

Set up the script to be run as a Sys V init script as follows:

sudo ln -s /opt/RPi-Reporter-MQTT2HA-Daemon/rpi-reporter /etc/init.d/rpi-reporter

# configure system to start this script at boot time
sudo update-rc.d rpi-reporter defaults

# let's start the script now, too so we don't have to reboot
sudo /etc/init.d/rpi-reporter start

# check to make sure all is ok with the start up
sudo /etc/init.d/rpi-reporter status

Update to latest

Like most active developers, we periodically upgrade our script. Use one of the following list of update steps based upon how you are set up.

Systemd commands to perform update

If you are setup in the systemd form, you can update to the latest we've published by following these steps:

# go to local repo
cd /opt/RPi-Reporter-MQTT2HA-Daemon

# stop the service
sudo systemctl stop isp-rpi-reporter.service

# get the latest version
sudo git pull

# (NEW) Move to the latest official release:
sudo git checkout v1.8.5 # (you want to replace v1.8.5 with the latest if this isn't)

# reload the systemd configuration (in case it changed)
sudo systemctl daemon-reload

# restart the service with your new version
sudo systemctl start isp-rpi-reporter.service

# if you want, check status of the running script
systemctl status isp-rpi-reporter.service

NOTE: Wondering about the "checkout" command? See Why are we checking-out the latest release? above.

SysV init script commands to perform update

If you are setup in the Sys V init script form, you can update to the latest we've published by following these steps:

# go to local repo
cd /opt/RPi-Reporter-MQTT2HA-Daemon

# stop the service
sudo /etc/init.d/rpi-reporter stop

# get the latest version
sudo git pull

# (NEW) Move to the latest official release:
sudo git checkout v1.8.5 # (you want to replace v1.8.5 with the latest if this isn't)

# restart the service with your new version
sudo /etc/init.d/rpi-reporter start

# if you want, check status of the running script
sudo /etc/init.d/rpi-reporter status

NOTE: Wondering about the "checkout" command? See Why are we checking-out the latest release? above.

Integration

When this script is running data will be published to the (configured) MQTT broker topic "raspberrypi/{hostname}/..." (e.g. raspberrypi/picam01/...).

An example:

{
  "info": {
    "timestamp": "2023-03-01T15:37:06-07:00",
    "rpi_model": "RPi 4 Model B r1.5",
    "ifaces": "e,w,b",
    "host_name": "pip2iotgw",
    "fqdn": "pip2iotgw.home",
    "ux_release": "bullseye",
    "ux_version": "5.15.84-v8+",
    "ux_updates": 3,
    "up_time": "21:08",
    "up_time_secs": 76080,
    "last_update": "2023-02-28T18:11:41-07:00",
    "fs_total_gb": 32,
    "fs_free_prcnt": 81,
    "fs_used_prcnt": 19,
    "networking": {
      "eth0": {
        "mac": "e4:5f:01:f8:18:01",
        "rx_data": 0,
        "tx_data": 0
      },
      "wlan0": {
        "IP": "192.168.100.196",
        "mac": "e4:5f:01:f8:18:02",
        "rx_data": 31954,
        "tx_data": 8883
      }
    },
    "drives": {
      "root": {
        "size_gb": 32,
        "used_prcnt": 19,
        "device": "/dev/root",
        "mount_pt": "/"
      }
    },
    "memory": {
      "size_mb": 1849,
      "free_mb": 1484,
      "size_swap": 100,
      "free_swap": 100
    },
    "mem_used_prcnt": 19,
    "cpu": {
      "hardware": "BCM2835",
      "model": "",
      "number_cores": 4,
      "bogo_mips": "432.00",
      "serial": "1000000081ae88c7",
      "load_1min_prcnt": 2.5,
      "load_5min_prcnt": 1,
      "load_15min_prcnt": 0.2
    },
    "throttle": [
      "throttled = 0x0",
      "Not throttled"
    ],
    "temperature_c": 28.7,
    "temp_gpu_c": 28.7,
    "temp_cpu_c": 28.2,
    "reporter": "ISP-RPi-mqtt-daemon v1.8.3",
    "reporter_releases": "v1.8.2,v1.7.2,v1.7.3,v1.7.4",
    "report_interval": 5
  }
}

NOTE: Where there's an IP address that interface is connected. Also, there are new tx_data and rx_data values which show traffic in bytes for this reporting interval for each network interface.

This data can be subscribed to and processed by your home assistant installation. How you build your RPi dashboard from here is up to you!

Troubleshooting

Issue: I've updated my RPi OS and now I'm getting reporter script startup errors

Most often fix: Re-add the video perms to the daemon group

See Closed Issues: #94, #98

We occasionaly have reports of users who updated their RPi afterwhich the RPI reporter Daemon script fails to start. The issue is that one of the packages updated appears to have reset the daemon group perminsions. For instructions on resetting the permissions to what is needed see: Set up daemon account to allow access to temperature values

Issue: Some of my RPi's don't show up in HA

Most often fix: install the missing package.

We occasionaly have reports of users with more than one RPi on their network but only one shows up in Home Assistant. This is most often caused when this script generats a non-unique id for the RPi's. This in turn is most often caused by an inability to get network interface details. I've just updated the install to ensure that we have net-tools package installed. On Raspberry Pi OS this package is already present while on Ubuntu this is not installed by default. If you can successfully run ifconfig(8) then you have what's needed. If not then simply run sudo apt-get install net-tools.

Issue: I removed the RPi sensor from HA now the RPi won't come back

Most often fix: reboot the missing RPi.

When you remove a sensor from Home Assistant it tells the MQTT broker to 'forget' everything it knows about the RPi. Some of the information is actually stored by the MQTT broker so it is available while the RPi is offline. Our Daemon script only broadcasts this stored information when it is first started. As a result the RPi will not re-appear after delete from Home Assistant until you reboot the RPi in question. (or, alternatively, stop then restart the script.). You may find reboot easier to do.

To reboot:

sudo shutdown -r now

To, instead, restart the Daemon:

sudo systemctl stop isp-rpi-reporter.service
sudo systemctl start isp-rpi-reporter.service

General debug

The deamon script can be run my hand while enabling debug and verbose messaging:

# first stop the running daemon
sudo systemctl stop isp-rpi-reporter.service

# now run the daemon with Debug and Verbose options enabled
python3 /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py -d -v

This let's you inspect many of the values the script is going to use and to see the data being sent to the MQTT broker.

Then remember to restart the daemon when you are done:

# now restart the daemon
sudo systemctl start isp-rpi-reporter.service

Exploring MQTT state

I find MQTT Explorer to be an excellent tool to use when trying to see what's going on the MQTT messaging any MQTT enabled device.

Alternatively I also use MQTTBox when I want to send messages by hand to interact via MQTT. it is affered as a web extension or a native application.

Viewing the Daemon logs

When your script is being run as a Daemon it is logging. You can view the log output since last reboot with:

journalctl -b --no-pager -u isp-rpi-reporter.service

Alternatively you can create a simple script which you can run any time you want to see the log. Here's my show Daemon log script showRpiLog:

#!/bin/bash

(set -x;journalctl -b --no-pager -u isp-rpi-reporter.service)

NOTE: the -b says 'since last boot' the --no-pager says just show it all without breaking it up into pages and requiring the enter key press for each page.


If you like my work and/or this has helped you in some way then feel free to help me out for a couple of ☕'s or 🍕 slices!

coffee    -OR-    PatreonPatreon.com/IronSheep


Contributors

This project is enjoyed by users in many countries. A number of these users have taken the time so submit pull requests which contribute changes/fixes to this project.

Thank you to the following github users for taking the time to help make this project function better for all of us!:

  • brunob45 - report swap usage, fixes to MQTT topics for HA 2023.8 update
  • hobbypunk90 - add commanding of RPi from HA
  • OasisOfChaos - adjust temp. reporting so can work on non-RPi devices like Orange Pi
  • nabeelmoeen - add memory usage as addiitonal sensor
  • mcarlosro - add ip traffic rate for network interfaces
  • Henry-Sir - add cpu usage as addiitonal sensor
  • woodmj74 - changes to reporting correct temperature units
  • dflvunoooooo - changes to getting last update date
  • hostcc - improved error handling with external commands
  • frennkie - add compatibility with paho-mqtt 2.0.0
  • kroecks - changes to sensor_name setup

Credits

Thank you to Thomas Dietrich for providing a wonderful pattern for this project. His project, which I use and heartily recommend, is miflora-mqtt-deamon

Thanks to synoniem for working through the issues with startup as a SystemV init script and for providing 'rpi-reporter' script itself and for identifying the need for support of other boot device forms.


Disclaimer and Legal

Raspberry Pi is registered trademark of Raspberry Pi (Trading) Ltd.

This project is a community project not for commercial use. The authors will not be held responsible in the event of device failure or simply errant reporting of your RPi status.

This project is in no way affiliated with, authorized, maintained, sponsored or endorsed by Raspberry Pi (Trading) Ltd. or any of its affiliates or subsidiaries.


rpi-reporter-mqtt2ha-daemon's People

Contributors

brunob45 avatar frennkie avatar henry-sir avatar hobbypunk90 avatar hostcc avatar ironsheep avatar kroecks avatar mcarlosro avatar oasisofchaos avatar woodmj74 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpi-reporter-mqtt2ha-daemon's Issues

Temperature always is -1º

Checklist:

  • I updated to the latest version available
  • I checked that my MQTT broker is otherwise working

Release with the issue:
v1.6.0

Last working release (if known):

Hardware, Operating System, Python version:
Rpi 4
Ubuntu
Python 3.8.10

Description of problem:

Hi,
I installed RPi Reporter MQTT2HA and Lovelace RPi Monitor Card.
Boths works fine and HA shows the rpi information.

All works fine less the temperature, always is -1ºC.

If I execute: groups daemon
The result is: daemon : daemon video

Thanks

Run our report script 'genBugInfo' on your failing device and include the output here:

SCRIPT genBugInfo v1.1 run 22/01/20-15:48:17

----------------------------------------------------------------------

/bin/cat /etc/apt/sources.list | /bin/egrep -v '#'

deb http://ports.ubuntu.com/ubuntu-ports focal main restricted

deb http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted

deb http://ports.ubuntu.com/ubuntu-ports focal universe
deb http://ports.ubuntu.com/ubuntu-ports focal-updates universe

deb http://ports.ubuntu.com/ubuntu-ports focal multiverse
deb http://ports.ubuntu.com/ubuntu-ports focal-updates multiverse

deb http://ports.ubuntu.com/ubuntu-ports focal-backports main restricted universe multiverse

deb http://ports.ubuntu.com/ubuntu-ports focal-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports focal-security universe
deb http://ports.ubuntu.com/ubuntu-ports focal-security multiverse


/bin/cat /etc/apt/sources.list | /bin/egrep -v '#' | /usr/bin/awk '{ print $3 }' | /bin/grep . | /usr/bin/sort -u | head -1

focal


/bin/uname -r

5.4.0-1050-raspi


/bin/hostname -f

Home


/usr/bin/uptime

15:48:17 up 18 min, 1 user, load average: 0.17, 0.26, 0.26


/sbin/ifconfig

./genBugInfo: line 276: /sbin/ifconfig: No such file or directory


/sbin/ifconfig | /bin/egrep 'Link|flags|inet|ether' | /bin/egrep -v -i 'lo:|loopback|inet6|::1|127.0.0.1'


/sbin/route

./genBugInfo: line 296: /sbin/route: No such file or directory


/bin/ls -l /var/log/dpkg.log /var/log/dpkg.log.1 2>/dev/null

-rw-r--r-- 1 root root 42426 Jan 20 07:02 /var/log/dpkg.log
-rw-r--r-- 1 root root 49444 Dec 20 14:14 /var/log/dpkg.log.1


/bin/grep 'status installed' /var/log/dpkg.log /var/log/dpkg.log.1 2>/dev/null | sort | tail -1

/var/log/dpkg.log:2022-01-20 07:02:42 status installed flash-kernel:arm64 3.103ubuntu1~20.04.3


/bin/df -m

Filesystem 1M-blocks Used Available Use% Mounted on
/dev/mmcblk0p2 59662 12702 44417 23% /

/bin/df -m | /usr/bin/tail -n +2 | /bin/egrep -v 'tmpfs|boot'

udev 1849 0 1849 0% /dev
/dev/mmcblk0p2 59662 12702 44417 23% /

ls -l /opt/vc/bin/vcgencmd /usr/bin/vcgencmd

ls: cannot access '/opt/vc/bin/vcgencmd': No such file or directory
ls: cannot access '/usr/bin/vcgencmd': No such file or directory


Python errors shown in the logs (if applicable):

Additional information:

After execute installation command: sudo pip3 install -r requirements.txt
Appears this error:

ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /usr/local/lib/python3.8/dist-packages/pip/_vendor/ pep517/in_process/_in_process.py build_wheel /tmp/tmpfzo3av4x
cwd: /tmp/pip-install-5d5uqo79/backports-zoneinfo_acfef4580a214f208ccc071 702b77ee9
Complete output (30 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-aarch64-3.8
creating build/lib.linux-aarch64-3.8/backports
copying src/backports/init.py -> build/lib.linux-aarch64-3.8/backports
creating build/lib.linux-aarch64-3.8/backports/zoneinfo
copying src/backports/zoneinfo/init.py -> build/lib.linux-aarch64-3.8/back ports/zoneinfo
copying src/backports/zoneinfo/_zoneinfo.py -> build/lib.linux-aarch64-3.8/bac kports/zoneinfo
copying src/backports/zoneinfo/_version.py -> build/lib.linux-aarch64-3.8/back ports/zoneinfo
copying src/backports/zoneinfo/_common.py -> build/lib.linux-aarch64-3.8/backp orts/zoneinfo
copying src/backports/zoneinfo/_tzpath.py -> build/lib.linux-aarch64-3.8/backp orts/zoneinfo
running egg_info
warning: no files found matching '.png' under directory 'docs'
warning: no files found matching '
.svg' under directory 'docs'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'docs/_output'
writing manifest file 'src/backports.zoneinfo.egg-info/SOURCES.txt'
copying src/backports/zoneinfo/init.pyi -> build/lib.linux-aarch64-3.8/bac kports/zoneinfo
copying src/backports/zoneinfo/py.typed -> build/lib.linux-aarch64-3.8/backpor ts/zoneinfo
running build_ext
creating build/temp.linux-aarch64-3.8
creating build/temp.linux-aarch64-3.8/lib
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g - fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.8 -c lib/zoneinfo_module.c -o build/te mp.linux-aarch64-3.8/lib/zoneinfo_module.o -std=c99
lib/zoneinfo_module.c:1:10: fatal error: Python.h: No such file or directory
1 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1

ERROR: Failed building wheel for backports.zoneinfo
Failed to build backports.zoneinfo
ERROR: Could not build wheels for backports.zoneinfo, which is required to insta ll pyproject.toml-based projects

Sensor Naming

When I add my RPi (which is name RPi-MagicMirror) the name is split and the sensor name is put in between.

Bildschirmfoto 2022-04-25 um 09 51 59

sensor.rpi_temp_magicmirror

I would like to have the sensor name appended to the end of the Pi name. How can I change this behavior (pointing me to the code line is also fine).

Add default domain for when (on older *nix) it's not avail.

Checklist:

  • I updated to the latest version available
  • I checked that my MQTT broker is otherwise working

Release with the issue:

Latest

Last working release (if known):

Never did work for my picam.home machine.

Hardware, Operating System, Python version:

picam
fs free prcnt
16
fs total gb
64
host name
picam
ifaces
e,w,b
last update
2020-07-20T06:25:03-06:00
networking
eth0:
mac: 'b8:27:eb:4a:03:c9'
wlan0:
IP: 192.168.100.148
mac: 'b8:27:eb:1f:56:9c'
reporter
ISP-RPi-mqtt-daemon v1.1.1
rpi model
RPi 3 Model B r1.2
temperature c
-1
timestamp
2020-07-21T18:50:31-06:00
up time
25 days, 3:00
ux release
stretch
ux version
4.19.66-v7+

Description of problem:

the FQDN as reported is missing the DN part!

Python errors shown in the logs (if applicable):

no errors

Additional information:
none

Configuration for non linux initiated

Is your feature request related to a problem? Please describe.
I just installed it on my RPi 3 b+r1.3 . When I get to the configuration step here are some errors I got.

Error 1 at step: cp /opt/RPi-Reporter-MQTT2HA-Daemon/config.{ini.dist,ini}
Returned message:
cp: cannot create regular file '/opt/RPi-Reporter-MQTT2HA-Daemon/config.ini': Permission denied

Error 2 at the next step :
vim /opt/RPi-Reporter-MQTT2HA-Daemon/config.ini
Returned message:
-bash: vim: command not found

Describe the solution you'd like

Error 1: This command worked for me
sudo cp /opt/RPi-Reporter-MQTT2HA-Daemon/config.{ini.dist,ini}

Error 2: This command worked for me
sudo nano /opt/RPi-Reporter-MQTT2HA-Daemon/config.ini

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
This is just to help any one that runs into these linux basics and is a home assistant and smart home enthousiaste. Other then this straight forward, thanks to Stephen.

ValueError: could not convert string to float: '/bin/sh: 1: /opt/vc/bin/vcgencmd: not found'

Checklist:

  • [ x ] I updated to the latest version available
  • [ x ] I checked that my MQTT broker is otherwise working

Release with the issue:
Latest

Last working release (if known):
Couple of versions ago

Hardware, Operating System, Python version:
rPi4, Buster, 3.8.0

root@harpi:/opt/vc/bin# ls -al
total 1280
drwxr-xr-x 2 root root   4096 Aug 17 08:56 .
drwxr-xr-x 6 root root   4096 Aug 15 06:45 ..
-rwxr-xr-x 1 root root  29036 May 27 13:22 containers_check_frame_int
-rwxr-xr-x 1 root root  13536 May 27 13:22 containers_datagram_receiver
-rwxr-xr-x 1 root root  13340 May 27 13:22 containers_datagram_sender
-rwxr-xr-x 1 root root  14052 May 27 13:22 containers_dump_pktfile
-rwxr-xr-x 1 root root  34776 May 27 13:22 containers_rtp_decoder
-rwxr-xr-x 1 root root  19408 May 27 13:22 containers_stream_client
-rwxr-xr-x 1 root root  16416 May 27 13:22 containers_stream_server
-rwxr-xr-x 1 root root  42616 May 27 13:22 containers_test
-rwxr-xr-x 1 root root  32736 May 27 13:22 containers_test_bits
-rwxr-xr-x 1 root root  44820 May 27 13:22 containers_test_uri
-rwxr-xr-x 1 root root  24048 May 27 13:22 containers_uri_pipe
-rwxr-xr-x 1 root root  11284 May 27 13:22 dtmerge
-rwxr-xr-x 1 root root  31172 May 27 13:22 dtoverlay
-rwxr-xr-x 1 root root    282 May 27 13:22 dtoverlay-post
-rwxr-xr-x 1 root root    280 May 27 13:22 dtoverlay-pre
lrwxrwxrwx 1 root root      9 Aug 12 08:36 dtparam -> dtoverlay
-rwxr-xr-x 1 root root  76884 Jul 20 08:51 edidparser
-rwxr-xr-x 1 root root  24212 Jul 20 08:51 mmal_vc_diag
-rwxr-xr-x 1 root root 131704 Jul 20 08:51 raspistill
-rwxr-xr-x 1 root root  93296 Jul 20 08:51 raspivid
-rwxr-xr-x 1 root root  79908 Jul 20 08:51 raspividyuv
-rwxr-xr-x 1 root root  75624 Jul 20 08:51 raspiyuv
-rwxr-xr-x 1 root root  74068 Jul 20 08:51 tvservice
-rwxr-xr-x 1 root root 257820 Jul 20 08:51 vcdbg
-rwxr-xr-x 1 root root  16460 Jul 20 08:51 vcgencmd
-rwxr-xr-x 1 root root  69068 May 27 13:22 vchiq_test
-rwxr-xr-x 1 root root   7824 May 27 13:22 vcmailbox
-rwxr-xr-x 1 root root  15160 May 27 13:22 vcsmem

And

root@harpi:/opt# vcgencmd measure_temp
temp=58.0'C

works and

root@harpi:/opt# python3 /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py --config /opt/RPi-Reporter-MQTT2HA-Daemon
[2020-08-17 09:22:24] * MQTT connection established
[2020-08-17 09:22:24] 
[2020-08-17 09:22:25] Announcing RPi Monitoring device to MQTT broker for auto-discovery ...
[2020-08-17 09:22:26] Publishing to MQTT topic "home/nodes/sensor/rpi-localhost/monitor, Data:{"info": {"timestamp": "2020-08-17T09:22:25+02:00", "rpi_model": "RPi 4 Model B r1.2", "ifaces": "e,w,b", "host_name": "localhost", "fqdn": "localhost", "ux_release": "buster", "ux_version": "5.4.51-v7l+", "up_time": "2 days,  18:49", "last_update": "2020-08-17T10:36:09+02:00", "fs_total_gb": 128, "fs_free_prcnt": 8, "networking": {"docker0": {"IP": "172.17.0.1", "mac": "xx:xx:69:2d:5d:1b"}, "eth0": {"IP": "192.168.x.x", "mac": "xx:xx:xx:7e:ed:28"}, "veth1c6ad3e": {"IP": "169.254.22.153", "mac": "xx:xx:b2:b3:62:62"}, "wg0": {"IP": "10.6.0.1"}}, "drives": {"root": {"size_gb": 128, "used_prcnt": 8, "device": "/dev/root", "mount_pt": "/"}, "var-lib-docker-overlay2-7692956b40e33dcc346422391e42c85bd0370897f07a0a5a6d815a011a8b7a71-merged": {"size_gb": 128, "used_prcnt": 8, "device": "overlay", "mount_pt": "/var/lib/docker/overlay2/7692956b40e33dcc346422391e42c85bd0370897f07a0a5a6d815a011a8b7a71/merged"}}, "temperature_c": 58.0, "temp_gpu_c": 58.0, "temp_cpu_c": 58.9, "reporter": "ISP-RPi-mqtt-daemon v1.4.4", "report_interval": 5}}"

works aswell.

Custom installation folder path

Hi,
First of all thank you for your script.
Since I installed your script in a different folder from /opt I found that could be useful to indicate that folder path should be update accordingly in the rpi-reporter

DIR=/opt/RPi-Reporter-MQTT2HA-Daemon

Otherwise the Sys V init script will not run.
Thanks

Mark

CPU usage 200%

Hi!

Not sure if this is a bug, or something wrong in the setup.

But for whatever reason I'm getting cpu usage % around 150-200%. Pi is being utilazed heavily, but from like htop cpu usage seems to around 80-90%. Any ideas?
image

Support for Bullseye

Just reinstalled an RPi from scratch with Bullseye. Daemon is running and shows no errors. But on Homeasisstant it seems to have an issue getting the payload. Within the log it shows the following error code:

2021-11-12 09:14:11 DEBUG (SyncWorker_7) [fritzconnection] b'<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:GetInfo xmlns:u="urn:dslforum-org:service:WANDSLInterfaceConfig:1"></u:GetInfo></s:Body></s:Envelope>'
2021-11-12 09:14:12 ERROR (MainThread) [homeassistant.components.sensor] Platform mqtt does not generate unique IDs. ID RPi-b827ebMon0f6592_monitor already exists - ignoring sensor.rpi_monitor_touch
2021-11-12 09:14:12 DEBUG (SyncWorker_7) [fritzconnection] response status: 200
2021-11-12 09:14:12 DEBUG (SyncWorker_7) [fritzconnection]
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

So the general functionality seems to work, device is shown as available, but it does not re-register the mqtt-client-id.
Maybe because the ID is automatical generated by mac-Adresses wich was the same before upgrading from buster to bullseye ?

MQTT-Infos
devices-detail
devices

Report Temp in Fahrenheit?

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Send temperature value in Fahrenheit instead of Celsius, possibly as a config option in "config.ini"?

Describe alternatives you've considered
Create a template sensor in HA, but would prefer not to.

Devices not shown in home assistant

i run hassio on a raspberry pi. on two other rpis i installed rpi-reporter (IP numbers ....67 and ....69). auto-detection at the mqtt broker is active.

everything is installed and looking fine:

● isp-rpi-reporter.service - RPi Reporter MQTT Client/Daemon Loaded: loaded (/opt/RPi-Reporter-MQTT2HA-Daemon/isp-rpi-reporter.service; enabled; v endor preset: enabled) Active: active (running) since Sat 2020-12-19 07:47:05 GMT; 11s ago Docs: https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon Main PID: 10184 (python3) Status: "Dec 19 07:47:04 - * MQTT connection established." Tasks: 4 (limit: 2182) CGroup: /system.slice/isp-rpi-reporter.service └─10184 /usr/bin/python3 -u /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-dae mon.py

but when i try to the rpis to home assistant, no devices are shown and thus i have no entities to add to my card. the mqtt broker shows this log:

23:41:38] INFO: Setup mosquitto configuration [23:41:38] WARNING: SSL not enabled - No valid certs found! [23:41:38] INFO: No local user available [23:41:39] INFO: Initialize Hass.io Add-on services [23:41:40] INFO: Initialize Home Assistant discovery [23:41:40] INFO: Start Mosquitto daemon 1608590500: mosquitto version 1.6.3 starting 1608590500: Config loaded from /etc/mosquitto.conf. 1608590500: Loading plugin: /usr/share/mosquitto/auth-plug.so 1608590500: ├── Username/password checking enabled. 1608590500: ├── TLS-PSK checking enabled. 1608590500: └── Extended authentication not enabled. 1608590500: |-- *** auth-plug: startup 1608590500: Opening ipv4 listen socket on port 1883. 1608590500: Opening ipv6 listen socket on port 1883. 1608590500: Opening websockets listen socket on port 1884. 1608590500: Warning: Mosquitto should not be run as root/administrator. 1608590505: New connection from 172.30.32.1 on port 1883. [INFO] found homeassistant on local database 1608590506: New client connected from 172.30.32.1 as 2cdXHPvbVerOgZL6ecpYWe (p2, c1, k60, u'homeassistant'). 1608590556: New connection from 192.168.178.67 on port 1883. 1608590556: New connection from 192.168.178.69 on port 1883. [INFO] found mqtt on Home Assistant 1608590558: New client connected from 192.168.178.67 as auto-857BAE5C-1AC9-3987-465B-36280FE6D2E7 (p2, c1, k60, u'mqtt'). 1608590558: New client connected from 192.168.178.69 as auto-A80A6673-63CF-40D0-2F0C-7661B255DE51 (p2, c1, k60, u'mqtt'). 1608590704: Socket error on client 2cdXHPvbVerOgZL6ecpYWe, disconnecting. 1608590780: New connection from 172.30.32.1 on port 1883. 1608590780: New client connected from 172.30.32.1 as 7qC1wY155CUGKGCOhi5AKK (p2, c1, k60, u'homeassistant'). 1608591134: New connection from 192.168.178.67 on port 1883. [INFO] found mqtt on Home Assistant 1608591135: New client connected from 192.168.178.67 as auto-2306B13D-AAF4-F5A0-C985-8DB8605856F6 (p2, c1, k60, u'mqtt'). 1608591145: Socket error on client auto-2306B13D-AAF4-F5A0-C985-8DB8605856F6, disconnecting. 1608591247: Socket error on client 7qC1wY155CUGKGCOhi5AKK, disconnecting. 1608591327: New connection from 172.30.32.1 on port 1883. [INFO] found homeassistant on local database 1608591328: New client connected from 172.30.32.1 as 6W9tQbCJwO5td0jPQK1NsM (p2, c1, k60, u'homeassistant').

so it looks like there is a connection, but maybe the socket error keeps the rpi-reporter from working properly. what does this error mean and how can i fix it?

could you please give me a hint how to be able to add the devices to my home assistant installation?

CPU Usage

It would be nice to have CPU usage as well.
maybe in a different sensor just like diskspace and temp.

tnx

Send drive temperatures to MQTT

I would like to monitor the temperature of my SSD (or any other external drive)
Would it be possible to send the output of external hard drives to MQTT as well?
Example output for sda: smartctl -A /dev/sda | grep emperature

Some improvements

Thanks for this nice script.
I do have a variety of Pi's running and had two issues with the script:

  1. Most of my Pi's run from a NFS share and their hdd size was not correctly detected
  2. I am also running a old Pi 2 B which did not return the correct value for temperature

So i have edited your script for those two parts which should work for all Pi's

def getFileSystemSpace():
    global rpi_filesystem_space_raw
    global rpi_filesystem_space
    global rpi_filesystem_percent
    out = subprocess.Popen("/bin/df -m / | grep /",
            shell=True,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT)
    stdout,stderr = out.communicate()
    rpi_filesystem_space_raw = stdout.decode('utf-8').rstrip()
    print_line('rpi_filesystem_space_raw=[{}]'.format(rpi_filesystem_space_raw), debug=True)
    lineParts = rpi_filesystem_space_raw.split()
    print_line('lineParts=[{}]'.format(lineParts), debug=True)
    filesystem_1GBlocks = int(lineParts[1],10) / 1024
    if filesystem_1GBlocks > 1:
        rpi_filesystem_space = '{}GB'.format(int(filesystem_1GBlocks))
    else:
        rpi_filesystem_space = '1GB'
    print_line('rpi_filesystem_space=[{}]'.format(rpi_filesystem_space), debug=True)
    rpi_filesystem_percent = lineParts[4].replace('%', '')
    print_line('rpi_filesystem_percent=[{}]'.format(rpi_filesystem_percent), debug=True)

def getSystemTemperature():
    global rpi_system_temp
    rpi_system_temp_raw = 'failed'
    retry_count = 3
    while retry_count > 0 and 'failed' in rpi_system_temp_raw:
        out = subprocess.Popen("cat /sys/class/thermal/thermal_zone0/temp",
                shell=True,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT)
        stdout,stderr = out.communicate()
        rpi_system_temp_raw = stdout.decode('utf-8').rstrip()
        retry_count -= 1
        sleep(1)

    if 'failed' in rpi_system_temp_raw:
        interpretedTemp = float('-1.0')
    else:
        interpretedTemp = float(rpi_system_temp_raw) / 1000.0
    rpi_system_temp = interpretedTemp
    print_line('rpi_system_temp=[{}]'.format(rpi_system_temp), debug=True)

Support for Arch Linux

Is your feature request related to a problem? Please describe.
If run under Arch Linux a few commands do not work, because Arch Linux handles them differently. The hostname command is not available from a clean install, Arch Linux has no general version only for each package since being a rolling release and the "last update" sensor does not work with pacman.

Describe the solution you'd like
The hostname programm can be installed via the inetutils package. This has to be added to the readme.
The version sensor can be left out on an Arch Linux installation.
And the last update sensor can be achieved easily I think, but I have to try and write a function.

Describe alternatives you've considered
An alternatve would be to comment the functions out, so they are not used, but that is a dirty solution.

I am not sure if I did this correct. This is my first feature request.

Add network usage information

I'm running in my RPI multiple applications in docker and I would like to monitor the network transfer in order to find if I have any peak that might be saturating my network.

As a solution I would like to add 2 more sensors for tx and rx at the interface level, as some people might be using eth or wlan at the same time.

Can I use this on my PiKVM OS?

Hi, how can I use this on my PiKVM? PiKVM OS is based on Arch Linux ARM. I use PiKVM on rpi zero w.

I tried to install RPi reporter on it but with no success. Maybe I use the wrong commands?

Make MQTT Discovery Topic configurable

The script currently uses homeassistant as the MQTT Discovery root topic. This is the default in HA but not mandatory.

I have more than one HA instance, so I do not use this topic. I would be nice to have this as a configuration variable.

Might just be me... Null Client

Current Config: HA CORE: 2021.12.10 (Supervised) | HAOS: 7.2

It might just be me, but I think I have identified an issue with multiple Ubuntu RPis running this daemon (or I'm just tired)... I had this fully working with 2 Pis (different OS) reporting in their states into HA. No issues, just worked. Then I decided to repurpose a Pi & moved it to Ubuntu.

After rebuild, MQTT sees the sensors from both RPis, but the HA integration sees only one device & associates the sensors to the wrong device. Tested by clearing subs & tested individually...

Example: Pi A & B both can connect successfully to MQTT (tested both ways)
If "Pi A" daemon is started first, the HA MQTT discovers the device & sensors, but if "Pi B" is started, it replaces the device in integrations with "PI B's" name, but leaves the sensors labeled as "Pi A" & if "Pi A" daemon is stopped the sensors show unavailable even though "Pi B" is the device name (if that makes any sense).

Additional Detail: mosquito_sub CLI sees client as null even though both Pis have unique hostnames (hostname -f)

Daemon Config: hostname/port/bas_topic/sensor_name (matches hostname)/user/password all set in the config.ini

Just in case I cleared & deleted all subs. stopped daemons. deleted the MQTT integration & add-on. rebooted. beat my head against the wall. Same result each time.

I don't want to rebuild HA, but I can to see if this is a daemon, host, or me lossing my MQTT mind.

Bug, missing config, or just me?

Jetson Nano Support

Is your feature request related to a problem? Please describe.
It would be awesome if you could add Jetson Nano support - I have tested it as is and most things work but temperatures are not read.

Describe the solution you'd like
Update to include Jetson Nano Temperature readings.

Describe alternatives you've considered
Currently using a bash script to read the values from:

cat /sys/devices/virtual/thermal/thermal_zone*/type

AO-therm
CPU-therm
GPU-therm
PLL-therm
PMIC-Die
thermal-fan-est

cat /sys/devices/virtual/thermal/thermal_zone*/temp

31000
24500
26500
24500
100000
25500

Additional context
N/A

Failed with result 'exit-code'

I havew been using the RPI-Reporter happily for a number of months on several raspberry pi devices - an original B, a pi 2 and a pi 4. It may be coincidence, but I appear to have issues following installation of NUT server on the pi B (as APCUPSD is deprecated - the pi's sole trask is to act as a master server in respect of a UPS). I've tried reloading the daemon, rebotting etc, all to no avail.

I'm out of my depth but I have the journal entry which may be helpful:

░░ A start job for unit isp-rpi-reporter.service has finished with a failure.
░░
░░ The job identifier is 159198 and the job result is failed.
Jan 23 21:43:34 raspberrypiups sudo[3878]: pam_unix(sudo:session): session closed for user root
Jan 23 21:43:37 raspberrypiups systemd[1]: isp-rpi-reporter.service: Scheduled restart job, restart counter is at 2301.
░░ Subject: Automatic restarting of a unit has been scheduled
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ Automatic restarting of the unit isp-rpi-reporter.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Jan 23 21:43:37 raspberrypiups systemd[1]: Stopped RPi Reporter MQTT Client/Daemon.
░░ Subject: A stop job for unit isp-rpi-reporter.service has finished
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A stop job for unit isp-rpi-reporter.service has finished.
░░
░░ The job identifier is 159336 and the job result is done.
Jan 23 21:43:37 raspberrypiups systemd[1]: Starting RPi Reporter MQTT Client/Daemon...
░░ Subject: A start job for unit isp-rpi-reporter.service has begun execution
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit isp-rpi-reporter.service has begun execution.
░░
░░ The job identifier is 159336.
Jan 23 21:43:37 raspberrypiups python3[3882]: File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 4
Jan 23 21:43:37 raspberrypiups python3[3882]: . /usr/share/debconf/confmodule
Jan 23 21:43:37 raspberrypiups python3[3882]: ^
Jan 23 21:43:37 raspberrypiups python3[3882]: SyntaxError: invalid syntax
Jan 23 21:43:37 raspberrypiups systemd[1]: isp-rpi-reporter.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ An ExecStart= process belonging to unit isp-rpi-reporter.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Jan 23 21:43:37 raspberrypiups systemd[1]: isp-rpi-reporter.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ The unit isp-rpi-reporter.service has entered the 'failed' state with result 'exit-code'.
Jan 23 21:43:37 raspberrypiups systemd[1]: Failed to start RPi Reporter MQTT Client/Daemon.
░░ Subject: A start job for unit isp-rpi-reporter.service has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit isp-rpi-reporter.service has finished with a failure.
░░
░░ The job identifier is 159336 and the job result is failed.

Test failing after install

Hi, these are the errors I receive after a fresh install and executing "python3 /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py"

Traceback (most recent call last):
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 484, in
getFileSystemDrives()
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 396, in getFileSystemDrives
total_size_in_gb = '{:.0f}'.format(next_power_of_2(lineParts[1]))
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 411, in next_power_of_2
size_as_nbr = int(size) - 1
ValueError: invalid literal for int() with base 10: 'de'

Raspberry Pi 4B rev1.2 4GB
Buster latest release
Python 3.7
Thanks for your help.

Make this a component for Hassio

I am using multiple Hasssio installations and I am guessing more people are.
Would it be possible to create this as a HACs integration as well?
It would improve the posibility for a overview on my main installation.

Easy and quick to be able to utilize the information together with the lovelace card.

Update Available Sensor

Hi, would it be possible to create an Update Available Sensor in HA for your new releases?

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

New sensor beeing created after reboot

On every reboot a new instance of the sensor.rpi_monitor.. is beeing created in Home Assistant. It starts with sensor.rpi_monitor_raspberrypi, but after rebooting my Pi4 (with Docker) the original Sensor is no longer beeing updated and a new one sensor.rpi_monitor_raspberrypi_2 is created. I don's know if this is the right place to ask for help. If not, just say so.

HA log shows: "ValueError: C is not a recognized temperature unit"

Checklist:

  • I updated to the latest version available
  • I checked that my MQTT broker is otherwise working

Release with the issue:
v1.5.4 Stable

Last working release (if known):

Hardware, Operating System, Python version:

Version core-2021.6.6
Installationstyp Home Assistant OS
Entwicklung false
Supervisor true
Docker true
Virtuelle Umgebung false
Python-Version 3.8.9
Betriebssystemfamilie Linux
Betriebssystem-Version 5.10.17-v8
CPU-Architektur aarch64
Zeitzone Europe/Berlin

In HA logfile I'm getting this message:

2021-07-24 21:23:54 ERROR (MainThread) [homeassistant.helpers.event] Error while processing state change for sensor.rpi_temp_raspi03
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 272, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 432, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/homekit/accessories.py", line 355, in async_update_event_state_callback
    self.async_update_state_callback(event.data.get("new_state"))
  File "/usr/src/homeassistant/homeassistant/components/homekit/accessories.py", line 377, in async_update_state_callback
    self.async_update_state(new_state)
  File "/usr/src/homeassistant/homeassistant/components/homekit/type_sensors.py", line 103, in async_update_state
    temperature = temperature_to_homekit(temperature, unit)
  File "/usr/src/homeassistant/homeassistant/components/homekit/util.py", line 367, in temperature_to_homekit
    return round(temp_util.convert(temperature, unit, TEMP_CELSIUS), 1)
  File "/usr/src/homeassistant/homeassistant/util/temperature.py", line 29, in convert
    raise ValueError(UNIT_NOT_RECOGNIZED_TEMPLATE.format(from_unit, TEMPERATURE))
**ValueError: C is not a recognized temperature unit.**

Description of problem:

The helper function temp_util.convert seems to expect °C instead of just C.

Run our report script 'genBugInfo' on your failing device and include the output here:


Python errors shown in the logs (if applicable):


Additional information:

Config.ini issue

I keep getting this error

File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 171, in
daemon_enabled = config['Daemon'].getboolean('enabled', True)
File "/usr/lib/python3.7/configparser.py", line 958, in getitem
raise KeyError(key)
KeyError: 'Daemon'

Here's my config.ini

[Default]                                                                       
hostname = {192.168.4.61}}                                                      
# ...                                                                           
username = {user}                                                             
password = {pw}

I tried not having default but it kept saying I was missing a section header

Request for additional documentation

So, I'm new to MQTT, and things have also changed in HASS's MQTT implementation (config YAML to UI), so finding solid answers via Google is a bit challenging right now. :)

I'm interested in surfacing some of the other variables that are currently being sent to HASS, but not directly usable (as far as I understand).

As part of the data block, I get
"throttle": [
"Under-voltage has occurred",
"Throttling has occurred"
],

(As well as the CPU load averages, temperatures, etc.)

I'd like to be able to pull some of those values into individual sensors, rather than the text block that your Lovelace custom card displays. Is there a way to do that as currently designed, or is that a code change to make additional (state topics?) ? My attempts to achieve this in the configuration.yaml haven't been successful, so any tips would be appreciated.

InterpolationSyntaxError: '%' must be followed by '%' or '('

Checklist:

  • I updated to the latest version available
  • I checked that my MQTT broker is otherwise working

Release with the issue:
1.5.4

Last working release (if known):
First time use.

Hardware, Operating System, Python version:

Raspberry Pi 4, Arch Linux ARM, 3.9.4-1.1

Description of problem:

I can not enter my MQTT password, because it contains a "%" character. If I start ISP-RPi-mqtt-daemon.py it produces the following error message:

Traceback (most recent call last):
  File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 933, in <module>
    mqtt_password = os.environ.get("MQTT_PASSWORD", config['MQTT'].get('password', None))
  File "/usr/lib/python3.9/configparser.py", line 1303, in get
    return _impl(self._name, option, raw=raw, vars=vars,
  File "/usr/lib/python3.9/configparser.py", line 799, in get
    return self._interpolation.before_get(self, section, option, value,
  File "/usr/lib/python3.9/configparser.py", line 395, in before_get
    self._interpolate_some(parser, option, L, value, section, defaults, 1)
  File "/usr/lib/python3.9/configparser.py", line 442, in _interpolate_some
    raise InterpolationSyntaxError(
configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: "%blabla4bla^5blablabla%'bla& "

I replaced the letters with blas.
Run our report script 'genBugInfo' on your failing device and include the output here:

# SCRIPT genBugInfo v1.1 run 21/05/03-22:33:25
# ----------------------------------------------------------------------

# /bin/cat /etc/apt/sources.list | /bin/egrep -v '#'


 ----

# /bin/cat /etc/apt/sources.list | /bin/egrep -v '#' | /usr/bin/awk '{ print $3 }' | /bin/grep . | /usr/bin/sort -u>


 ----

# /bin/uname -r

5.10.33-1-ARCH

 ----

# /bin/hostname -f

./genBugInfo: line 256: /bin/hostname: No such file or directory

 ----

# /usr/bin/uptime

 22:33:25 up 1 day, 10:45,  1 user,  load average: 0.41, 0.47, 0.53

 ----

# /sbin/ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.55  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 2a02:908:896:3fc0:dea6:32ff:fe35:c7de  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::dea6:32ff:fe35:c7de  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:35:c7:de  txqueuelen 1000  (Ethernet)
        RX packets 892469  bytes 146721860 (139.9 MiB)
        RX errors 0  dropped 73216  overruns 0  frame 0
        TX packets 351222  bytes 77901150 (74.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 20979  bytes 1699991 (1.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 20979  bytes 1699991 (1.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 ----

# /sbin/ifconfig | /bin/egrep 'Link|flags|inet|ether' | /bin/egrep -v -i 'lo:|loopback|inet6|\:\:1|127\.0\.0\.1'

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.55  netmask 255.255.255.0  broadcast 192.168.0.255
        ether dc:a6:32:35:c7:de  txqueuelen 1000  (Ethernet)

 ----

# /sbin/route

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         _gateway        0.0.0.0         UG    1024   0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
_gateway        0.0.0.0         255.255.255.255 UH    1024   0        0 eth0

 ----

# /bin/ls -l /var/log/dpkg.log /var/log/dpkg.log.1 2>/dev/null

/bin/ls: cannot access '/var/log/dpkg.log': No such file or directory
/bin/ls: cannot access '/var/log/dpkg.log.1': No such file or directory

 ----

# /bin/grep 'status installed' /var/log/dpkg.log /var/log/dpkg.log.1 2>/dev/null | sort | tail -1


 ----

# /bin/df -m

Filesystem     1M-blocks  Used Available Use% Mounted on
dev                  583     0       583   0% /dev
run                  715     1       714   1% /run
/dev/sda2          29306  5281     22513  19% /
tmpfs                715     0       715   0% /dev/shm
tmpfs                715     0       715   0% /tmp
/dev/sda1            487    38       449   8% /boot
tmpfs                143     0       143   0% /run/user/972
tmpfs                143     0       143   0% /run/user/1000

 ----

# /bin/df -m | /usr/bin/tail -n +2 | /bin/egrep -v 'tmpfs|boot'

dev                  583     0       583   0% /dev
run                  715     1       714   1% /run
/dev/sda2          29306  5281     22513  19% /

 ----

# ls -l /opt/vc/bin/vcgencmd /usr/bin/vcgencmd

ls: cannot access '/usr/bin/vcgencmd': No such file or directory
-rwxr-xr-x 1 root root 16460 Apr 30 15:53 /opt/vc/bin/vcgencmd

 ----

Python errors shown in the logs (if applicable):


Additional information:
The password escape seems to be broken. Maybe there is some easy way for me to do this in the config.ini?

MQTT auto discovery not working

Checklist:

  • [x ] I updated to the latest version available
  • [ x] I checked that my MQTT broker is otherwise working

Release with the issue:
latest

Last working release (if known):

Hardware, Operating System, Python version:

MQTT auto discovery not working. Messages are posted without problems to the MQTT server allright. A topic withe the name

homeassistant/sensor/rpi-mqtt-hole

is created but Home Assistant does not pick this up and there is no sensor.rpi-mqtt-hole available for the reporter card. When the 'Listen to a topic' functionality is used of the MQTT integration, and when listening to homeassistant/# the messages are received just fine.

Run our report script 'genBugInfo' on your failing device and include the output here:


Python errors shown in the logs (if applicable):


There are no errors thrown anywhere.

Multiple conflicting time zone configurations found

On a fresh install of Raspberry Pi OS on an RPI4, I get the following errors when trying to start the daemon through systemctl.

Oct 19 10:44:48 miflora python3[726]: Traceback (most recent call last):
Oct 19 10:44:48 miflora python3[726]:   File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 35, in <module>
Oct 19 10:44:48 miflora python3[726]:     local_tz = get_localzone()
Oct 19 10:44:48 miflora python3[726]:   File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 205, in get_localzone
Oct 19 10:44:48 miflora python3[726]:     _cache_tz = _get_localzone()
Oct 19 10:44:48 miflora python3[726]:   File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 167, in _get_localzone
Oct 19 10:44:48 miflora python3[726]:     tzname = _get_localzone_name(_root)
Oct 19 10:44:48 miflora python3[726]:   File "/usr/local/lib/python3.7/dist-packages/tzlocal/unix.py", line 146, in _get_localzone_name
Oct 19 10:44:48 miflora python3[726]:     raise utils.ZoneInfoNotFoundError(message)
Oct 19 10:44:48 miflora python3[726]: tzlocal.utils.ZoneInfoNotFoundError: 'Multiple conflicting time zone configurations found:\n/etc/timezone: America/New_York\n/usr/share/zoneinfo/posixrules: posixrules\nFix the configuration, or set the time zone in a TZ environment variable.\n'
Oct 19 10:44:48 miflora systemd[1]: isp-rpi-reporter.service: Main process exited, code=exited, status=1/FAILURE

I'm running this software without issue on some other RPIs, so I'm at a bit of a loss. /usr/share/zoneinfo/America/New_York is a symlink to /usr/share/zoneinfo/posixrules.

unidecode module not found

Checklist:

  • I updated to the latest version available
  • I checked that my MQTT broker is otherwise working

Release with the issue:

Last working release (if known):

Hardware Raspberry PI 3B, Operating System, Python version:3.8.6

Description of problem:
I follow all steps as your guide to install script. All OK.
In "Choose Run Style"->as system daemon
sudo systemctl start isp-rpi-reporter.service
i have following result:
.....
Nov 28 15:00:02 raspA python3[1140]: Traceback (most recent call last):
Nov 28 15:00:02 raspA python3[1140]: File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 22, in
Nov 28 15:00:02 raspA python3[1140]: from unidecode import unidecode
Nov 28 15:00:02 raspA python3[1140]: ModuleNotFoundError: No module named 'unidecode'
Nov 28 15:00:02 raspA systemd[1]: isp-rpi-reporter.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
.....
python 3.8.6 Homeassistant core (0.118.3) on Raspberry 3B

Run our report script 'genBugInfo' on your failing device and include the output here:

SCRIPT genBugInfo v1.1 run 20/11/28-15:29:12

----------------------------------------------------------------------

/bin/cat /etc/apt/sources.list | /bin/egrep -v '#'

deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi


/bin/cat /etc/apt/sources.list | /bin/egrep -v '#' | /usr/bin/awk '{ print $3 }' | /bin/grep . | /usr/bin/sort -u | head -1

buster


/bin/uname -r

5.4.72-v7+


/bin/hostname -f

raspA


/usr/bin/uptime

15:29:12 up 31 min, 1 user, load average: 0.27, 0.31, 0.29


/sbin/ifconfig

eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:86:9e:25 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 1873 bytes 154698 (151.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1873 bytes 154698 (151.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.23 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::617c:71ee:b6bd:1967 prefixlen 64 scopeid 0x20
ether b8:27:eb:d3:cb:70 txqueuelen 1000 (Ethernet)
RX packets 41028 bytes 13006172 (12.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 19146 bytes 3322505 (3.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


/sbin/ifconfig | /bin/egrep 'Link|flags|inet|ether' | /bin/egrep -v -i 'lo:|loopback|inet6|::1|127.0.0.1'

eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:86:9e:25 txqueuelen 1000 (Ethernet)
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.23 netmask 255.255.255.0 broadcast 192.168.1.255
ether b8:27:eb:d3:cb:70 txqueuelen 1000 (Ethernet)


/sbin/route

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default vodafone 0.0.0.0 UG 303 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 303 0 0 wlan0


/bin/ls -l /var/log/dpkg.log /var/log/dpkg.log.1 2>/dev/null

/bin/ls: cannot access '/var/log/dpkg.log.1': No such file or directory
-rw-r--r-- 1 root root 131177 Nov 28 10:55 /var/log/dpkg.log


/bin/grep 'status installed' /var/log/dpkg.log /var/log/dpkg.log.1 2>/dev/null | sort | tail -1

/var/log/dpkg.log:2020-11-28 10:55:16 status installed python3-tzlocal:all 1.5.1-1


/bin/df -m

Filesystem 1M-blocks Used Available Use% Mounted on
/dev/root 112391 6399 101378 6% /
devtmpfs 430 0 430 0% /dev
tmpfs 463 0 463 0% /dev/shm
tmpfs 463 13 450 3% /run
tmpfs 5 1 5 1% /run/lock
tmpfs 463 0 463 0% /sys/fs/cgroup
/dev/sda1 253 54 199 22% /boot
tmpfs 93 0 93 0% /run/user/1000


/bin/df -m | /usr/bin/tail -n +2 | /bin/egrep -v 'tmpfs|boot'

/dev/root 112391 6399 101378 6% /


ls -l /opt/vc/bin/vcgencmd /usr/bin/vcgencmd

-rwxr-xr-x 1 root root 16460 Jul 20 08:51 /opt/vc/bin/vcgencmd
lrwxrwxrwx 1 root root 20 Oct 22 16:32 /usr/bin/vcgencmd -> /opt/vc/bin/vcgencmd



**Python errors shown in the logs (if applicable):**


**Additional information:**

hassio installation

Checklist:

  • I updated to the latest version available
  • I checked that my MQTT broker is otherwise working

Release with the issue:

Last working release (if known):

Hardware, Operating System, Python version:

RPi 4, hassio OS...
Description of problem:
I am running Home Assistant installed from the image provided by the developer. After the boot sequence I am only allowed to enter the login and then I am logged in to the hassio OS, which does not support sudo command and other commons for general Linux. How do I install that sript? The RPi monitor card's manual says I have to install the MQTT2HA Daemon first, but Daemons's guide explains nothing on how to install itself under HA OS. Can onyone help me with that?

Run our report script 'genBugInfo' on your failing device and include the output here:


Python errors shown in the logs (if applicable):


Additional information:

Uptime in seconds?

Is your feature request related to a problem? Please describe.
I am not able to create an uptime sensor in seconds.
It is easier to deal with seconds to create automations.

Describe the solution you'd like
The uptime has a value that is impossible (for me) to change in seconds. For example, in this moment I have up_time: 12 days, 27 min
The file /proc/uptime contains the value in seconds (the first value). To get only the first value awk '{print $1}' /proc/uptime
Maybe you could add another property like up_time_s with that value

Describe alternatives you've considered
If you have a reverse formula to change the actual property up_time in a template sensor, I am very fine with that :-)
At the moment I use a ssh template to my raspberries to get it

After HA restart the sensors are unavailable in HA

When I restart Home Assistant, the sensors from RPI-Reporter-MQTT2hA-Daemon become unavailable.

I run this daemon on 3 raspberry pi's and all of them have this same problem.

Only when I reboot the Raspberry Pi, do the sensors become available in HA.

Any idea how I can solve this?

EDIT: I found out that when I use this command (sudo systemctl start isp-rpi-reporter.service) again. The sensors become back available at HA again. Any idea why this happens?

RPI - reporter via REST API

Hello,

I like your RPI reporter a lot. However I dont work with MQTT at home. I prefer working with REST-API's using swagger documentation. So that I can expose the info as an output on the Raspberry Pi that I monitor and collect the input via the sensor configuration on my Home automation.
I have this currently set up on my raspberry pi's. Is this something you are interested in, in seeing working?

Regards,

Thomas

Add easy way to report individual values to monitor

Thanks for your wonderful Daemon and perfect setup description - works like a charm!

To support individual programs or scripts running on the Raspberry Pi it would be more than useful if the monitoring/reporting of individual values/parameters could be added.

For example on my Pi there are multiple scripts running - it would be very helpful if I could use the RPI-Reporter_MQTT2HA-Daemon to report in parallel, which script was running on what time and for what period of time.
This could be done by different methods - e.g. an environment-value, which the script sets to 1 if running and 0 if not and is monitored by your program. Or e.g. by a program-call with some parameters (e.g. ./update_individual_value.py NEW_VALUE )
or any other smarter way to pass individual values to the script...

Happy to support / test / discuss (but unfortunately not smart enough, to implement from scratch on my own :( )

Add reporting of other mounted drives

This is not related to any problem just asking for more goodness!

Other drives can be mounted to our RPI. Let's report each identifying each, which is the boot drive, total space, and used space, etc.

does this only work with English language system?

Checklist:

  • I updated to the latest version available
  • I checked that my MQTT broker is otherwise working

Hardware, Operating System, Python version:

  • python3 --version = Python 3.7.3
  • uname -a = Linux pi4 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux

Description of problem:

When I run python3 /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py, I get the output below. I assume the ValueError is caused because the script expects something in English, but receives '1M-Blöcke', which is German.

Run our report script 'genBugInfo' on your failing device and include the output here:

# SCRIPT genBugInfo v1.0 run 20/08/05-16:56:52
# ----------------------------------------------------------------------

# /bin/cat /etc/apt/sources.list | /bin/egrep -v '#'
  
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

 ----

# /bin/cat /etc/apt/sources.list | /bin/egrep -v '#' | /usr/bin/awk '{ print  }' | /bin/grep . | /usr/bin/sort -u
  
buster

 ----

# /bin/uname -r
  
4.19.97-v7l+

 ----

# /bin/hostname -f
  
pi4

 ----

# /usr/bin/uptime
  
 16:56:52 up 1 day, 17 min,  2 users,  load average: 0,01, 0,23, 0,16

 ----

# /sbin/ifconfig
  
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 9b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Lokale Schleife)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.197  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fc15  prefixlen 64  scopeid 0x20<link>
        ether 9d  txqueuelen 1000  (Ethernet)
        RX packets 715740  bytes 879183621 (838.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 228173  bytes 24967680 (23.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


 ----

# /sbin/ifconfig | /bin/egrep 'Link|flags|inet|ether' | /bin/egrep -v -i 'lo:|loopback|inet6|\:\:1|127\.0\.0\.1'
  
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 9b  txqueuelen 1000  (Ethernet)
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.197  netmask 255.255.255.0  broadcast 192.168.100.255
        ether 9d  txqueuelen 1000  (Ethernet)

 ----

# /sbin/route
  
Kernel-IP-Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
default         192.168.100.1   0.0.0.0         UG    303    0        0 wlan0
192.168.100.0   0.0.0.0         255.255.255.0   U     303    0        0 wlan0

 ----


Python errors shown in the logs (if applicable):

none

Additional information:

As stated above, I assume this is due to my output being in a different language. Is this fixable, i.e. by changing some value in the .py file by hand? Or am I out of luck unless I set my system to English?

Thank you for your help.

Using /etc/os-release

just a suggestion not a issue.

You are using /etc/apt/sources.list and uname to determine Linux release and kernel version. For release name and version you could also use /etc/os-release and especially PRETTY_NAME and/or VERSION_ID.

Feature Request: MotionEyeOS

Is it possible to be able to install this on a MotionEyeOS RPi Zero? I have a few of these sprinkled about the property and would like to monitor them all within HA. But MotionEyeOS is a very scaled back OS and doesn't have full support of the commands used to install your scripts.

Thank you!

vcgencmd not found?

Successfully installed this on two other Pi's but having a problem on the 3rd!

Checklist:

  • I updated to the latest version available
  • I checked that my MQTT broker is otherwise working

Release with the issue:
v.1.4.2
Last working release (if known):
First install on this machine

Hardware, Operating System, Python version:
RPI 4 8Gb with SSD, RaspOS Buster, Python 3.7.3

Description of problem:
getting errors when running the script
pi@newdock:/opt/RPi-Reporter-MQTT2HA-Daemon $ python3 /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py [2020-08-11 13:42:37] * MQTT connection established [2020-08-11 13:42:37] [2020-08-11 13:42:38] Announcing RPi Monitoring device to MQTT broker for auto-discovery ... Traceback (most recent call last): File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 935, in <module> afterMQTTConnect() # now instead of after? File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 925, in afterMQTTConnect handle_interrupt(0) File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 910, in handle_interrupt update_values() File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 897, in update_values getSystemTemperature() File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 457, in getSystemTemperature interpretedTemp = float(rpi_gpu_temp_raw) ValueError: could not convert string to float: '/bin/sh: 1: /opt/vc/bin/vcgencmd: not found'

If I edit the script to set the path of vcgencmd to /usr/bin/vcgencmd the script runs without issue!
genBugInfo-200811-135326.txt

Run our report script 'genBugInfo' on your failing device and include the output here:


Python errors shown in the logs (if applicable):


Additional information:

IndexError: list index out of range

Receiving this on 3 Pi's all running RetroPie, all other Pi's are functioning as planned.

Traceback (most recent call last):
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 867, in
getNetworkIFs() # this will fill-in rpi_mac
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 516, in getNetworkIFs
getNetworkIFsUsingIP(ip_cmd)
File "/opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py", line 422, in getNetworkIFsUsingIP
interfaceName = lineParts[1].replace(':', '')
IndexError: list index out of range

SCRIPT genBugInfo v1.1 run 20/08/17-23:16:58

----------------------------------------------------------------------

/bin/cat /etc/apt/sources.list | /bin/egrep -v '#'

deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi


/bin/cat /etc/apt/sources.list | /bin/egrep -v '#' | /usr/bin/awk '{ print $3 }' | /bin/grep . | /usr/bin/sort -u | head -1

stretch


/bin/uname -r

4.14.98-v7+


/bin/hostname -f

sega


/usr/bin/uptime

23:16:58 up 3:54, 2 users, load average: 0.00, 0.02, 0.00


/sbin/ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.10.10.8 netmask 255.255.255.0 broadcast 10.10.10.255
inet6 fe80::6f66:b579:18a3:1aa5 prefixlen 64 scopeid 0x20
ether b8:27:eb:8e:4c:2a txqueuelen 1000 (Ethernet)
RX packets 142682 bytes 121598664 (115.9 MiB)
RX errors 0 dropped 43 overruns 0 frame 0
TX packets 46284 bytes 3949862 (3.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 420 bytes 22646 (22.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 420 bytes 22646 (22.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


/sbin/ifconfig | /bin/egrep 'Link|flags|inet|ether' | /bin/egrep -v -i 'lo:|loopback|inet6|::1|127.0.0.1'

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.10.10.8 netmask 255.255.255.0 broadcast 10.10.10.255
ether b8:27:eb:8e:4c:2a txqueuelen 1000 (Ethernet)


/sbin/route

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.10.10.1 0.0.0.0 UG 202 0 0 eth0
10.10.10.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0


/bin/ls -l /var/log/dpkg.log /var/log/dpkg.log.1 2>/dev/null

-rw-r--r-- 1 root root 103263 Aug 17 21:51 /var/log/dpkg.log
-rw-r--r-- 1 root root 1158261 May 1 22:30 /var/log/dpkg.log.1


/bin/grep 'status installed' /var/log/dpkg.log /var/log/dpkg.log.1 2>/dev/null | sort | tail -1

/var/log/dpkg.log:2020-08-17 21:51:57 status installed python3-keyring:all 10.1-1


/bin/df -m

Filesystem 1M-blocks Used Available Use% Mounted on
/dev/root 29875 16130 12514 57% /
devtmpfs 370 0 370 0% /dev
tmpfs 375 0 375 0% /dev/shm
tmpfs 375 10 365 3% /run
tmpfs 5 1 5 1% /run/lock
tmpfs 375 0 375 0% /sys/fs/cgroup
/dev/mmcblk0p1 57 22 36 39% /boot
tmpfs 75 0 75 0% /run/user/1000


/bin/df -m | /usr/bin/tail -n +2 | /bin/egrep -v 'tmpfs|boot'

/dev/root 29875 16130 12514 57% /


ls -l /opt/vc/bin/vcgencmd /usr/bin/vcgencmd

-rwxr-xr-x 1 root root 15176 Feb 18 2019 /opt/vc/bin/vcgencmd
lrwxrwxrwx 1 root root 20 Apr 1 2019 /usr/bin/vcgencmd -> /opt/vc/bin/vcgencmd


CPU load is not updated

Hi, first of all awesome work! I started using this script recently on a Pi 4 but ran into an issue with the CPU load information.
For me it does not seem to update after the initial run of the script. I set up the script as a service according to the installation guide and I receive the MQTT messages (in Home Assistant).
I see that other values like memory consumption are updated but the CPU usage remains stuck at the same values. I don't see any errors when running journalctl -u isp-rpi-reporter.service.
cat /proc/loadavg which seems to be used by the script actually returns normal and changing values if I manually run it.

Please let me know if I can provide any additional info. Here is the genBugInfo minus some private info

# SCRIPT genBugInfo v1.1 run 21/11/16-21:29:08
# ----------------------------------------------------------------------

# /bin/cat /etc/apt/sources.list | /bin/egrep -v '#'

deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

 ----

# /bin/cat /etc/apt/sources.list | /bin/egrep -v '#' | /usr/bin/awk '{ print $3 }' | /bin/grep . | /usr/bin/sort -u | head -1

buster

 ----

# /bin/uname -r

5.10.60-v7l+

 ----

# /bin/hostname -f

abcdefg // removed

 ----

# /usr/bin/uptime

 21:29:08 up 9 days,  4:59,  1 user,  load average: 0.19, 0.24, 0.26

 ----

# /sbin/ifconfig

// some network info removed

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:80:91:26:9a  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ...
        inet6 fe80::8b2a:beb4:b25e:a9ca  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:2b:2b:93  txqueuelen 1000  (Ethernet)
        RX packets 42012933  bytes 2192071394 (2.0 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 22918245  bytes 902076 (880.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 791094  bytes 181690386 (173.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 791094  bytes 181690386 (173.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

// ...

# /sbin/ifconfig | /bin/egrep 'Link|flags|inet|ether' | /bin/egrep -v -i 'lo:|loopback|inet6|\:\:1|127\.0\.0\.1'

br-368bf670ebdf: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:73:8d:8b:1e  txqueuelen 0  (Ethernet)
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:80:91:26:9a  txqueuelen 0  (Ethernet)
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        // ...
        ether ...  txqueuelen 1000  (Ethernet)
// ...
wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether ...  txqueuelen 1000  (Ethernet)

 ----
# /bin/ls -l /var/log/dpkg.log /var/log/dpkg.log.1 2>/dev/null

-rw-r--r-- 1 root root    0 Nov 15 00:00 /var/log/dpkg.log
-rw-r--r-- 1 root root 2884 Nov 14 15:23 /var/log/dpkg.log.1

 ----

# /bin/grep 'status installed' /var/log/dpkg.log /var/log/dpkg.log.1 2>/dev/null | sort | tail -1

/var/log/dpkg.log.1:2021-11-14 15:23:32 status installed python3-unidecode:all 1.0.23-1

 ----

# /bin/df -m

Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/root          29113 17477     10422  63% /
devtmpfs             776     0       776   0% /dev
tmpfs                937     0       937   0% /dev/shm
tmpfs                937    19       918   2% /run
tmpfs                  5     1         5   1% /run/lock
tmpfs                937     0       937   0% /sys/fs/cgroup
/dev/sda1         119675  3645    109909   4% /mnt/extssd
/dev/mmcblk0p1       253    49       204  20% /boot
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/30a40eb1dc4cb65318716c50b871c4e7650fb7c64663b09ebb41326b90fe$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/78591b6926421c059f470f1e4ff9ddcf07abc4dd4bc0fe2e3f5d3efa5dd3$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/f076bd314a68737903c4c227479dc8d19a9dd6727b41155d31df2c90c4c5$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/fbea69b7eb9d5b2a99e57a74ebd94aadd4cb7f368a59b5816fa0af5747c5$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/b0229cf122f48ab02b7d19496f7ab8573b367695aced47fe901a07a64702$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/c8d7de10df9c4778f34686c3dc702ca514c8dc6d653ff5af663a71217c88$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/957f3da8134297fff524fa0f21fa24232cbd40785d400506cd2873e4ecee$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/3d2edbbc670873f940326a4f4c935cd5a8cd345476f23b30812fc5ce698d$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/2379de8e708a6c6027b997e46343b55ec5db26b00b974263923e5a8319e2$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/5b8877d3ec4ed265cd166a26692b8cfaa5b5e154a3e37be6d845ec24e7eb$
tmpfs                188     0       188   0% /run/user/1000

 ----

# /bin/df -m | /usr/bin/tail -n +2 | /bin/egrep -v 'tmpfs|boot'

/dev/root          29113 17477     10422  63% /
/dev/sda1         119675  3645    109909   4% /mnt/extssd
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/30a40eb1dc4cb65318716c50b871c4e7650fb7c64663b09ebb41326b90fe$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/78591b6926421c059f470f1e4ff9ddcf07abc4dd4bc0fe2e3f5d3efa5dd3$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/f076bd314a68737903c4c227479dc8d19a9dd6727b41155d31df2c90c4c5$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/fbea69b7eb9d5b2a99e57a74ebd94aadd4cb7f368a59b5816fa0af5747c5$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/b0229cf122f48ab02b7d19496f7ab8573b367695aced47fe901a07a64702$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/c8d7de10df9c4778f34686c3dc702ca514c8dc6d653ff5af663a71217c88$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/957f3da8134297fff524fa0f21fa24232cbd40785d400506cd2873e4ecee$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/3d2edbbc670873f940326a4f4c935cd5a8cd345476f23b30812fc5ce698d$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/2379de8e708a6c6027b997e46343b55ec5db26b00b974263923e5a8319e2$
overlay            29113 17477     10422  63% /var/lib/docker/overlay2/5b8877d3ec4ed265cd166a26692b8cfaa5b5e154a3e37be6d845ec24e7eb$

 ----

# ls -l /opt/vc/bin/vcgencmd /usr/bin/vcgencmd

-rwxr-xr-x 1 root root 16460 Jan  5  2021 /opt/vc/bin/vcgencmd
lrwxrwxrwx 1 root root    20 Aug 31 16:50 /usr/bin/vcgencmd -> /opt/vc/bin/vcgencmd

 ----

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.