themoosman / weewx-ambientweatherapi-json

An AmbientWeather API driver for the weewx weather software using JSON.
14 stars 0 forks source link

Meteobridge flips battery status with ambientweather #18

Closed staze closed 3 years ago

staze commented 3 years ago

As requested. =)

https://github.com/ambient-weather/api-docs/wiki/Device-Data-Specs

battout - OK/Low indication, Int, 1=OK, 0=Low (Meteobridge Users 1=Low, 0=OK) batt1...batt10 - OK/Low indication, Int, 1=OK, 0=Low (Meteobridge Users 1=Low, 0=OK) batt_25 - PM2.5 Air Quality Sensor Battery indication, OK/Low indication, Int, 1=OK, 0=Low (Meteobridge Users 1=Low, 0=OK)

From an api test call, I can confirm:

  "battin": 0,
  "battout": 0,

Adding a setting to flip this logic would be great.

Thanks!

themoosman commented 3 years ago

@staze I tested as much as I could without a Meteobridge, can you check out the branch and confirm for me?

https://github.com/themoosman/weewx-ambientweatherapi-json/tree/issue-18

staze commented 3 years ago

Testing now. Interestingly, I had grabbed the last main branch last week and noticed that it was showing different results after that update. Outside showed "Okay" and Inside showed "Low".

Waiting for a web refresh to see what this shows now...

Okay, now, ironically, it shows the opposite. Outside shows Low, Inside shows "OK"

Maybe I misunderstood the setting in weewx.conf. I did set it to "use_meteobridge = TRUE" Maybe True needs to be in quotes?

themoosman commented 3 years ago

True does not need to be in quotes. It will print the setting in the log, look for an entry like use_meteobridge: True

themoosman commented 3 years ago

You can also set debug = 1 in weewx.conf to get more information.

themoosman commented 3 years ago

You also might have to post an API response JSON. AW does not report an "inside" battery status, as it nests them in bat1, bat2, etc.

staze commented 3 years ago

Debug shows:

971:Mar  8 13:48:37 raspi-server-misc weewx[23838] INFO __main__: Terminating weewx version 4.4.0
973:Mar  8 13:48:38 raspi-server-misc weewx[29972] INFO __main__: Initializing weewx version 4.4.0
974:Mar  8 13:48:38 raspi-server-misc weewx[29972] INFO __main__: Using Python 3.7.3 (default, Jul 25 2020, 13:03:44) #012[GCC 8.3.0]
975:Mar  8 13:48:38 raspi-server-misc weewx[29972] INFO __main__: Platform Linux-5.10.11-v7l+-armv7l-with-debian-10.8
976:Mar  8 13:48:38 raspi-server-misc weewx[29972] INFO __main__: Locale is 'en_US.UTF-8'
977:Mar  8 13:48:38 raspi-server-misc weewx[29972] INFO __main__: PID file is /var/run/weewx.pid
978:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO __main__: Using configuration file /etc/weewx/weewx.conf
979:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO __main__: Debug is 1
980:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.engine: Loading station type ambientweatherapi (user.ambientweatherapi)
981:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO root: use_meteobridge: True
982:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO root: Starting: ambientweatherapi, version: 0.3
984:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.engine: StdConvert target unit is 0x1
986:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.engine: Archive will use data binding wx_binding
987:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.engine: Record generation will be attempted in 'hardware'
988:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.engine: Using archive interval of 300 seconds (specified in weewx configuration)
989:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.restx: StationRegistry: Registration not requested.
990:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.restx: Wunderground: Posting not enabled.
991:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.restx: PWSweather: Posting not enabled.
992:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.restx: CWOP: Posting not enabled.
993:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.restx: WOW: Posting not enabled.
994:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.restx: AWEKAS: Posting not enabled.
995:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO __main__: Starting up weewx version 4.4.0
996:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.engine: Using binding 'wx_binding' to database 'weewx.sdb'
997:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.manager: Starting backfill of daily summaries
998:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.manager: Daily summaries up to date
999:Mar  8 13:48:38 raspi-server-misc weewx[29976] INFO weewx.engine: Starting main packet loop.
1173:Mar  8 13:49:39 raspi-server-misc weewx[29976] INFO weewx.wxxtypes: Type beaufort has been deprecated. Use unit beaufort instead.
1174:Mar  8 13:49:39 raspi-server-misc weewx[29976] INFO root: loopPacket Accepted
1373:Mar  8 13:50:42 raspi-server-misc weewx[29976] INFO root: loopPacket Accepted

