fastcgi.map-extensions = ( ".htm" => ".php", ".html" => ".php")<?php
$cpu_temp = exec ('cat /sys/class/thermal/thermal_zone0/temp')/1000;
$cpu_temp = number_format($cpu_temp , 1 , '.' , ',');
?>import weewx
from weewx.engine import StdServicefrom gpiozero import CPUTemperature
class AddCpuTemp(StdService):
def __init__(self, engine, config_dict):
# Initialize my superclass first: super(AddCpuTemp, self).__init__(engine, config_dict)
# Bind to any new archive record events: self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)
def new_archive_record(self, event):
cpu = CPUTemperature()
event.record['extraTemp1'] = ( cpu.temperature * 1.8 ) + 32
[Engine] [[Services]] # This section specifies the services that should be run. They are # grouped by type, and the order of services within each group # determines the order in which the services will be run. prep_services = weewx.engine.StdTimeSynch data_services = user.cputemp.AddCpuTemp
<tr> <td class="label">Server uptime</td> <td class="data">$station.os_uptime</td> </tr> <tr> <td class="label">Server CPU Temp</td> <td class="data">$current.extraTemp1</td> </tr> <tr> <td class="label">WeeWX uptime</td> <td class="data">$station.uptime</td> </tr>
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/51911b10-1bd3-4c73-89cd-22532f89eb63%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/0cd4a4b2-bf30-4f34-a567-4bff9120903f%40googlegroups.com.
import weewxif event.record['usUnits'] == weewx.US:event.record['extraTemp1'] = ( cpu.temperature * 1.8 ) + 32else:event.record['extraTemp1'] = cpu.temperature-tk
On Wed, Mar 18, 2020 at 8:38 AM Mike Revitt <mi...@cougar.eu.com> wrote:
Thanks Thomas,--Was looking at that but didn't know how, my Raspberry Pi reports the temperature in Celsius and the database is in Fahrenheit and obviously a check would be best.But how to do that easily?
On Wednesday, March 18, 2020 at 2:14:32 PM UTC, Thomas Keffer wrote:Well done!However, your extension makes the assumption that the archive record is always in US Customary. Best to put a check in there before doing the conversion.-tk
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.
Most likely cause is that you have entered some code in the wrong place. Can you post the entire contents of your /usr/share/weewx/user/cputemp.py ?
Gary
Since this is very interesting, I tried it right away. I created a python file called cputemp.AddCpuTemp.py with the content:
import weewx
from weewx.engine import StdServicefrom gpiozero import CPUTemperature
class AddCpuTemp(StdService):
def __init__(self, engine, config_dict):
# Initialize my superclass first: super(AddCpuTemp, self).__init__(engine, config_dict)
# Bind to any new archive record events: self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)
def new_archive_record(self, event):
cpu = CPUTemperature()
event.record['extraTemp1'] = ( cpu.temperature * 1.8 ) + 32
and save this under /usr/share/weewx/user/
In the weewx.conf have it the Service: data_services = user.cputemp.AddCpuTemp
Now this error message appears to me:
Did I forget something there?
Thanks for Help
Your python file needs to be named cputemp.py not cputemp.AddCpuTemp.py
Gary

event.record['extraTemp1'] = ( cpu.temperature * 1.8 ) + 32
by the solution of Thomas turns the syntax wrong. Although I am an absolute newbie in python, I know, that wrong indentation could make things mess up. So I am fine with the listing of Mike. Maybe it is useful to present a complete listing, easily transferable by copy/paste, for people like me.
Thanks!Peter
Gary