Re: [weewx-user] Re: weewx-cmon doesn't read cpu_temp of Raspberri PI

2020-12-27 Thread Tom Keffer
That's a novel use of xtypes, but I'm not sure it's always a good idea. In
this case, I think you'd be better off simply adding the type to the LOOP
packet or archive record.

The intended purpose of xtypes is to calculate derived variables. It's
entirely possible it could be called many times during a reporting cycle,
depending on the template used. Something involving I/O could be very
expensive.

Having said that, xtypes also do database accesses, which can also be very
expensive, so my advice is inconsistent. So, not saying never do it, but
think it through.

-tk

On Sun, Dec 27, 2020 at 3:44 PM Graham Eddy  wrote:

> an alternative to repurposing an existing data_type is to define an xtype
> (e.g. see https://github.com/g-eddy/weewx-vitalstats)
>
> On 28 Dec 2020, at 9:05 am, Kevin Chapman  wrote:
>
> Thank you.  I will check it out.
>
> On Sun, Dec 27, 2020 at 6:00 AM Mike Revitt  wrote:
>
>> Sorry it has taken so long to respond to this, but I have just finished
>> documenting how I added the CPU Temperature to my website, this is all
>> documented here
>> 
>>
>> https://www.cougar.eu.com/useful-guides/weewx-guides/rasberry-pi/read-cpu-temp.html
>>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/6B658B72-0127-4CA6-BC85-60A52CB0A9E7%40gmail.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CAPq0zEC0O72sOpRhZE6b1vZ%3DxrW725Hr0XrsK%3DXAsjryejj9sQ%40mail.gmail.com.


Re: [weewx-user] Re: weewx-cmon doesn't read cpu_temp of Raspberri PI

2020-12-27 Thread Graham Eddy
an alternative to repurposing an existing data_type is to define an xtype (e.g. 
see https://github.com/g-eddy/weewx-vitalstats)

> On 28 Dec 2020, at 9:05 am, Kevin Chapman  wrote:
> 
> Thank you.  I will check it out.  
> 
> On Sun, Dec 27, 2020 at 6:00 AM Mike Revitt  > wrote:
> Sorry it has taken so long to respond to this, but I have just finished 
> documenting how I added the CPU Temperature to my website, this is all 
> documented here 
> 
>  
> https://www.cougar.eu.com/useful-guides/weewx-guides/rasberry-pi/read-cpu-temp.html
>  
> 

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/6B658B72-0127-4CA6-BC85-60A52CB0A9E7%40gmail.com.


Re: [weewx-user] Re: weewx-cmon doesn't read cpu_temp of Raspberri PI

2020-11-12 Thread Kevin Chapman
Ok cool. I’ll check the database. Thanks for taking the time explaining it.

On Thu, Nov 12, 2020 at 9:02 PM vince  wrote:

> I would look for values in extraTemp1 in your database, as it seems that's
> where the python code is putting it.
>
> A query that would report the last 10 readings of this sorted with most
> recent at the top is:
>
> echo "select
> datetime(dateTime,'unixepoch','localtime'),dateTime,extraTemp1 from archive
> order by rowid desc limit 10;" | sqlite3 weewx.sdb
>
> What this is doing is saying 'give me a human readable date+time, the
> dateTime element, and the extraTemp1 element' from the archive table in the
> weewx.sdb database...and reverse sort it, showing me the 10 most recent
> readings (whew).
>
> The location of weewx.sdb differs depending on how you installed weewx and
> what os you are running.   See
> http://weewx.com/docs/usersguide.htm#Where_to_find_things for what's
> where in the various variants of operating systems etc.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "weewx-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/weewx-user/Iny0WMj78cU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> weewx-user+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/8a08f5b0-73be-43ff-aaca-0ec102e5aa2dn%40googlegroups.com
> 
> .
>
-- 
-
Kevin Chapman
(713) 245-9368

Life is a food chain.  Be at the top or be on the menu!
-

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CACwjpb3uUd5jPmH5yfBsce7eBHkKQs0dSGCDcz2oWkA4ZQiD1w%40mail.gmail.com.


Re: [weewx-user] Re: weewx-cmon doesn't read cpu_temp of Raspberri PI

2020-11-12 Thread vince
I would look for values in extraTemp1 in your database, as it seems that's 
where the python code is putting it.

A query that would report the last 10 readings of this sorted with most 
recent at the top is:

echo "select 
datetime(dateTime,'unixepoch','localtime'),dateTime,extraTemp1 from archive 
order by rowid desc limit 10;" | sqlite3 weewx.sdb

What this is doing is saying 'give me a human readable date+time, the 
dateTime element, and the extraTemp1 element' from the archive table in the 
weewx.sdb database...and reverse sort it, showing me the 10 most recent 
readings (whew).

The location of weewx.sdb differs depending on how you installed weewx and 
what os you are running.   
See http://weewx.com/docs/usersguide.htm#Where_to_find_things for what's 
where in the various variants of operating systems etc.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/8a08f5b0-73be-43ff-aaca-0ec102e5aa2dn%40googlegroups.com.


Re: [weewx-user] Re: weewx-cmon doesn't read cpu_temp of Raspberri PI

2020-11-12 Thread Kevin Chapman
So below is the code I used from Mike Revitt.  I have no idea if it comes
from a package. I followed Mike’s instructions as well as I could.  He was
not clear what to name it or where to put it.  I created the python script
in the ‘user/share/weewx/user folder.  At first, I named it AddCpuTemp.py
but that generated errors starting weewx.  Then I named it cputemp.py and
the startup errors went away.  I hope that makes sense.



On Thu, Nov 12, 2020 at 6:23 PM vince  wrote:

> We'd have to see the code you're running to look at it in detail.
> Where did you get 'cputemp.py' and how can we get a look at the exact
> version you're running ?
>
> FWIW - you check the temperature on a pi by running "vcgencmd
> measure_temp" which reads the right thing under /proc and formats it for
> output
>
> On Thursday, November 12, 2020 at 3:19:45 PM UTC-8 kdch...@gmail.com
> wrote:
>
>> Ok,  I am not familiar with Python at all.  I managed to work through the
>> instructions above and make the changes to my weewx.conf file and then
>> create cputemp.py in my /usr/share/weewx/user directory.  This eliminated
>> the errors in the my syslog.  I am not seeing the cpu temp on the charts.
>> How would I look up the variables in python to see if they are registering
>> at all.
>>
>>
>>> On Friday, May 8, 2020 at 3:41:39 AM UTC-5, Mike Revitt wrote:

 I have this working on my Rasberry pi at
 https://weather.cougar.eu.com/telemetry.html and this is how I did it

 in weewx.conf

 In
 [Engine]
  [[Services]]

 set

 data_services = user.cputemp.AddCpuTemp

 Then add this Python program to the bin user directory where your
 Rasberry Pi code is.

 #Copyright (c) 2009-2020 Mike Revitt

 #See the file LICENSE.txt for your rights.

 """Gets the CPU temperature on a Rasberry Pi"""



 *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()



 *if* event.record['usUnits'] == weewx.US:

 event.record['extraTemp1'] = ( cpu.temperature * 1.8 ) + 32

 *else*:

 event.record['extraTemp1'] = cpu.temperature





 You can then access the Rasberry Pi CPU temperature as the variable
 extraTemp1 from within your HTML files

>>> --
-
Kevin Chapman
(713) 245-9368

Life is a food chain.  Be at the top or be on the menu!
-

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CACwjpb0H5YB6Asi%3DXDOQpFo51pnwnm%3D7wvknCHof5a0Gjy3RLA%40mail.gmail.com.


Re: [weewx-user] Re: weewx-cmon doesn't read cpu_temp of Raspberri PI

2020-05-09 Thread Mike Revitt
Glad I could help

On Friday, May 8, 2020 at 2:37:16 PM UTC+1, steeple ian wrote:
>
> Works perfectly.
>
> On Fri, 8 May 2020 at 09:41, Mike Revitt  > wrote:
>
>> I have this working on my Rasberry pi at 
>> https://weather.cougar.eu.com/telemetry.html and this is how I did it
>>
>> in weewx.conf 
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/47cbe2b4-77db-496d-b728-0cf2b3065119%40googlegroups.com.


Re: [weewx-user] Re: weewx-cmon doesn't read cpu_temp of Raspberri PI

2020-05-08 Thread steeple ian
Works perfectly.

On Fri, 8 May 2020 at 09:41, Mike Revitt  wrote:

> I have this working on my Rasberry pi at
> https://weather.cougar.eu.com/telemetry.html and this is how I did it
>
> in weewx.conf
>
> In
> [Engine]
>  [[Services]]
>
> set
>
> data_services = user.cputemp.AddCpuTemp
>
> Then add this Python program to the bin user directory where your Rasberry
> Pi code is.
>
> #Copyright (c) 2009-2020 Mike Revitt
>
> #See the file LICENSE.txt for your rights.
>
> """Gets the CPU temperature on a Rasberry Pi"""
>
>
>
> *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()
>
>
>
> *if* event.record['usUnits'] == weewx.US:
>
> event.record['extraTemp1'] = ( cpu.temperature * 1.8 ) + 32
>
> *else*:
>
> event.record['extraTemp1'] = cpu.temperature
>
>
>
>
>
>
>
>
> On Thursday, May 7, 2020 at 3:48:53 PM UTC+1, Luc Heijst wrote:
>>
>> Recently I downloaded the latest version of weewx-cmon (v 0.20) which was
>> converted to use with python3.
>> This version, and also elder versions of cmon.py, did not read the
>> cpu-temp of my Raspberri PI systems (models 1B, 2B, 3B and 3B+).
>>
>> On my raspberry PI the following statement is true:
>> *os.path.exists(tdir)*, still a cpu-temp could not be found in this
>> section
>> The *elif os.path.exists(tfile):* statement caused the bottem section to
>> be skipped and that is the section that reads the RPI cpu-temp.
>>
>> See the modifications in yellow which fixed this problem.
>>
>> Luc
>>
>> --- snipped of cmon.py ---
>> # read cpu temperature
>> tdir = '/sys/class/hwmon/hwmon0/device'
>> # rpi keeps cpu temperature in a different location
>> tfile = '/sys/class/thermal/thermal_zone0/temp'
>> *temp_found = False*
>> if os.path.exists(tdir):
>> try:
>> for f in os.listdir(tdir):
>> if f.endswith('_input'):
>> s = self._readproc_line(os.path.join(tdir, f))
>> if s and len(s):
>> *temp_found = True*
>> n = f.replace('_input', '')
>> t_C = int(s) / 1000 # degree C
>> record['cpu_' + n] = t_C
>> except Exception as e:
>> logdbg("read failed for %s: %s" % (tdir, e))
>> ### elif os.path.exists(tfile):  ### original statement
>> if* not temp_found and *os.path.exists(tfile):
>> try:
>> s = self._readproc_line(tfile)
>> t_C = int(s) / 1000 # degree C
>> record['cpu_temp'] = t_C
>> except Exception as e:
>> logdbg("read failed for %s: %s" % (tfile, e))
>>
>> ---
>>
>>
> You can then access the Rasberry Pi CPU temperature as the variable
> extraTemp1 from within your HTML files
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/368a7cda-13db-4d7c-a11a-48449d9eb48f%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CADASSaQ9fC9DzFoXJDF2X%2BZxAutnsErr765D6W8b2%2B54zebbAA%40mail.gmail.com.