update readme

This commit is contained in:
hjelev
2023-02-05 15:42:44 +02:00
committed by Masoko
parent 10f264e860
commit 6742608de4

View File

@@ -21,9 +21,11 @@ Run this command to use the automated installation:
```bash ```bash
bash <(curl -s https://raw.githubusercontent.com/hjelev/rpi-mqtt-monitor/master/remote_install.sh) bash <(curl -s https://raw.githubusercontent.com/hjelev/rpi-mqtt-monitor/master/remote_install.sh)
``` ```
Raspberry Pi MQTT monitor will be intalled in the location where the installer is called, inside a folder named rpi-mqtt-monitor. Raspberry Pi MQTT monitor will be intalled in the location where the installer is called, inside a folder named rpi-mqtt-monitor.
The auto-installer needs the software below and will install it if its not found: The auto-installer needs the software below and will install it if its not found:
* python (2 or 3) * python (2 or 3)
* python-pip * python-pip
* git * git
@@ -33,27 +35,37 @@ Only python is not automatically installed, the rest of the dependancies should
It will also help you configure the host and credentials for the mqtt server in config.py and create the cronjob configuration for you. It will also help you configure the host and credentials for the mqtt server in config.py and create the cronjob configuration for you.
## Manual ## Manual
If you don't like the automated installation here are manuall installation instructions: If you don't like the automated installation here are manuall installation instructions:
1. Install pip if you don't have it: 1. Install pip if you don't have it:
```bash ```bash
$ sudo apt install python-pip sudo apt install python-pip
``` ```
2. Then install this python module needed for the script: 2. Then install this python module needed for the script:
```bash ```bash
$ pip3 install paho-mqtt pip3 install paho-mqtt
``` ```
3. Install git if you don't have it: 3. Install git if you don't have it:
```bash ```bash
$ apt install git apt install git
``` ```
4. Clone the repository: 4. Clone the repository:
```bash ```bash
$ git clone https://github.com/hjelev/rpi-mqtt-monitor.git git clone https://github.com/hjelev/rpi-mqtt-monitor.git
``` ```
5. Rename ```src/config.py.example``` to ```src/config.py``` 5. Rename ```src/config.py.example``` to ```src/config.py```
## Configuration ## Configuration
(only needed for manual installation) (only needed for manual installation)
Populate the variables for MQTT host, user, password and main topic in ```src/config.py```. Populate the variables for MQTT host, user, password and main topic in ```src/config.py```.
@@ -93,16 +105,21 @@ The group message looks like this:
## Test Raspberry Pi MQTT Monitor ## Test Raspberry Pi MQTT Monitor
Run Raspberry Pi MQTT Monitor (you might need to update the path in the command below, depending on where you installled it) Run Raspberry Pi MQTT Monitor (you might need to update the path in the command below, depending on where you installled it)
```bash ```bash
$ /usr/bin/python3 /home/pi/rpi-mqtt-monitor/rpi-cpu2mqtt.py /usr/bin/python3 /home/pi/rpi-mqtt-monitor/rpi-cpu2mqtt.py
``` ```
Once you run Raspberry Pi MQTT monitor there will be no output if it run OK, but you should get 8 or more messages via the configured MQTT server (the messages count depends on your configuration). Once you run Raspberry Pi MQTT monitor there will be no output if it run OK, but you should get 8 or more messages via the configured MQTT server (the messages count depends on your configuration).
## Schedule Raspberry Pi MQTT Monitor execution ## Schedule Raspberry Pi MQTT Monitor execution
Create a cron entry like this (you might need to update the path in the cron entry below, depending on where you installed it): Create a cron entry like this (you might need to update the path in the cron entry below, depending on where you installed it):
``` ```
*/2 * * * * /usr/bin/python /home/pi/rpi-mqtt-monitor/rpi-cpu2mqtt.py */2 * * * * /usr/bin/python /home/pi/rpi-mqtt-monitor/rpi-cpu2mqtt.py
``` ```
## Home Assistant Integration ## Home Assistant Integration
![Rapsberry Pi MQTT monitor in Home Assistant](images/rpi-cpu2mqtt-hass.jpg) ![Rapsberry Pi MQTT monitor in Home Assistant](images/rpi-cpu2mqtt-hass.jpg)
@@ -111,6 +128,7 @@ Once you installed the script on your raspberry you need to create some sensors
If you are using ```discovery_messages```, then this step is not required as a new MQTT device will be automatically created in Home Assistant and all you need to do is add it to a dashboard. If you are using ```discovery_messages```, then this step is not required as a new MQTT device will be automatically created in Home Assistant and all you need to do is add it to a dashboard.
This is the sensors configuration if ```group_messages = True``` assuming your sensors are separated in ```sensors.yaml``` file. This is the sensors configuration if ```group_messages = True``` assuming your sensors are separated in ```sensors.yaml``` file.
```yaml ```yaml
- platform: mqtt - platform: mqtt
name: 'rpi4 cpu load' name: 'rpi4 cpu load'
@@ -174,6 +192,7 @@ This is the sensors configuration if ```group_messages = True``` assuming your s
``` ```
This is the sensors configuration if ```group_messages = False``` assuming your sensors are separated in ```sensors.yaml``` file. This is the sensors configuration if ```group_messages = False``` assuming your sensors are separated in ```sensors.yaml``` file.
```yaml ```yaml
- platform: mqtt - platform: mqtt
state_topic: "masoko/rpi4/cpuload" state_topic: "masoko/rpi4/cpuload"
@@ -269,7 +288,9 @@ entities:
``` ```
# To Do # To Do
- maybe add network traffic monitoring via some third party software (for now I can't find a way to do it without additional software) - maybe add network traffic monitoring via some third party software (for now I can't find a way to do it without additional software)
# Feature request: # Feature request
If you want to suggest a new feature or improvement don't hesitate to open an issue or pull request. If you want to suggest a new feature or improvement don't hesitate to open an issue or pull request.