API data:

[
  {
    "macAddress": "xxxxxxxx",
    "lastData": {
      "dateutc": 1615240500000,
      "winddir": 180,
      "windspeedmph": 0,
      "windgustmph": 0.9,
      "maxdailygust": 20,
      "windgustdir": 220,
      "winddir_avg2m": 180,
      "windspdmph_avg2m": 0,
      "winddir_avg10m": 65,
      "windspdmph_avg10m": 0,
      "tempf": 49.3,
      "humidity": 61,
      "baromrelin": 29.93,
      "baromabsin": 29.42,
      "tempinf": 73.6,
      "humidityin": 34,
      "hourlyrainin": 0,
      "dailyrainin": 0,
      "monthlyrainin": 0.7,
      "yearlyrainin": 12.04,
      "battin": 0,
      "battout": 1,
      "feelsLike": 49.3,
      "dewPoint": 36.43,
      "feelsLikein": 72.3,
      "dewPointin": 43.5,
      "lastRain": "2021-03-07T12:55:00.000Z",
      "tz": "America/Los_Angeles",
      "date": "2021-03-08T21:55:00.000Z"
    },
    "info": {
      "name": "Home",
      "location": "Home",
      "coords": {
        "coords": {
          "lat": 44.xxxxx,
          "lon": -123.xxxxx
        },
        "address": "xxxxx",
        "location": "Springfield",
        "elevation": 136.5034027099609,
        "geo": {
          "type": "Point",
          "coordinates": [
            -123.xxxx,
            44.xxxxx
          ]
        }
      }
    }
  }
]
themoosman commented 3 years ago
 "battin": 0,
 "battout": 1,

I wonder if battin follows the default or meteobridge method for reporting? AW does not document that setting.

staze commented 3 years ago

not sure. as mentioned earlier, prior to this branch, battin was showing as "okay" I believe.

I imagine since they mention meteobridge flips the bit on all the others, it would on this one as well.

themoosman commented 3 years ago

I opened an issue https://github.com/ambient-weather/api-docs/issues/29

themoosman commented 3 years ago

not sure. as mentioned earlier, prior to this branch, battin was showing as "okay" I believe.

I imagine since they mention meteobridge flips the bit on all the others, it would on this one as well.

Yeah, so the flip logic in this code is working :)

staze commented 3 years ago

Though, that's odd. Cause as far as I know, the batteries on both are fine...

Let me take a closer look at my setup and see if the battery is in fact low.

staze commented 3 years ago

Yup, my meteobridge is reporting a low battery. Guess I know what I'm doing this evening. lol

staze commented 3 years ago

ha. it just went low today. figures...

themoosman commented 3 years ago

Of course, it did. :laughing:

staze commented 3 years ago

Battery Status

I'm not kidding! what are the odds. lol

themoosman commented 3 years ago

Let me know if that other battery reports good and I'll merge the code.

staze commented 3 years ago

I believe you should be good to go. The console battery should always be good since it's plugged into power.

So yup, go ahead and merge. I'll go get the station battery replaced tonight and report back if that resolves the low one.

themoosman commented 3 years ago

@staze Did the new battery resolve the alert?

staze commented 3 years ago

@themoosman sadly haven't had a chance. and right now it's raining... so... maybe have to wait a day or two. We'll see when things clear up. looks like tomorrow is supposed to be dry. Will let you know!

staze commented 3 years ago

Replaced battery yesterday, console is still showing low battery. Normally it should reset at midnight and show it's fine, but it didn't. So either the battery I installed was already low (unlikely) or I'm seeing the occasion where it takes a couple days.

https://support.davisinstruments.com/article/bv6nzyga1g-i-m-getting-a-low-battery-transmitter-1-error-on-my-console

Will post back once I have an answer.

staze commented 3 years ago

Another night and it reset. weewx now looks good. Think we're good to merge this in and close out the issue.

Thanks!