[weewx-user] Re: sdr.py not parsing Oregon WGR800X output correctly.

2020-05-25 Thread 'Rob Series' via weewx-user
Hi Gazza,
The 'if' statement is on the right hand side of the '=' sign is actually a 
ternary operator. Read the expression as :

  if obj.get('battery_ok') == 'OK':
   pkt['battery'] = 1 
else:
  pkt['battery']=0

(In python Numeric zero, None or False all evaluate to False, anything else 
is true). 

C++ has a similar operator ? : operator.

See https://www.python.org/dev/peps/pep-0308/ for the rational. Personally 
I find it very confusing to use 'if' for both forms.

Hope this helps. Good luck.

Rob


On Monday, 25 May 2020 11:09:09 UTC+1, Gazza wrote:
>
>
> Hi Rob,
>
> I don't know much about python so can you explain how the new version of 
> the battery status works as I still have to sort that for my mates station. 
>
> if 'battery_ok' in obj:
> pkt['battery'] = 1 if obj.get('battery_ok') == 'OK' else 0
>
> If the received data is "battery_ok" : 1 ( or "battery_ok" : 0 for flat 
> battery), what is the == 'OK' doing as it will never return a result of 
> 'OK" ??
>
>
> Gaz
>

-- 
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/662e5e8a-7cbb-4cac-af52-405abae5f1a4%40googlegroups.com.


[weewx-user] Re: sdr.py not parsing Oregon WGR800X output correctly.

2020-05-25 Thread Gazza

Hi Rob,

I don't know much about python so can you explain how the new version of 
the battery status works as I still have to sort that for my mates station. 

if 'battery_ok' in obj:
pkt['battery'] = 1 if obj.get('battery_ok') == 'OK' else 0

If the received data is "battery_ok" : 1 ( or "battery_ok" : 0 for flat 
battery), what is the == 'OK' doing as it will never return a result of 
'OK" ??


Gaz

-- 
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/e8aabc20-d62b-44ab-934f-7187f5383c27%40googlegroups.com.


[weewx-user] Re: sdr.py not parsing Oregon WGR800X output correctly.

2020-05-24 Thread 'Rob Series' via weewx-user
Thanks. In the end I kept the sensor name the same and mimiced the code for 
parse_json() from another posting so its compatible with both versions of 
rtl_433. 
NB original version of sdr.py parses battery status the wrong way round (0 
is False, 1 is True). Seems to be a common problem in lots of sensors.
Here is the fixed code:

# {"time" : "2018-08-04 15:29:27", "brand" : "OS", "model" : "PCR800", 
"id" : 236, "channel" : 0, "battery" : "OK", "rain_rate" : 0.000, 
"rain_total" : 109.594}
# {"time" : "2020-05-23 11:18:53", "brand" : "OS", "model" : 
"Oregon-PCR800", "id" : 40, "channel" : 0, "battery_ok" : 1, 
"rain_rate_in_h" : 0.000, "rain_in" : 97.571}
@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['usUnits'] = weewx.US
pkt['house_code'] = obj.get('id')
pkt['channel'] = obj.get('channel')

if 'battery' in obj:
pkt['battery'] = 1 if obj.get('battery') == 'OK' else 0
if 'battery_ok' in obj:
pkt['battery'] = 1 if obj.get('battery_ok') == 'OK' else 0

# Rain rate (inches/hour - weewx.us set above)
if 'rain_rate' in obj:
pkt['rain_rate'] = Packet.get_float(obj, 'rain_rate')
if 'rain_rate_in_h' in obj:
pkt['rain_rate'] = Packet.get_float(obj, 'rain_rate_in_h')

# Total rainfall (inches)
if 'rain' in obj:
pkt['rain'] = Packet.get_float(obj, 'rain')
if 'rain_in' in obj:
pkt['rain'] = Packet.get_float(obj, 'rain_in')

return OS.insert_ids(pkt, OSPCR800Packet.__name__)

Looking at the code for rtl_433 lots of other sensors are affected by the 
cnages in rtl_443. Is there a mechanism for asking the developers to update 
the official version of sdr.py?

Many thanks

On Sunday, 24 May 2020 04:53:32 UTC+1, Gazza wrote:
>
>
> As you have alredy found this is another case where rtl_433 has changed 
> the reported info from what is expected by sdr.py V0.77.
>
> For this station it looks like most of the strings have changed. 
>
> In the 'class OSWGR800Packet(Packet):' section of sdr.py try changing 
> these bits,
>
> fromIDENTIFIER = "WGR800"
> to  IDENTIFIER = "Oregon-WGR800"
>
>
> frompkt['wind_gust'] = Packet.get_float(obj, 'gust')
>   pkt['wind_speed'] = Packet.get_float(obj, 'average')
>   pkt['wind_dir'] = Packet.get_float(obj, 'direction')
>
>
> to   pkt['wind_gust'] = Packet.get_float(obj, 'wind_max_m_s')
>   pkt['wind_speed'] = Packet.get_float(obj, 'wind_avg_m_s')
>   pkt['wind_dir'] = Packet.get_float(obj, 'wind_dir_deg')
>
>
> The battery status info has also changed from 'battery:OK' to 'battery_ok 
> : 1' but I'm not sure what change is needed to fix that.
>
>
> Gaz
>

-- 
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/47aabe74-f73f-4a08-b4f6-38c1e0eeb9cc%40googlegroups.com.


[weewx-user] Re: sdr.py not parsing Oregon WGR800X output correctly.

2020-05-23 Thread Gazza

As you have alredy found this is another case where rtl_433 has changed the 
reported info from what is expected by sdr.py V0.77.

For this station it looks like most of the strings have changed. 

In the 'class OSWGR800Packet(Packet):' section of sdr.py try changing these 
bits,

fromIDENTIFIER = "WGR800"
to  IDENTIFIER = "Oregon-WGR800"


frompkt['wind_gust'] = Packet.get_float(obj, 'gust')
  pkt['wind_speed'] = Packet.get_float(obj, 'average')
  pkt['wind_dir'] = Packet.get_float(obj, 'direction')


to   pkt['wind_gust'] = Packet.get_float(obj, 'wind_max_m_s')
  pkt['wind_speed'] = Packet.get_float(obj, 'wind_avg_m_s')
  pkt['wind_dir'] = Packet.get_float(obj, 'wind_dir_deg')


The battery status info has also changed from 'battery:OK' to 'battery_ok : 
1' but I'm not sure what change is needed to fix that.


Gaz

-- 
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/45760cec-2038-4b2d-8ba7-8fff073d94be%40googlegroups.com.


[weewx-user] Re: sdr.py not parsing Oregon WGR800X output correctly.

2020-05-23 Thread 'Rob Series' via weewx-user
Hi,
I have done some more research and it looks like there was a change in 
RTL_433 at tag 19.08 (August 2019) that changed the naming convention for a 
significant number of wind related fields for lots of sensors. I guess 
sdr.py needs to be updated to take this into account. I would offer but my 
main programming was over 20 years ago and have never programmed in Python 
so I would probably do more harm than good.

https://github.com/merbanan/rtl_433/commit/6d21cad0f158fbc6064d66ddd1abf96d6ba4867b#diff-06935eba6ba3c8d3e4b0d4d59d294ac8

see also:

https://github.com/merbanan/rtl_433/blob/6d75c7db86793072f854a33efa0a88a83e06e796/src/devices/oregon_scientific.c#L637-L654

