openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.69k forks source link

Always `Unable to find table for query` when viewing chart #3810

Closed derabbink closed 8 years ago

derabbink commented 8 years ago

I am running a minimal install of OpenHAB 1.8.0. I have configured the Weather Binding to use Wunderground.com, but I also want OpenHAB to be able to render e.g. a chart for the temperature and humidity.

However, whenever I attempt to load such a chart (by opening my "Dublin Weather" frame), I will see an empty one, and in the logs the following appears:

2016-01-16 15:50:48.044 [DEBUG] [.p.m.i.MysqlPersistenceService] - mySQL query: item is Weather_Temperature 2016-01-16 15:50:48.045 [ERROR] [.p.m.i.MysqlPersistenceService] - mySQL: Unable to find table for query 'Weather_Temperature'. 2016-01-16 15:50:48.047 [DEBUG] [.p.m.i.MysqlPersistenceService] - mySQL query: item is Weather_Temperature 2016-01-16 15:50:48.047 [ERROR] [.p.m.i.MysqlPersistenceService] - mySQL: Unable to find table for query 'Weather_Temperature'. 2016-01-16 15:50:48.048 [DEBUG] [.p.m.i.MysqlPersistenceService] - mySQL query: item is Weather_Humidity 2016-01-16 15:50:48.049 [ERROR] [.p.m.i.MysqlPersistenceService] - mySQL: Unable to find table for query 'Weather_Humidity'. 2016-01-16 15:50:48.050 [DEBUG] [.p.m.i.MysqlPersistenceService] - mySQL query: item is Weather_Humidity 2016-01-16 15:50:48.050 [ERROR] [.p.m.i.MysqlPersistenceService] - mySQL: Unable to find table for query 'Weather_Humidity'.

The only explanation I have seen so far is that this can happen if no data has been persisted yet. However, I have kept my OpenHAB running for many hours now (and weather data is being fetched every 15 minutes).

How can I make this work?

Below, I have added my configurations:

I have a weather.items containing the following:

Group   gWeather        "Weather"           <sun_clouds>    (All)
Group   gWeather_Chart  "Weather Charts"    <chart>         (gWeather)
/* Same as Weather_Temperature, but different label and icon */
Number      Weather_Summary         "Dublin Weather [%.1f °C]"     <sun_clouds>    (gWeather)                  {weather="locationId=dublin, type=temperature, property=current"}
Number      Weather_Temperature     "Temperature [%.1f °C]"            <temperature>   (gWeather,gWeather_Chart)   {weather="locationId=dublin, type=temperature, property=current"}
Number      Weather_Temp_Feel       "Felt Temperature [%.1f °C]"   <temperature>   (gWeather)                  {weather="locationId=dublin, type=temperature, property=feel"}
String      Weather_Condition       "Condition [%s]"                <sun_clouds>    (gWeather)                  {weather="locationId=dublin, type=condition, property=text"}
Number      Weather_Humidity        "Outside Humidity [%d %%]"                      (gWeather,gWeather_Chart)   {weather="locationId=dublin, type=atmosphere, property=humidity"}
Number      Weather_Rain_Chance     "Chance of Rain [%d %%]"        <rain>          (gWeather)                  {weather="locationId=dublin, type=precipitation, property=probability"}
Number      Weather_Rain_Total      "Amount of Rain [%d mm]"        <rain>          (gWeather)                  {weather="locationId=dublin, type=precipitation, property=total"}
String      Weather_Wind_Dir        "Wind Direction [%s]"           <wind>          (gWeather)                  {weather="locationId=dublin, type=wind, property=direction"}
Number      Weather_Wind_Speed      "Wind Speed [%d km/h]"          <wind>          (gWeather)                  {weather="locationId=dublin, type=wind, property=speed"}
Number      Weather_Pressure        "Pressure [%.2f mb]"                            (gWeather)                  {weather="locationId=dublin, type=atmosphere, property=pressure"}
Number      Weather_Chart_Period    "Chart Period"
DateTime    Weather_LastUpdate      "Last Update [%1$ta %1$tR]"     <clock>

The group gWeather_Chart exists solely to be able to create persistence rules for the Weather_Temperature and Weather_Humidity items, which brings me to my weather-mysql.persist file:

Strategies {
    everyHour   : "0 0 * * * ?"
    default = everyChange
}
Items {
    gWeather_Chart* : strategy = everyChange, everyHour
}

And finally, this is my default.sitemap; It defines a "Weather" section, underneath which I declared a chart for the gWeather_Chart group:

sitemap home label="Home"
{
    Frame label="Weather" {
        Text item=Weather_Summary valuecolor=[Weather_LastUpdate=="Uninitialized"="lightgray",Weather_LastUpdate>90="lightgray",>25="orange",>15="green",>5="orange",<=5="blue"] {
            Frame {
                Text item=Weather_Condition
                Text item=Weather_LastUpdate visibility=[Weather_LastUpdate>30] valuecolor=[Weather_LastUpdate>120="orange", Weather_LastUpdate>300="red"]
            }
            Frame {
                Switch item=Weather_Chart_Period label="Chart Period" mappings=[0="Hour", 1="Day", 2="Week"]
                Chart item=gWeather_Chart period=h refresh=6000 visibility=[Weather_Chart_Period==0, Weather_Chart_Period=="Uninitialized"]
                Chart item=gWeather_Chart period=D refresh=30000 visibility=[Weather_Chart_Period==1]
                Chart item=gWeather_Chart period=W refresh=30000 visibility=[Weather_Chart_Period==2]
            }
        }
    }
}

I enabled logging for the mysql persistence and weather bindings:

<logger name="org.openhab.binding.weather" level="DEBUG" />
<logger name="org.openhab.persistence.mysql" level="DEBUG" />
watou commented 8 years ago

I am able to chart groups of persisted Number items in openHAB 1.8.0 as you are attempting. Could you try

http://host:port/chart?groups=gWeather_Chart&period=W&random=1&h=800&w=1200

Please continue this, including your openhab.cfg contents and results of examining your MySQL database directly, at https://community.openhab.org, and if there it's discovered to be a bug, please reopen this issue.

derabbink commented 8 years ago

OK. In case anyone wants to read the follow-up, this is where I posted: https://community.openhab.org/t/always-unable-to-find-table-for-query-when-viewing-chart/6329