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

2020-12-27 Thread Graham Eddy
i forgot to acknowledge the design consideration you raised that by calculating 
value once and storing it in the packet, unlike an xtype it is not 
re-calculated each time it is referenced

> On 28 Dec 2020, at 12:54 pm, Graham Eddy  wrote:
> 
> hmm, the ‘novelty’ i think is having an xtype calculated with values from 
> outside weewx (eg cpu temperature), and the expense of the calculation is not 
> really at issue - though normally they would be light-weight in case they are 
> used often (eg barometer)
> 
> architecturally anything external is supposed to brought into weewx via a 
> service and made available via weewx packet. (the *providing* of an xtype is 
> now positioned as a service, but the xtypes themselves are not.)
> 
> okay, i’ll recast my vitalstats from xtypes_service to data_service and not 
> bypass the packets...
> 
>> On 28 Dec 2020, at 11:40 am, Tom Keffer > > wrote:
>> 
>> 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.
> 

-- 
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/929A756F-DAE7-495C-9368-C85D2479E4F7%40gmail.com.


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

2020-12-27 Thread Graham Eddy
hmm, the ‘novelty’ i think is having an xtype calculated with values from 
outside weewx (eg cpu temperature), and the expense of the calculation is not 
really at issue - though normally they would be light-weight in case they are 
used often (eg barometer)

architecturally anything external is supposed to brought into weewx via a 
service and made available via weewx packet. (the *providing* of an xtype is 
now positioned as a service, but the xtypes themselves are not.)

okay, i’ll recast my vitalstats from xtypes_service to data_service and not 
bypass the packets...

> On 28 Dec 2020, at 11:40 am, Tom Keffer  wrote:
> 
> 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.

-- 
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/29A71619-51B9-41B6-A4AB-14E54482FB56%40gmail.com.


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

2020-05-07 Thread Tom Keffer
Looks simple enough, but cmon is not part of weewx. You should submit as a
PR to weewx-cmon .



On Thu, May 7, 2020 at 7:48 AM 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 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/db0db811-94ac-4762-ad31-9eb39b561bb9%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/CAPq0zEDd6%3DXZ7hRRa%3DhdMhYZMaz6u3a1aNbsLHF%2B3n2JhZPSpA%40mail.gmail.com.


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

2020-05-07 Thread Luc Heijst
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 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/db0db811-94ac-4762-ad31-9eb39b561bb9%40googlegroups.com.