On Wednesday, 20 May 2020 14:00:38 UTC+1, Rob Series wrote:
>
> Hi,
>
> Please could anyone help. I'm having problems using an Oregon wind speed 
> sensor using instructions on /weewx/weewx/wiki/sdr-rpi-recipe.
> This was working, but following an upgrade from an old WGR800 to the newer 
> WGR800X it seems to have broken. 
>  
> Output from sdr.py shows its getting the correct wind speed, but the parse 
> is breaking. The crazy thin is it works with my older WGR800 unit where the 
> input appears to be the same format. Is it possibly related to the \n
>
> WEEWX SDR FILTER OUTPUT
> ===
> * pi@raspberrypi:~ $ sudo PYTHONPATH=/usr/share/weewx python 
> /usr/share/weewx/user/sdr.py --cmd="rtl_433 -M utc -F json" --debug*
>
> out:[u'{"time" : "2020-05-20 12:24:03", "brand" : "OS", "model" : 
> "Oregon-WGR800", "id" : 100, "channel" : 0, "battery_ok" : 1, 
> "wind_max_m_s" : 1.700, "wind_avg_m_s" : 0.600, "wind_dir_deg" : 202.500
> }\n']
>
> parsed: {'battery.0:100.OSWGR800Packet': 1, 
> 'wind_dir.0:100.OSWGR800Packet': None, 'dateTime': 1589977443, 
> 'wind_speed.0:100.OSWGR800Packet': None, 
> 'wind_gust.0:100.OSWGR800Packet': None, 'usUnits': 17}
>
>
> *weewx.conf*
>
> ...
>   [SDR]
> # This section is for the software-defined radio driver.
> 
> # The driver to use
> driver = user.sdr
> cmd = rtl_433 -M utc -F json
> path=/usr/local/bin/
> log_unknown_sensors = True
> log_unmapped_sensors = True
> 
> [[sensor_map]]  
> # Wind sensor
> windSpeed = wind_speed.0:100.OSWGR800Packet
> windGust = wind_gust.0:100.OSWGR800Packet
> windDir = wind_dir.0:100.OSWGR800Packet
> windBatteryStatus = battery.0:100.OSWGR800Packet
>
>
> Other info
> ==
> pi@raspberrypi:~ $ sudo PYTHONPATH=/usr/share/weewx python 
> /usr/share/weewx/user/sdr.py --version
> sdr driver version 0.77
>
> pi@raspberrypi:~ $ rtl_433 -V
> rtl_433 version 20.02-55-gc1d1f9f branch master at 202005162227 inputs 
> file rtl_tcp RTL-SDR
>
>
>
> ALSO
> 
> If anyone has access to edit the sdr-rpi-recepie page, could the add 
> appropriate 'cmd' and 'path' lines to the conf file (or should thhs have 
> been added automativally by weewx_conf and the install script?
> It took me some time to figure it out.
>
> Many thanks for a great product.
>
>
>
>

-- 
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/f314cf81-9a25-404f-9b49-e17a50535a4d%40googlegroups.com.


[weewx-user] Re: sdr.py Fine Offset WH32B sensor

2019-04-08 Thread mwall
thank you!  changes added to the weewx-sdr driver at commit 8d057e4

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[weewx-user] Re: sdr.py Fine Offset WH32B sensor

2019-04-08 Thread steepleian
For completeness here is the actual output from the command line (after the 
addition of the new paser): -

out: ['{"time" : "2019-04-08 07:06:03", "model" : "Fineoffset-WH32B", "id" 
: 146, "temperature_C" : 16.900, "humidity" : 59, "pressure_hPa" : 
1001.300, "battery" : "OK", "mic" : "CHECKSUM"}\n']
parsed: {'humidity.146.FOWH32BPacket': 59.0, 'battery.146.FOWH32BPacket': 
0, 'dateTime': 1554707163, 'pressure.146.FOWH32BPacket': 1001.3, 
'temperature.146.FOWH32BPacket': 16.9, 'usUnits': 16}

On Monday, April 8, 2019 at 1:01:08 AM UTC+1, mwall wrote:
>
> On Sunday, April 7, 2019 at 6:44:00 PM UTC-4, steepleian wrote:
>>
>> However, thus far, I have not been able to map the packets correctly with 
>> the sdr.py driver. Has anybody else had a chance to look at this yet and 
>> come to any conclusions?
>>
>
> please post the rtl_433 JSON output so that i can add the WH32B parser.  
> just run sdr.py directly, something like this:
>
> cd /home/weewx
> PYTHONPATH=bin python bin/user/sdr.py --cmd="rtl_433 -M utc -F json -R 78"
>
> adjust the paths as needed, depending on where/how you installed weewx and 
> rtl_433
>
> i won't be able to test with my WH32B for a few weeks...
>
> m 
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[weewx-user] Re: sdr.py Fine Offset WH32B sensor

2019-04-07 Thread steepleian
I have created this parser similar to WH65B and it works fine: -


class FOWH32BPacket(Packet):
# time  : 2019-04-08 00:48:02
# model : Fineoffset-WH32B   
# ID: 146
# Temperature: 17.5 C  
# Humidity  : 60 %  
# Pressure  : 1001.2 hPa
# Battery   : OK
# Integrity : CHECKSUM


# This is for a WH32B which is the indoors sensor array for an Ambient 
Weather
# WS-2902A. The same sensor array is used for several models.

# {"time" : "2019-04-08 00:48:02", "model" : "Fineoffset-WH32B", "id" : 
146, "temperature_C" : 17.600, "humidity" : 93, "battery" : "OK", 
"Integrity : CHECKSUM"}
IDENTIFIER = "Fineoffset-WH32B"

