Hello.

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  StdService
from    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:


Mar 26 09:34:29 raspberrypi weewx[1412]: engine: Loading service 
weewx.engine.StdTimeSynch
Mar 26 09:34:29 raspberrypi weewx[1412]: engine: Finished loading service 
weewx.engine.StdTimeSynch
Mar 26 09:34:29 raspberrypi weewx[1412]: engine: Loading service 
user.cputemp.AddCpuTemp
Mar 26 09:34:29 raspberrypi weewx[1412]: engine: Caught unrecoverable 
exception in engine:
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****  No module named cputemp
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****  Traceback (most recent 
call last):
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****    File 
"/usr/share/weewx/weewx/engine.py", line 888, in main
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****      engine = 
engine_class(config_dict)
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****    File 
"/usr/share/weewx/weewx/engine.py", line 78, in __init__
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****      
self.loadServices(config_dict)
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****    File 
"/usr/share/weewx/weewx/engine.py", line 142, in loadServices
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****      
self.service_obj.append(weeutil.weeutil._get_object(svc)(self, config_dict))
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****    File 
"/usr/share/weewx/weeutil/weeutil.py", line 1107, in _get_object
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****      mod = 
__import__(module)
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****  ImportError: No module 
named cputemp
Mar 26 09:34:29 raspberrypi weewx[1412]:     ****  Exiting.

Did I forget something there?

Thanks for Help


Am Mittwoch, 18. März 2020 14:34:41 UTC+1 schrieb Mike Revitt:
>
> Not sure if you are still looking for solutions, but I liked you idea so 
> had a look at implementing it in Python.
>
> Turns out it was easier than I thought.
>
> 1) create a python file and put it into the bin/user directory, this file 
> gets the CPU temperature, coverts it to Fahrenheit and puts it into the 
> extraTemp1 column in the database
>
> import  weewx
> from    weewx.engine    import  StdService
> from    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
>
>
> 2) modify weewx.conf to call the new file
> [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
>
>
> Now the value can be obtained anywhere you want by 
> referencing $current.extraTemp1
> I modified about.inc in the seasons skin with the following
>
>     <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>
>
>
> Also you can now access the dayTemp graph to see the plots over time
>
> On Thursday, February 20, 2020 at 4:55:00 PM UTC, Vetti52 wrote:
>>
>> Sorry for being too dumb for python...
>>
>> I want to show the actual cpu temperature in the "About this weather 
>> station" section. On my Raspberry Pi I get the result: 
>>
>> $ vcgencmd measure_temp
>> temp=53.0'C
>>
>> However, I do not know, how to enter this into a skin file. 
>> I gave a first try to
>>
>> <?PHP
>> echo exec('vcgencmd measure_temp|sed "s/'/ °/"');
>> ?>
>>
>> resulting in
>> VCHI initialization failed
>>
>> I have added www-data to the video group, but this did not help. But, may 
>> be, it is much easier to realize. Please help!
>>
>>
>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/32a7dbcf-785b-4608-80fe-5f05c1b58f6b%40googlegroups.com.

Reply via email to