internal temperature from other raspberry pi's

Python and python framework

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:

internal temperature from other raspberry pi's

Post 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
Raspberry Pi 2 B - MySensors (dimmers, switches, motion, temperature, lux, humidity sensors)
zWave (220v switches)
various 433 via RFLink
AYAMY
Posts: 21
Joined: Sunday 27 May 2018 11:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: internal temperature from other raspberry pi's

Post by AYAMY »

Hi,
this is extacly what i'm looking for.... THX
zodracom
Posts: 11
Joined: Monday 11 February 2019 21:20
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.7900
Location: Roosendaal, Netherlands
Contact:

Re: internal temperature from other raspberry pi's

Post by zodracom »

so, de device ID is your IDX to the virtual sensor?
Jasper79
Posts: 85
Joined: Sunday 26 July 2020 8:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: internal temperature from other raspberry pi's

Post 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.
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: internal temperature from other raspberry pi's

Post 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
Jasper79
Posts: 85
Joined: Sunday 26 July 2020 8:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: internal temperature from other raspberry pi's

Post by Jasper79 »

Thanks, that didn't end up with a error.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest