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,
>
> from        IDENTIFIER = "WGR800"
> to          IDENTIFIER = "Oregon-WGR800"
>
>
> from        pkt['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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/47aabe74-f73f-4a08-b4f6-38c1e0eeb9cc%40googlegroups.com.

Reply via email to