@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['usUnits'] = weewx.METRIC
pkt['station_id'] = obj.get('id')
pkt['temperature'] = Packet.get_float(obj, 'temperature_C')
pkt['humidity'] = Packet.get_float(obj, 'humidity')
pkt['pressure'] = Packet.get_float(obj, 'pressure_hPa')
pkt['battery'] = 0 if obj.get('battery') == 'OK' else 1
return FOWH32BPacket.insert_ids(pkt)
  
  

@staticmethod
def insert_ids(pkt):
station_id = pkt.pop('station_id', '')
pkt = Packet.add_identifiers(pkt, station_id, 
FOWH32BPacket.__name__)
return pkt





On Monday, April 8, 2019 at 1:01:08 AM UTC+1, mwall wrote:
>
> On Sunday, April 7, 2019 at 6:44:00 PM UTC-4, steepleian wrote:
>>
>> However, thus far, I have not been able to map the packets correctly with 
>> the sdr.py driver. Has anybody else had a chance to look at this yet and 
>> come to any conclusions?
>>
>
> please post the rtl_433 JSON output so that i can add the WH32B parser.  
> just run sdr.py directly, something like this:
>
> cd /home/weewx
> PYTHONPATH=bin python bin/user/sdr.py --cmd="rtl_433 -M utc -F json -R 78"
>
> adjust the paths as needed, depending on where/how you installed weewx and 
> rtl_433
>
> i won't be able to test with my WH32B for a few weeks...
>
> m 
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [weewx-user] Re: sdr.py Fine Offset WH32B sensor

2019-04-07 Thread steeple ian
I have had a go at creating the parser as follows: -



class FOWH32BPacket(Packet):
# time  : 2019-04-08 00:48:02
# model : Fineoffset-WH32B   
# ID: 146
# Temperature: 17.5 C  
# Humidity  : 60 %  
# Pressure  : 1001.2 hPa
# Battery   : OK
# Integrity : CHECKSUM
_

# This is for a WH32B which is the indoors sensor array for an Ambient 
Weather
# WS-2902A. The same sensor array is used for several models.

# {time  : 2019-04-08 00:49:02
model : Fineoffset-WH32B   ID: 146
Temperature: 17.5 C  Humidity  : 60 %  Pressure  : 1001.2 hPa
Battery   : OKIntegrity : CHECKSUM}


IDENTIFIER = "Fineoffset-WH32B"

@staticmethod
def parse_json(obj):
pkt = dict()
pkt['dateTime'] = Packet.parse_time(obj.get('time'))
pkt['usUnits'] = weewx.METRIC
pkt['station_id'] = obj.get('id')
pkt['temperature'] = Packet.get_float(obj, 'temperature_C')
pkt['humidity'] = Packet.get_float(obj, 'humidity')
pkt['pressure'] = Packet.get_float(obj, 'pressure_hPa')
pkt['battery'] = 0 if obj.get('battery') == 'OK' else 1
return FOWH32BPacket.insert_ids(pkt)
  
  

@staticmethod
def insert_ids(pkt):
station_id = pkt.pop('station_id', '')
pkt = Packet.add_identifiers(pkt, station_id, FOWH32BPacket.__name__)
return pkt
  
   

