Check remote RPi temperature

Hi, I need to monitor a second RPI temperature (with Libreelec) from HA.
The Rpi is not always on: I shutdown it when it’s not necessary.

This command_line sensor work for me:

# Rpi Kodi Stanzetta CPU temp
- platform: command_line
  name: "Kodi Stanzetta - CPU Temp"
  command: ssh [email protected] cat /sys/class/thermal/thermal_zone0/temp
  unit_of_measurement: "°C"
  scan_interval: 120
  value_template: '{{ value | multiply(0.001) | round(2) }}'

but when the Pi is off, my log is full of:

Command failed: ssh [email protected] cat /sys/class/thermal/thermal_zone0/temp

I created a bynary_sensor to check if the Pi is on or off:

# Ping Rpi Stanzetta
- platform: ping
  host: 192.168.1.226
  name: "Kodi Stanzetta"
  count: 2
  scan_interval: 30

But now I’m very confused…
There is a way to merge them and avoid the log issues?
Something like: check first with ping if the Rpi state is on and only in this case send the command_line and show the result.

Any help?
Thx a lot

Hmm I would create a cronjob on the RPi LibreElec with a curl command… This would update the sensor, only when your Kodi is on.

I’m using mqtt sensors for this.

  • Install mosquitto clients on your remote pi
  • run the command or a script with crontab every 2 minutes
  • publish the values to mqtt topic
  • create mqtt sensor in ha

Example script:

#!/bin/bash
MQTT='192.168.123.123'
TOPIC='home/sensors/minibian/i2c_bus'
PAYLOAD=$(/usr/sbin/i2cdetect -y 1 | egrep '^20' | cut -d' ' -f2-9)
/usr/bin/mosquitto_pub -r -t "$TOPIC" -m "$PAYLOAD" -h "$MQTT"
3 Likes

Just thought about MQTT as well, but I think on LibreElec are no apt-get commands possible (correct me, if I am wrong) :slight_smile:

Good point!
Don’t know much about libreelec.

For security reason there is no working apt-get command in LibreElec.
Maybe with this addon?
https://forum.kodi.tv/showthread.php?tid=222109

1 Like