uajqq/weewx-davishealthapi

No Values shown

Closed this issue · 19 comments

Hi,

I have followed the Installation Manual.

I installed the latest version from Github, I was creating the API Key and Secret and via the python tool I chekced the Station ID.
I added this three values to the weewx.conf

Because I am using Belchertown-Skin I added the follwoing to the "HomePage" Section of the Belchertown graphs.conf:

[[voltChart]]
        title = Voltages
        type = spline
        data_binding = davishealthapi_binding
        [[[supercapVolt]]]
        [[[solarVolt]]]
        [[[txBattery]]] 

I can see the graph on the WebPage but no values.

How can I check that the collection of values is working?

Br,
Johannes

Hi, I was checking with the DB and it seems the problem is not the Visualization, but the retreival and storage of the values.

I checked the sqlitedb. The tables were created but there are no values inside.

ERROR user.davishealthapi: DavisHealthAPI is missing a required parameter. Double-check your configuration file. key: Nonesecret: None station ID: 97634

But when running the python script I am getting

{"stations":[{"station_id":97634,...

I think I found the first issue:

In the Software you are using "api_key" and "api_secret" but in the weewx.config you are using "api-key" and "api-secret".

Chaning from "-" to "_" fixed this issue

But now I am getting the follwoing error:

ERROR user.davishealthapi: No valid historical API data recieved. Double-check API key/secret and station id. Error is: 'sensors'

I can see now in the Database entries for "archive" but still no entries for all other tables

uajqq commented

Hmm, can you post an example of what the API returns when you run the Python script to get the station ID?

Hi @uajqq ,

{
	"stations": [
		{
			"station_id": XYZ,
			"station_name": "XYZ",
			"gateway_id": XYZ,
			"gateway_id_hex": "XYZ",
			"product_number": "6100USB",
			"username": "ebnerjoh",
			"user_email": "XYZ@fABC.at",
			"company_name": "",
			"active": true,
			"private": false,
			"recording_interval": 15,
			"firmware_version": null,
			"registered_date": 1600345563,
			"time_zone": "Europe/Vienna",
			"city": "XYZ",
			"region": "XYZ",
			"country": "XYZ",
			"latitude": XYZ,
			"longitude": XYZ,
			"elevation": 2772.5813
		}
	],
	"generated_at": 1602589490
}
uajqq commented

Can you insert the following line into bin/user/davishealthapi.py just after line 356;

logerr("JSON data is : %s" % data)

then start/stop weewx and post the output after "JSON data is:"? That will print out what the API is returning so we can see what's going wrong.

Got now a critical error:

Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__: Caught unrecoverable exception:
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****  local variable 'data' referenced before assignment
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****  Traceback (most recent call last):
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 195, in run
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      self.dispatchEvent(weewx.Event(weewx.CHECK_LOOP, packet=packet))
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 224, in dispatchEvent
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      callback(event)
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 578, in check_loop
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      raise BreakLoop
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****  weewx.engine.BreakLoop
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****  During handling of the above exception, another exception occurred:
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****  Traceback (most recent call last):
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 594, in post_loop
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      self._catchup(self.engine.console.genArchiveRecords)
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 638, in _catchup
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      for record in generator(lastgood_ts):
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/drivers/__init__.py", line 30, in genArchiveRecords
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      raise NotImplementedError("Method 'genArchiveRecords' not implemented")
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****  NotImplementedError: Method 'genArchiveRecords' not implemented
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****  During handling of the above exception, another exception occurred:
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****  Traceback (most recent call last):
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewxd", line 154, in main
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      engine.run()
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 202, in run
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      self.dispatchEvent(weewx.Event(weewx.POST_LOOP))
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 224, in dispatchEvent
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      callback(event)
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 596, in post_loop
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      self._software_catchup()
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 658, in _software_catchup
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      origin='software'))
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 224, in dispatchEvent
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      callback(event)
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/user/davishealthapi.py", line 388, in new_archive_record
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      self.save_data(self.get_packet(now, self.last_ts))
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/user/davishealthapi.py", line 410, in get_packet
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      self.api_key, self.api_secret, self.station_id, self.polling_interval
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****    File "/usr/share/weewx/user/davishealthapi.py", line 357, in get_data
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****      logerr("JSON data is : %s" % data)
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****  UnboundLocalError: local variable 'data' referenced before assignment
Oct 13 19:30:19 Weewx weewx[29853] CRITICAL __main__:     ****  Exiting.

Ok, moved te command some lines below. now it looks like:

Oct 13 19:35:19 Weewx weewx[30162] ERROR user.davishealthapi: JSON data is : {'sensors': [{'lsid': 347236, 'data': [{'temp_in_lo_at': 1602609580, 'arch_int': 900, 'temp_in_hi': 74.5, 'temp_in_hi_at': 1602609640, 'hum_in_hi': 47.4, 'temp_in_last': 74.3, 'temp_in_lo': 74.1, 'hum_in_lo': 46.7, 'hum_in_last': 47.4, 'dew_point_in': 53, 'hum_in_lo_at': 1602609309, 'heat_index_in': 74, 'hum_in_hi_at': 1602610120, 'ts': 1602610200}], 'sensor_type': 243, 'data_structure_type': 13}, {'lsid': 347235, 'data': [{'bar_absolute': 26.853, 'bar_hi_at': 1602610070, 'bar_sea_level': 29.716, 'arch_int': 900, 'bar_lo': 29.711, 'bar_hi': 29.717, 'bar_lo_at': 1602609308, 'ts': 1602610200}], 'sensor_type': 242, 'data_structure_type': 13}, {'lsid': 347234, 'data': [{'battery_voltage': 6105, 'wifi_rssi': -79, 'network_error': None, 'ip_v4_gateway': '192.168.1.1', 'bluetooth_version': None, 'bgn': None, 'firmware_version': 1596147041, 'local_api_queries': 14428, 'rx_bytes': 2563558, 'health_version': 1, 'radio_version': 621020416, 'ip_address_type': 1, 'link_uptime': 464737, 'input_voltage': 4705, 'tx_bytes': 89887054, 'ip_v4_netmask': None, 'rapid_records_sent': 172347, 'uptime': 464748, 'touchpad_wakeups': 48, 'ip_v4_address': '192.168.1.223', 'bootloader_version': 1550707628, 'espressif_version': 1534381024, 'dns_type_used': None, 'network_type': 1, 'ts': 1602610200}], 'sensor_type': 504, 'data_structure_type': 15}, {'lsid': 347247, 'data': [{'wind_speed_avg': 0, 'dew_point_hi_at': 1602609341, 'supercap_volt_last': None, 'uv_dose': 0, 'wind_chill_last': 38, 'solar_rad_hi': 0, 'solar_volt_last': None, 'dew_point_lo_at': 1602609320, 'thsw_index_hi_at': 1602609341, 'dew_point_last': 30.6, 'rain_size': 2, 'thsw_index_lo': 35.4, 'uv_index_hi': 0, 'thsw_index_hi': 35.9, 'thsw_index_lo_at': 1602609853, 'solar_rad_hi_at': 1602609307, 'heat_index_hi': 37.9, 'arch_int': 900, 'good_packets_streak': 1279, 'wind_run': 0, 'rain_rate_hi_at': 1602609305, 'tx_id': 1, 'temp_hi': 38.6, 'temp_lo': 38, 'wind_dir_of_prevail': 0, 'thw_index_last': 37.5, 'rain_rate_hi_clicks': 0, 'et': None, 'rainfall_in': 0, 'wind_chill_lo_at': 1602610069, 'rainfall_mm': 0, 'wet_bulb_last': 34.3, 'trans_battery': None, 'rain_rate_hi_in': 0, 'hum_lo': 73.1, 'heat_index_last': 37.5, 'hum_hi': 74.5, 'heat_index_hi_at': 1602609341, 'rain_rate_hi_mm': 0, 'rainfall_clicks': 0, 'wet_bulb_hi_at': 1602609341, 'solar_rad_volt_last': 0, 'wind_speed_hi': 0, 'temp_last': 38, 'temp_avg': 38.2, 'trans_battery_flag': 0, 'hum_last': 74.5, 'wind_chill_lo': 38, 'wet_bulb_hi': 34.7, 'wind_speed_hi_at': 1602609302, 'reception': 99, 'wet_bulb_lo_at': 1602609851, 'solar_rad_avg': 0, 'error_packets': 0, 'afc': -2, 'cooling_degree_days': 0, 'rssi': -82, 'wet_bulb_lo': 34.2, 'wind_speed_hi_dir': 0, 'temp_lo_at': 1602610069, 'dew_point_hi': 30.8, 'thw_index_lo': 37.4, 'uv_index_hi_at': 1602609318, 'dew_point_lo': 30.3, 'solar_energy': 0, 'resynchs': 0, 'temp_hi_at': 1602609341, 'thw_index_hi': 37.9, 'hum_lo_at': 1602609697, 'thw_index_lo_at': 1602609853, 'thw_index_hi_at': 1602609341, 'thsw_index_last': 35.5, 'hum_hi_at': 1602610158, 'uv_index_avg': 0, 'uv_volt_last': 0, 'heating_degree_days': 0.28125, 'ts': 1602610200}], 'sensor_type': 50, 'data_structure_type': 11}], 'generated_at': 1602610519, 'station_id': XYZ}

uajqq commented

That's odd. It looks like the API is reporting data correctly, but it's saying it can't find an entry for "sensors" in the data. However, we can clearly see it's there.

Try this: download the latest version from this repo, then change the word error to data on line 243 and post the error text it returns.

Hi,

I have update the installation and edited the file
/usr/share/weewx/user/davishealthapi.py

accordingly, but I am not seeing any entries in the logs.

I only can see the follwing:

Oct 14 20:30:18 Weewx weewx[9682] ERROR user.davishealthapi: No valid historical data structure types found in API data. Error is: list index out of range
Oct 14 20:30:19 Weewx weewx[9682] INFO weewx.manager: Added record 2020-10-14 20:30:17 CEST (1602700217) to database 'davishealthapi.sdb'
Oct 14 20:30:19 Weewx weewx[9682] INFO weewx.manager: Added record 2020-10-14 20:30:17 CEST (1602700217) to daily summary in 'davishealthapi.sdb'

Br,
Johannes

uajqq commented

In that case, download the latest files again to revert the changes, and see what error gets thrown at baseline. Sounds like something may have changed--now it's saying the data is there, but missing the parts with the actual sensor reports.

@uajqq, what do you mean with "at baseline"?

I reverted back, but no difference in the log file.

uajqq commented

I mean which error does it throw when you revert the file to the one downloaded from the repository: "index out of range," or "sensor"?

ERROR user.davishealthapi: No valid historical API data recieved. Double-check API key/secret and station id. Error is: 'sensors'

uajqq commented

I just pushed a commit with improved debugging output. Can you download the latest and post any log messages that include "davishealthapi"? You can quickly do that by running cat [location of the log on your system] | grep davishealthapi.

Oct 16 06:10:18 Weewx weewx[16959] ERROR user.davishealthapi: No valid historical  API data recieved. Double-check API key/secret and station id. Error is: 'sensors'
Oct 16 06:10:18 Weewx weewx[16959] ERROR user.davishealthapi: The API data returned was: {'code': '403', 'message': 'Access is not authorized for station 97634'}
uajqq commented

Ahhh, okay, that’s the issue then. The Davis health data is included as part of the “historical” API, which is only available on the paid Pro tier from Davis. See this post: https://gitter.im/WeatherLink/v2-api?at=5f2a0478c6dbab65123f59f4 and also see here: https://weatherlink.github.io/v2-api/data-permissions. The Pro tier costs $3.95 USD/month. I’ll update the documentation on the page to make that more clear so no one else has this issue.

uajqq commented

I'm going to close this issue @ebnerjoh, but please let me know if upgrading your subscription status didn't fix the problem.