Integrar RPI-Monitor en Home Assistant

Hoy integraremos de una forma muy facil los datos que nos proporciona cada uno de los RPI-Monitor de nuestro ecosistema.

Para ello usaremos esta Card

La podemos instalas de forma manual o de una forma mas cómoda desde HACS “explorar o descargar repositorios” , buscaremos por rpi y añadiremos el repositorio.

Una vez descargado ya aparecerá en nuestra lista de tarjetas de Lovelace

En configuration.yaml añadiremos

    - url: /hacsfiles/lovelace-rpi-monitor-card/rpi-monitor-card.js
      type: module  

Previamente tendremos que tener RPI-Monitor instalado en nuestra Raspberry Pi y cada Raspberry Pi tendremos que instalar RPi-Reporter-MQTT2HA-Daemon

Instalaremos los requisitos previos con

sudo apt-get install git python3 python3-pip python3-tzlocal python3-sdnotify python3-colorama python3-unidecode python3-paho-mqtt 
sudo git clone https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon.git /opt/RPi-Reporter-MQTT2HA-Daemon

cd /opt/RPi-Reporter-MQTT2HA-Daemon
sudo pip3 install -r requirements.txt
sudo cp /opt/RPi-Reporter-MQTT2HA-Daemon/config.{ini.dist,ini}
sudo nano /opt/RPi-Reporter-MQTT2HA-Daemon/config.ini

Configuraremos el demonio según nuestras preferencias

[MQTT]

# The hostname or IP address of the MQTT broker to connect to (Default: localhost)
# Also read from the MQTT_HOSTNAME environment variable
hostname = 192.168.1.145

# The TCP port the MQTT broker is listening on (Default: 1883)
# Also read from the MQTT_PORT environment variable
port = 1883

# Maximum period in seconds between ping messages to the broker. (Default: 60)
#keepalive = 60

# by default Home Assistant listens to the /homeassistant but it can be changed for a given instal$
#  likewise, by default this script advertises on the same default topic. If you use a different
#  discovery prefix then specify yours here.  [default: homeassistant]
discovery_prefix = homeassistant

# NOTE: The MQTT topic used for this device is constructed as:
#  {base_topic}/{sensor_name}
#
# The MQTT base topic under which to publish the Raspberry Pi sensor data topics.
#base_topic = home/nodes

# The MQTT name for this Raspberry Pi as a sensor
sensor_name =  rpi-Pi2W1

# The MQTT broker authentification credentials (Default: no authentication)
# Will also read from MQTT_USERNAME and MQTT_PASSWORD environment variables
username = antonio
password = ***************

# Enable TLS/SSL on the connection
tls = false

# Path to CA Certificate file to verify host
#tls_ca_cert =

# Path to TLS client auth key file
#tls_keyfile =

# Path to TLS client auth certificate file
#tls_certfile =

Podremos probar que todo sea correcto con :

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

Si todo es correcto deberia aparecer algo similar a esto

Tendremos que dar permisos al demonio para poder acceder a las temperaturas

# 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

Lo haremos correr como un servicio

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

Si queremos actualizar a la ultima versión :

# 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

# 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

Reiniciaremos nuestra Raspberry Pi y crearemos nuestras tarjetas en lovelace

      - type: 'custom:rpi-monitor-card'
        entity: sensor.rpi_monitor_pi2w1
        card_style: glance
        temp_scale: C
        fs_severity:
          - color: Green
            from: 0
            to: 25
          - color: Orange
            from: 26
            to: 55
          - color: Red
            from: 56
            to: 100    

      - type: 'custom:rpi-monitor-card'
        entity: sensor.rpi_monitor_piia
        card_style: glance
        temp_scale: C
        fs_severity:
          - color: Green
            from: 0
            to: 25
          - color: Orange
            from: 26
            to: 55
          - color: Red
            from: 56
            to: 100   

Y así debería aparecernos en nuestro Home Assistant

Y con esto y un bizcocho ….