Issue displaying additional temperature

110 views
Skip to first unread message

jszit...@gmail.com

unread,
Sep 9, 2020, 3:52:57 PM9/9/20
to weewx-user

I have an extra temperature system logging to a different database.  I can pull the current temperature in my html.tmpl file with the code:
           <td class="stats_data">$latest($data_binding='well_binding').wellTemp</td>
and it shows just fine.  But when I try to pull my max/min values the page shows "N/A at N/A".  I placed it in an if statement which allows it to run, so I'm not sure why it won't show the appropriate information.  My code is:

              #if $day($data_binding='well_binding').wellTemp.has_data
              <tr>
                <td class="stats_label">
                  High Well Temperature<br/>
                  Low Well Temperature
                </td>
                <td class="stats_data">
                  $day($data_binding='well_binding').wellTemp.max at $day($data_binding='well_bindi$
                  $day($data_binding='well_binding').wellTemp.min at $day($data_binding='well_bindi$
                </td>
              </tr>
              #end if

Thanks for any direction.

-Jonathan

Tom Keffer

unread,
Sep 9, 2020, 5:27:32 PM9/9/20
to weewx-user
I'm assuming that the #if statement is evaluating True. That is, you're seeing the <tr>...</tr> HTML elements. 

Things to try:

1. Does the 'well_binding' database have a daily summary? That is normally what the $day tag uses.

2. Have you checked the values in the database? In particular, the values in the daily summary? Maybe they are all null?

3. Maybe it's just a typo, but the template snippet you included is garbled. The expression "$day($data_binding='well_bindi$" is not valid.

-tk

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/5a263ab5-96d2-4c00-9b25-27a30a9efd5bn%40googlegroups.com.

Jonathan Zitelman

unread,
Sep 9, 2020, 5:46:03 PM9/9/20
to weewx...@googlegroups.com
Thanks for the direction!  I checked the daily summary table and it exists but is empty, so that's likely the issue.  When I ran "sudo wee_database --rebuild-daily --binding=well_binding" I receive an error that the table archive does not exist, though I specify a different table name in weewx.conf.

pertinent section from weewx.conf:

    [[well_binding]]
        database = sensors
        table_name = sensor_gamma
        manager = weewx.wxmanager.WXDaySummaryManager
        schema = user.wellTemp.schema

Specific error from wee_database:

Using configuration file /etc/weewx/weewx.conf
Using database binding 'well_binding', which is bound to database 'sensors'
Traceback (most recent call last):
  File "/usr/share/weewx/wee_database", line 974, in <module>
    main()
  File "/usr/share/weewx/wee_database", line 169, in main
    rebuildDaily(config_dict, db_binding, options)
  File "/usr/share/weewx/wee_database", line 225, in rebuildDaily
    with weewx.manager.Manager.open(manager_dict['database_dict']) as dbmanager:
  File "/usr/share/weewx/weewx/manager.py", line 131, in open
    dbmanager = cls(connection, table_name)
  File "/usr/share/weewx/weewx/manager.py", line 83, in __init__
    self.sqlkeys = self.connection.columnsOf(self.table_name)
  File "/usr/share/weewx/weedb/mysql.py", line 61, in guarded_fn
    raise klass(e)
weedb.NoTableError: (1146, "Table 'sensors.archive' doesn't exist")


Apologies about the garbled code.  I copied and pasted from the shell and didn't catch that it cut the line off.  The correct code is:
              #if $day($data_binding='well_binding').wellTemp.has_data
              <tr>
                <td class="stats_label">
                  High Well Temperature<br/>
                  Low Well Temperature
                </td>
                <td class="stats_data">
                  $day($data_binding='well_binding').wellTemp.max at $day($data_binding='well_binding').wellTemp.maxtime<br/>
                  $day($data_binding='well_binding').wellTemp.min at $day($data_binding='well_binding').wellTemp.mintime
                </td>
              </tr>
              #end if

You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/vNlqslTsCs4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEBLiqRn%3DCW5Yg2jEsbdL5u9UgHc_m1gNw_-PTdwTM_trw%40mail.gmail.com.

Tom Keffer

unread,
Sep 9, 2020, 5:51:05 PM9/9/20
to weewx-user
Double check your schema, user.wellTemp.schema. Does it use the old-style V3.x schema spec, or the new-style V4.x schema spec? If you compare schemas/wview.py (old-style) and schemas/wview_extended.py (new-style) you can see the difference.

If you are using new-style schemas, then you must explicitly list what types should appear in the daily summaries.

-tk

Jonathan Zitelman

unread,
Sep 9, 2020, 6:09:56 PM9/9/20
to weewx...@googlegroups.com
The user schema is using the V3.x spec.  When I update it to follow the V4.x spec, specifying as table= instead of schema= and adding the daily summary section it creates a new error:
         AttributeError: Module 'user.wellTemp' has no attribute 'schema' when searching for 'user.wellTemp.schema'

As this table was empty, it looks like this issue existed when I was running 3.8 as I just upgraded this past weekend.  Otherwise maybe there is a setting in weewx.conf that maybe I didn't change when I upgraded?  Maybe this relates to the other issue I have posted about the error in the main packet loop?  I didn't see a need for wee_database --update as was listed for some of the older upgrades.

-JZ

Tom Keffer

unread,
Sep 9, 2020, 6:37:51 PM9/9/20
to weewx-user
Could you post:

1. The exact schema you are using. 
2. The [DataBindings] section of weewx.conf.
3. More context on what is causing this error. I can't tell what program was running, nor what it was doing when the error occurred. The log would be best. Don't skimp!

Jonathan Zitelman

unread,
Sep 9, 2020, 6:53:01 PM9/9/20
to weewx...@googlegroups.com
1.  I reverted user/wellTemp.py back to the V3 schema as follows:

"""The wview schema, which is also used by weewx."""

schema = [('dateTime',             'INTEGER NOT NULL UNIQUE PRIMARY KEY'),
          ('usUnits',              'INTEGER NOT NULL'),
          ('interval',             'INTEGER NOT NULL'),
          ('wellTemp',             'REAL'),
          ('wellFlow',             'REAL'),
          ('battery',              'INTEGER'),
          ('sigLevel',             'INTEGER'),
          ('transID',              'INTEGER')]


2. The associated sections from weewx.conf:

[DataBindings]

    [[wx_binding]]
         database = archive_mysql
        table_name = archive
        manager = weewx.manager.DaySummaryManager
        schema = schemas.wview_extended.schema


    [[well_binding]]
        database = sensors
        table_name = sensor_gamma
        manager = weewx.wxmanager.WXDaySummaryManager
        schema = user.wellTemp.schema

    [[HPt_binding]]
        database = sensors
        table_name = sensor_HPtank
        manager = weewx.wxmanager.WXDaySummaryManager
        schema = user.hpTank.schema

[Databases]

    [[archive_mysql]]
        database_name = weewx
        database_type = MySQL

    [[sensors]]
        database_type = MySQL2
        database_name = z_sensors_ranch


3a.  The full error text when trying to backfill the daily summaries:

$ /usr/share/weewx/wee_database --rebuild-daily --binding=well_binding

Using configuration file /etc/weewx/weewx.conf
Using database binding 'well_binding', which is bound to database 'sensors'
Traceback (most recent call last):
  File "/usr/share/weewx/wee_database", line 974, in <module>
    main()
  File "/usr/share/weewx/wee_database", line 169, in main
    rebuildDaily(config_dict, db_binding, options)
  File "/usr/share/weewx/wee_database", line 225, in rebuildDaily
    with weewx.manager.Manager.open(manager_dict['database_dict']) as dbmanager:
  File "/usr/share/weewx/weewx/manager.py", line 131, in open
    dbmanager = cls(connection, table_name)
  File "/usr/share/weewx/weewx/manager.py", line 83, in __init__
    self.sqlkeys = self.connection.columnsOf(self.table_name)
  File "/usr/share/weewx/weedb/mysql.py", line 61, in guarded_fn
    raise klass(e)
weedb.NoTableError: (1146, "Table 'z_sensors_ranch.archive' doesn't exist")

3b.  Having stopped weewx completely to run the above command, I only get one update to syslog, so not much to skimp on here:

Sep  9 17:48:58 derby wee_database[23747] ERROR weewx.manager: Cannot get columns of table archive, and no schema specified

This may be the error I posted a separate issue about in the forum as I typically have weewx running and have a cron job to update the external sensor databases, so the syslog may have been muddying up the information by combining everything.

-JZ

Jonathan Zitelman

unread,
Sep 9, 2020, 7:58:25 PM9/9/20
to weewx...@googlegroups.com
I apologize as I didn't include the V4 schema I tried along with it's error message.  The syslog notation was the same: ERROR weewx.manager: Cannot get columns of table archive, and no schema specified

V4 schema:

"""The extended wview schema."""

table= [('dateTime',             'INTEGER NOT NULL UNIQUE PRIMARY KEY'),

          ('usUnits',              'INTEGER NOT NULL'),
          ('interval',             'INTEGER NOT NULL'),
          ('wellTemp',             'REAL'),
          ('wellFlow',             'REAL'),
          ('battery',              'INTEGER'),
          ('sigLevel',             'INTEGER'),
          ('transID',              'INTEGER')]


day_summaries = [(e[0], 'scalar') for e in table
                 if e[0] not in ('dateTime', 'usUnits', 'interval')]

schema = {
    'table': table,
    'day_summaries' : day_summaries
}


Error produced from: sudo /usr/share/weewx/wee_database --rebuild-daily --binding=well_binding  (looks to be the same)

Using configuration file /etc/weewx/weewx.conf
Using database binding 'well_binding', which is bound to database 'sensors'
Traceback (most recent call last):
  File "/usr/share/weewx/wee_database", line 974, in <module>
    main()
  File "/usr/share/weewx/wee_database", line 169, in main
    rebuildDaily(config_dict, db_binding, options)
  File "/usr/share/weewx/wee_database", line 225, in rebuildDaily
    with weewx.manager.Manager.open(manager_dict['database_dict']) as dbmanager:
  File "/usr/share/weewx/weewx/manager.py", line 131, in open
    dbmanager = cls(connection, table_name)
  File "/usr/share/weewx/weewx/manager.py", line 83, in __init__
    self.sqlkeys = self.connection.columnsOf(self.table_name)
  File "/usr/share/weewx/weedb/mysql.py", line 61, in guarded_fn
    raise klass(e)
weedb.NoTableError: (1146, "Table 'z_sensors_ranch.archive' doesn't exist")


-JZ

Tom Keffer

unread,
Sep 10, 2020, 8:00:42 AM9/10/20
to weewx-user
1. Looking through your [[sensors]] section we see

 [[sensors]]
        database_type = MySQL2
        database_name = z_sensors_ranch

I don't know what a database type of MySQL2 is. Your choices are normally SQLite or MySQL. What is MySQL2?

2. This matters because well_binding is bound to the database 'sensors'. In turn, 'sensors' specifies that it will contain a database named 'z_sensors_ranch', which, apparently, is missing. Double check that.

-tk

Jonathan Zitelman

unread,
Sep 10, 2020, 8:40:27 AM9/10/20
to weewx...@googlegroups.com
MYSQL2 is a second MYSQL connection to an off-site server:
    [[MySQL2]]
        driver = weedb.mysql
        host = (secret host)
        user = weewx
        password = (secret password)

The database is there, and weewx pulls the information correctly earlier in my HTML with a call to the main table "sensor_gamma" (i.e.: <td class="stats_data">$latest($data_binding='well_binding').wellTemp</td>).  The database also contains the table "sensor_gamma_day_wellTemp" but wee_database doesn't seem to be able to populate it, even though it originally created it.  The only day summary table with information is metadata specifying Version 1.0.  If I drop any of the daily summary tables, weewx doesn't seem to recreate them, I assume because of the ongoing error.

What's really odd if I have this exact same setup at a different location (though it uses pondTemp).

-JZ

Jonathan Zitelman

unread,
Sep 10, 2020, 8:54:02 AM9/10/20
to weewx...@googlegroups.com
Tom,

I just created an empty table called 'archive' with columns: datetime, interval, sigLevel, usUnits.  This seems to have fixed the issue.  I was able to run the rebuild and it created the daily summaries but left the archive table empty.  Interestingly, I have another sensor on a cistern, "HPtank" which was just recently added and was Version 2.0 (According to the metadata), this table updated without any issues before adding the 'archive' table.  Not sure if it is just a small glitch or some left over code, but all seems to be working now.

Thank you for all your help!  I'm sure when you first developed WeeWX over 10 years ago, you hadn't planned on a lifetime of support.  Thank you again for all your work (along with the others that have joined in the past several years) on developing such a great application!

-Jonathan
Reply all
Reply to author
Forward
0 new messages