The temperature is updated in the file : /sys/class/thermal/thermal_zone0/temp
Only reading the first 2 digits on the first line.
Send this value to a virtual sensor in Domoticz every 5 minutes.
Note: This script has to run on the Proxmox server itself !! Not on the OS Domoticz runs on !!!!!
Code: Select all
import os
import re
import requests
import time
import sys
while True:
file = open('/sys/class/thermal/thermal_zone0/temp', 'r')
first_line = file.readline(2).strip()
# Close the file
file.close()
domoticzserver = "192.168.178.37:8080"
idx_temp = "373" # Put youre own IDX here of the virtual sensor
val_temp = first_line
res = requests.get(
"http://"
+ domoticzserver
+ "/json.htm?type=command¶m=udevice&idx="
+ idx_temp
+ "&nvalue=0&svalue="
+ val_temp
)
time.sleep(300) # send every 5 minutes