> On 8 Apr 2019, at 01:01, mwall  wrote:
> 
> On Sunday, April 7, 2019 at 6:44:00 PM UTC-4, steepleian wrote:
> However, thus far, I have not been able to map the packets correctly with the 
> sdr.py driver. Has anybody else had a chance to look at this yet and come to 
> any conclusions?
> 
> please post the rtl_433 JSON output so that i can add the WH32B parser.  just 
> run sdr.py directly, something like this:
> 
> cd /home/weewx
> PYTHONPATH=bin python bin/user/sdr.py --cmd="rtl_433 -M utc -F json -R 78"
> 
> adjust the paths as needed, depending on where/how you installed weewx and 
> rtl_433
> 
> i won't be able to test with my WH32B for a few weeks...
> 
> m 
> 
> -- 
> 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 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[weewx-user] Re: sdr.py Fine Offset WH32B sensor

2019-04-07 Thread mwall
On Sunday, April 7, 2019 at 6:44:00 PM UTC-4, steepleian wrote:
>
> However, thus far, I have not been able to map the packets correctly with 
> the sdr.py driver. Has anybody else had a chance to look at this yet and 
> come to any conclusions?
>

please post the rtl_433 JSON output so that i can add the WH32B parser.  
just run sdr.py directly, something like this:

cd /home/weewx
PYTHONPATH=bin python bin/user/sdr.py --cmd="rtl_433 -M utc -F json -R 78"

adjust the paths as needed, depending on where/how you installed weewx and 
rtl_433

i won't be able to test with my WH32B for a few weeks...

m 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[weewx-user] Re: sdr.py

2016-10-30 Thread Brad Tucker
Fantastic. Thanks!
Brad

On Sunday, October 30, 2016 at 8:56:04 AM UTC-7, Brad Tucker wrote:
>
> Trying to install weewx. I have installed rtlsdr rtl433 along with weewx.
>
> I have tested rtf-433 by issuing rtl-433 -G and get lots of data passed 
> back.
>
> Once I try and use the actual sdr.py driver directly using the command:
> sudo PYTHONPATH=bin python bin/user/sdr.py
>
> I get this:
> Traceback (most recent call last):
>   File "bin/user/sdr.py", line 699, in 
> [--path=PATH] [--ld_library_path=LD_LIBRARY_PATH]""" % DEFAULT_CMD
> ValueError: unsupported format character 'p' (0x70) at index 1
>
> Not quite sure where to go from here. Seems maybe I need to call a path 
> out to the driver.
>
> I have tried things like this:
> export PATH=/usr/local/bin:${PATH}
>
> export LD_LIBRARY_PATH=/usr/local/lib
>
>
> from the shell and then issuing the command. Im a bit of a newbie here so any 
> help would be greatly appreciated.
>
>
> Thanks,
>
> Brad
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[weewx-user] Re: sdr.py

2016-10-30 Thread mwall
On Sunday, October 30, 2016 at 11:56:04 AM UTC-4, Brad Tucker wrote:
>
> Once I try and use the actual sdr.py driver directly using the command:
> sudo PYTHONPATH=bin python bin/user/sdr.py
>
> I get this:
> Traceback (most recent call last):
>   File "bin/user/sdr.py", line 699, in 
> [--path=PATH] [--ld_library_path=LD_LIBRARY_PATH]""" % DEFAULT_CMD
> ValueError: unsupported format character 'p' (0x70) at index 1
>
> Not quite sure where to go from here. Seems maybe I need to call a path 
> out to the driver.
>

sorry about that.  fixed at cc7984d.  please pull then try again.

 

> I have tried things like this:
> export PATH=/usr/local/bin:${PATH}
>
> export LD_LIBRARY_PATH=/usr/local/lib
>
>
> from the shell and then issuing the command. Im a bit of a newbie here so any 
> help would be greatly appreciated.
>
>
you can either configure the environment before running python/weewx:

export LD_LIBRARY_PATH=/usr/local/lib
export PATH=/usr/local/bin:${PATH}
PYTHONPATH=bin python bin/user/sdr.py

or you can specify PATH and LD_LIBRARY_PATH as options to the sdr driver 
and it will pre-load the environment with those variables before it invokes 
the rtl_433 command.  for example:

[SDR]
path = /usr/loca/bin
ld_library_path = /usr/local/lib
cmd = rtl_433 -G

m 

-- 
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.
For more options, visit https://groups.google.com/d/optout.