Page 1 of 1

internal temperature from other raspberry pi's

Posted: Wednesday 25 January 2017 23:35
by dakipro
From time to time my Kodi gets a bit hot, so I wanted to see and log its temperature in domoticz. I can see the temperature by typing /opt/vc/bin/vcgencmd measure_temp in the console, but wanted to send it to domoticz. And I found small script on google that I changed a bit, and have cron send value to virtual temperature sensor every few minutes. Script is very simple and looks like

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))
Beginners guide and cron setup (that I wish I had found :) ) is here
http://www.domoticz.com/forum/viewtopic ... 02#p116402

Re: internal temperature from other raspberry pi's

Posted: Wednesday 06 June 2018 9:58
by AYAMY
Hi,
this is extacly what i'm looking for.... THX

Re: internal temperature from other raspberry pi's

Posted: Monday 11 February 2019 22:24
by zodracom
so, de device ID is your IDX to the virtual sensor?

Re: internal temperature from other raspberry pi's

Posted: Monday 10 August 2020 12:29
by Jasper79
Thanks,

I tried using this though when entering

Code: Select all

python3 temperaturefordomoticz.py
it returns

Code: Select all

Traceback (most recent call last):
  File "temperaturefordomoticz.py", line 5, in <module>
    import urllib2
ModuleNotFoundError: No module named 'urllib2'
Edit: data does start to come through now.

Re: internal temperature from other raspberry pi's

Posted: Monday 10 August 2020 14:14
by FireWizard
Hi,

@Jasper79

You run this script as a Python3 script but it is a Python2 script.

Try:

Code: Select all

python temperaturefordomoticz.py
Regards

Re: internal temperature from other raspberry pi's

Posted: Monday 10 August 2020 15:47
by Jasper79
Thanks, that didn't end up with a error.