Kodi raspberry pi internal temperature

Moderator: leecollings

Post Reply
dakipro
Posts: 49
Joined: Thursday 17 December 2015 22:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Norway
Contact:

Kodi raspberry pi internal temperature

Post by dakipro »

Hi,
from time to time my Kodi gets a bit hot, so I would like to see its current temperature (or history) in domoticz. I can see the temperature by typing /opt/vc/bin/vcgencmd measure_temp in the console, but could this be somehow converted into a virtual sensor, or maybe integrated into the existing kodi integration?
Or is it already solved and I missed it?
Thanks!
Raspberry Pi 2 B - MySensors (dimmers, switches, motion, temperature, lux, humidity sensors)
zWave (220v switches)
various 433 via RFLink
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Kodi raspberry pi internal temperature

Post by pvm »

You can install domoticz on it (as a slave device). Or create a script that parses the output of the command you mention and add it to a virtual sensor in domoticz with a json call
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Kodi raspberry pi internal temperature

Post by Egregius »

Buy the alu Kodi case. It acts as a heat shield.
Mine runs overclocked at 1350Mhz and doesn't go above 60 degrees Celsius.
dakipro
Posts: 49
Joined: Thursday 17 December 2015 22:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Norway
Contact:

Re: Kodi raspberry pi internal temperature

Post by dakipro »

Thanks, I manage to google it and make it work somehow :)
I first made a virtual device that can be updated by calling the domoticz url directly

http://192.168.1.1:8080/json.htm?type=c ... &svalue=20

When I checked that the value is updated, I then used the python script I found on the google (changed it a bit)

Code: Select all

#!/usr/bin/python
import subprocess
import time
import os
import urllib2

serverIP = "192.168.1.1:8080"
deviceId = 1

currentTemp = subprocess.check_output(["/opt/vc/bin/vcgencmd","measure_temp"])
currentTemp = float(currentTemp.split("=")[1][:-3])
urllib2.urlopen("http://" + serverIP + "/json.htm?type=command&param=udevice&idx=" + str(deviceId) + "&nvalue=0&svalue=" + str(currentTemp))
(change your IP and your device id)

I saved the script in some "temperaturefordomoticz.py" file, somewhere on pi (I have my in /home/pi/ )
Then I called the script from command line like "python /home/pi/temperaturefordomoticz.py" to make sure that value is being sent to domoticz.

Then I made a cronjob that will send the temperature every 5 min with command
crontab -e

then at the bottom of the file I added
*/5 * * * * python /home/pi/temperaturefordomoticz.py

when you save file, you should see all cron jobs by typing "crontab -l" in command line
(more info on cron here https://debian-administration.org/artic ... _with_cron)
(Also note that Kodi osmc by default doesn't have a crontab installed by default, but can be easily installed either via osmc shop, or googling on how to add cron to raspberry)

I've added this on 3 Pi's I have, and they all work nice, I see them in the domoticz as temperature sensors :)

Hope someone finds this useful
Raspberry Pi 2 B - MySensors (dimmers, switches, motion, temperature, lux, humidity sensors)
zWave (220v switches)
various 433 via RFLink
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: Kodi raspberry pi internal temperature

Post by MikeF »

Here's an alternative approach I came up with, using dzVents on my Domoticz RPi. It uses ssh to send the 'vcgencmd measure_temp' command to the RPi running Kodi (in my case, on Libreelec). sshpass is used, which sends the user id and password in-line with the ssh command (which avoids having to enter the password every time you run ssh, but you may think it is not secure ...).

In my case, the Domoticz temperature device is called 'Kodi CPU'.

Code: Select all

--
-- This script uses ssh to read the CPU temperature on another RPi
-- and sends the result to Domoticz
--

return {
	on = {
		timer = { "every minute"}
	},
	execute = function(dz)
	
	local base = "sshpass -p <password> ssh <userid>@<url> -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "
	cmd = base .. "'vcgencmd measure_temp'"
	
	local f = io.popen(cmd)
	local r = f:read("*a")
	f:close()
	
	temp = string.match(r, '%d[%d.,]*')
	--print ("Kodi CPU temp: " .. temp)
	
	local kodi_cpu	= dz.devices("Kodi CPU")
	kodi_cpu.updateTemperature(temp)
	
	end

}
Substitute your values for the <brackets> in line 12.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests