matthewwall / weewx-sdr

weewx driver for software-defined radio
GNU General Public License v3.0
114 stars 74 forks source link

Oregon-BHTR968 #118

Closed linux150 closed 3 years ago

linux150 commented 3 years ago

Hi Sorry my first post here on github. I modified my sdr.py to get all sensor data exept the BHTR968. Sorry difficult to explain, but i dont get the "Packet line" from this sensor. The data from the syslog Mar 5 17:24:54 weewx weewx[4380] DEBUG user.sdr: lines=['{"time" : "2021-03-05 16:24:50", "brand" : "OS", "model" : "Oregon-BHTR968", "id" : 23, "channel" : 0, "battery_ok" : 1, "temperature_C" : 23.100, "humidity" : 31, "pressure_hPa" : 915.000}\n', '{"time" : "2021-03-05 16:24:50", "brand" : "OS", "model" : "Oregon-BHTR968", "id" : 23, "channel" : 0, "battery_ok" : 1, "temperature_C" : 23.100, "humidity" : 31, "pressure_hPa" : 915.000}\n'] Mar 5 17:24:57 weewx weewx[4380] DEBUG user.sdr: lines=[] Mar 5 17:25:00 weewx weewx[4380] DEBUG user.sdr: lines=[] And the lines in the sdr.py `# apparently rtl_433 uses BHTR968 when it should be BTHR968 class OSBTHR968Packet(Packet):

Added 2017-04-22 ALG

# 2017-09-12 21:44:55     :       OS :    BHTR968
# House Code:      111
# Channel:         0
# Battery:         OK
# Celcius:         26.20 C
# Fahrenheit:      79.16 F
# Humidity:        36 %
# Pressure:        1012 mbar

IDENTIFIER = "BHTR968"
PARSEINFO = {
    'House Code': ['house_code', None, lambda x: int(x)],
    'Channel': ['channel', None, lambda x: int(x)],
    'Battery': ['battery', None, lambda x: 0 if x == 'OK' else 1],
    'Temperature': ['temperature', re.compile('([\d.-]+) C'), lambda x: float(x)],
    'Humidity': ['humidity', re.compile('([\d.]+) %'), lambda x: float(x)],
    'Pressure': ['pressure', re.compile('([\d.]+) mbar'), lambda x: float(x)]}

@staticmethod
def parse_text(ts, payload, lines):
    pkt = dict()
    pkt['dateTime'] = ts
    pkt['usUnits'] = weewx.METRIC
    pkt.update(Packet.parse_lines(lines, OSBTHR968Packet.PARSEINFO))
    return OS.insert_ids(pkt, OSBTHR968Packet.__name__)

# original rtl_433 output
# {"time" : "2017-01-18 14:56:03", "brand" : "OS", "model" :"BHTR968", "id" : 111, "channel" : 0, "battery" : "OK", "temperature_C" : 27.200, "temperature_F" : 80.960,  "humidity" : 46, "pressure" : 1013}
# by 06mar2019
# {"time" : "2019-03-06 13:27:23", "brand" : "OS", "model" : "BHTR968", "id" : 179, "channel" : 0, "battery" : "LOW", "temperature_C" : 19.800, "humidity" : 54, "pressure_hPa" : 974.000}

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

`

Any help ? lg linux150

andylittle commented 3 years ago

change the identifier

IDENTIFIER = "BHTR968" should be Oregon-BHTR968

fix battery_ok

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

There may be more, I just looked quick

Andy

On Fri, Mar 5, 2021 at 8:31 AM linux150 notifications@github.com wrote:

Hi Sorry my first post here on github. I modified my sdr.py to get all sensor data exept the BHTR968. Sorry difficult to explain, but i dont get the "Packet line" from this sensor. The data from the syslog Mar 5 17:24:54 weewx weewx[4380] DEBUG user.sdr: lines=['{"time" : "2021-03-05 16:24:50", "brand" : "OS", "model" : "Oregon-BHTR968", "id" : 23, "channel" : 0, "battery_ok" : 1, "temperature_C" : 23.100, "humidity" : 31, "pressure_hPa" : 915.000}\n', '{"time" : "2021-03-05 16:24:50", "brand" : "OS", "model" : "Oregon-BHTR968", "id" : 23, "channel" : 0, "battery_ok" : 1, "temperature_C" : 23.100, "humidity" : 31, "pressure_hPa" : 915.000}\n'] Mar 5 17:24:57 weewx weewx[4380] DEBUG user.sdr: lines=[] Mar 5 17:25:00 weewx weewx[4380] DEBUG user.sdr: lines=[] And the lines in the sdr.py `# apparently rtl_433 uses BHTR968 when it should be BTHR968 class OSBTHR968Packet(Packet):

Added 2017-04-22 ALG

2017-09-12 21:44:55 : OS : BHTR968

House Code: 111

Channel: 0

Battery: OK

Celcius: 26.20 C

Fahrenheit: 79.16 F

Humidity: 36 %

Pressure: 1012 mbar

IDENTIFIER = "BHTR968" PARSEINFO = { 'House Code': ['house_code', None, lambda x: int(x)], 'Channel': ['channel', None, lambda x: int(x)], 'Battery': ['battery', None, lambda x: 0 if x == 'OK' else 1], 'Temperature': ['temperature', re.compile('([\d.-]+) C'), lambda x: float(x)], 'Humidity': ['humidity', re.compile('([\d.]+) %'), lambda x: float(x)], 'Pressure': ['pressure', re.compile('([\d.]+) mbar'), lambda x: float(x)]}

@staticmethod def parse_text(ts, payload, lines): pkt = dict() pkt['dateTime'] = ts pkt['usUnits'] = weewx.METRIC pkt.update(Packet.parse_lines(lines, OSBTHR968Packet.PARSEINFO)) return OS.insert_ids(pkt, OSBTHR968Packet.name)

original rtl_433 output

{"time" : "2017-01-18 14:56:03", "brand" : "OS", "model" :"BHTR968", "id" : 111, "channel" : 0, "battery" : "OK", "temperature_C" : 27.200, "temperature_F" : 80.960, "humidity" : 46, "pressure" : 1013}

by 06mar2019

{"time" : "2019-03-06 13:27:23", "brand" : "OS", "model" : "BHTR968", "id" : 179, "channel" : 0, "battery" : "LOW", "temperature_C" : 19.800, "humidity" : 54, "pressure_hPa" : 974.000}

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

`

Any help ? lg linux150

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/matthewwall/weewx-sdr/issues/118, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC446XT43AHWZSIPQA56FGDTCEBPZANCNFSM4YVQKHQA .

linux150 commented 3 years ago

tnx, i did change but no solution. The weewx installation is running for testing and backup in the moment. But when i configured to start, the sensor already worked. I did check the logs and he stopped working on 15.2. ? Maybe after changing batterys ? Or any update on rtl. lg linux150

andylittle commented 3 years ago

id" : 23

id probably changes on power cycle, is id hard coded in your map?

On Fri, Mar 5, 2021 at 9:35 AM linux150 notifications@github.com wrote:

tnx, i did change but no solution. The weewx installation is running for testing and backup in the moment. But when i configured to start, the sensor already worked. I did check the logs and he stopped working on 15.2. ? Maybe after changing batterys ? Or any update on rtl. lg linux150

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/matthewwall/weewx-sdr/issues/118#issuecomment-791571835, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC446XUTNEP5KPGOZY376R3TCEI5VANCNFSM4YVQKHQA .

linux150 commented 3 years ago

I will check, but i dont remember any hardcoding. LG Edit: Sensor map

[[sensor_map]] pressure = pressure.0:48.OSBTHR968Packet inTemp = temperature.0:48.OSBTHR968Packet inBatteryStatus = battery.0:48.OSBTHR968Packet inHumidity = humidity.0:48.OSBTHR968Packet outTemp = temperature.1:253.OSTHGR122NPacket outHumidity = humidity.1:253.OSTHGR122NPacket outBatteryStatus = Humidity = humidity.1:253.OSTHGR122NPacket extraTemp1 = temperature.0:137.OSBTHR968Packet extraHumidity1 = humidity.0:137.OSBTHR968Packet rain_rate = rain_rate.0:171.OSRGR968Packet rain_total = total_rain.0:171.OSRGR968Packet UV = uv_index.1:21.OSUV800Packet windSpeed = wind_speed.0:83.OSWGR968Packet windGust = wind_gust.0:83.OSWGR968Packet windDir = wind_dir.0:83.OSWGR968Packet

RaSTuS26 commented 3 years ago

You can use a wildcard '*' in the 'id' field, so for example the following should work for any 'id'.

[[sensor_map]]
pressure = pressure.0:*.OSBTHR968Packet
.....
linux150 commented 3 years ago

Wow, great support. Tnx all working fine again ! Always difficult to start something new, config all until it runs and then after month of stable running, to starts from beginning. So thanks for your help, issue closed. linux150