[SOLVED] Problem: Chart generation failed: null

you mean that :
/var/lib/openhab2/persistence/rrd4j:

home_temp.rrd file:

Please ,how can you see the date (time)?
Curl

curl -X GET --header "Accept: application/json" "http://192.168.2.169:8080/rest/persistence/items/home_temp"

Request URL

http://192.168.2.169:8080/rest/persistence/items/home_temp

Response Body

{
  "name": "home_temp",
  "datapoints": "12",
  "data": [
    {
      "time": 1563112800000,
      "state": "25.4"
    },
    {
      "time": 1563113040000,
      "state": "25.4"
    },
    {
      "time": 1563113280000,
      "state": "25.4"
    },
    {
      "time": 1563113520000,
      "state": "25.4"
    },
    {
      "time": 1563113760000,
      "state": "25.4"
    },
    {
      "time": 1563114000000,
      "state": "25.4"
    },
    {
      "time": 1563114240000,
      "state": "25.4"
    },
    {
      "time": 1563114480000,
      "state": "25.4"
    },
    {
      "time": 1563114720000,
      "state": "25.4"
    },
    {
      "time": 1563114960000,
      "state": "25.124999999999996"
    },
    {
      "time": 1563115200000,
      "state": "24.3"
    },
    {
      "time": 1563115440000,
      "state": "24.3"
    }
  ]
}

Response Code

200

Response Headers

{
  "content-length": "517",
  "server": "Jetty(9.4.11.v20180605)",
  "content-type": "application/json"
}

Ups, I have to take that back a bit. The timestamps are 840 seconds, but that is the setting of the archive no. 3 (14 minutes).

Yes, remove this file and start again. The .rrd file can NOT be looked at usefully using an text editor!
Using the REST API you can look at the contents!

i try it :
Response Body

{
  "name": "home_temp",
  "datapoints": "1",
  "data": [
    {
      "time": 1563118320000,
      "state": "24.3"
    }
  ]
}

OK now you have started a new .rrd file (yes, it it was new one in your last post, I missed that, sorry)
It migth take a while until you see a line on the graph since it takes at least two values to make a line!
On your sitemap file, please increase the refresh value, it is supposed to be in milliseconds!
Iā€™m using it like:

Chart item=home_temp period=D legend=true refresh=300000

This bit by the way, is a Unix style ā€œepochā€ timestamp.
You can google ā€œepoch convertā€ for online converters and paste the long number in.

1 Like

I have 5 values but the same problem
Response Body

{
  "name": "home_temp",
  "datapoints": "5",
  "data": [
    {
      "time": 1563118320000,
      "state": "24.3"
    },
    {
      "time": 1563118560000,
      "state": "24.3"
    },
    {
      "time": 1563118800000,
      "state": "25.125"
    },
    {
      "time": 1563119040000,
      "state": "24.849999999999998"
    },
    {
      "time": 1563119280000,
      "state": "27.113333333333333"
    }
  ]
}

In this case it MIGHT be that you need to install the influxDB + grafana package ( there is an option to do that if you are on a openhabian installation). I have NO CLUE why such would help but I came across some users that solved the same problem like that.
As said, I do not know why it resolves the issue nor can I reproduce it.

Before you go installing other unwanted services, I do have the basic sitemap chart working with rrd4j. It is true that I have never meddled with persistence defaults like has obviously happened here, but try some things first.

You do seem to have default persistence set - but specify it anyway.
Try a daily chart.

Chart item=home_temp  period=D service="rrd4j" legend=true refresh=30
1 Like

thank you for your reply,
I tried with your proposal but the same problem

Do you still get WARN ā€œChart generation failed: nullā€?
What kind of installation do you use? Version of openHAB, JAVA and OS?

yes the same warn Chart generation failed: null
version openhab: 2.4.0-1
version OS : Windows 10
version java:

java version ā€œ1.8.0_201ā€

Thanks for posting those.
From here on Iā€™m fishing in the dark:
My setting for Charts on PaperUI is Height 240, Width 480. Not sure if those settings will change the issue, butā€¦

ā€¦and if the last did not help, would you try to raise the Debug-level IOT get more info what migth went wrong?

If yes, open the Karaf-console and raise the Level by:
log:set DEBUG org.eclipse.smarthome.ui.internal.chart

sorry for the delay because the installation takes time
thank you for your reply
It is working now.
after installation

sudo openhabian-config

Go to ā€œ20 Optional Componentsā€ > ā€œ24 InfluxDB+Grafanaā€ <>
After installation and reboot:

2 Likes

Weird isnā€™t it. Must reset some shared parameters somewhere.

thank you for your reply, yes itā€™s Weird

Yes, weird!
It is another example of this, IMHO the message comes from ChartServlet.java (in org.eclipse.smarthome.ui.internal.chart) in the method ā€œdoGetā€ the final tryā€¦:

 // Set the content type to that provided by the chart provider
    res.setContentType("image/" + provider.getChartType());
    logger.debug("chart building with width {} height {} dpi {}", width, height, dpi);
    try (ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(res.getOutputStream())) {
        BufferedImage chart = provider.createChart(serviceName, req.getParameter("theme"), timeBegin, timeEnd,
                height, width, req.getParameter("items"), req.getParameter("groups"), dpi, legend);
        ImageIO.write(chart, provider.getChartType().toString(), imageOutputStream);
        logger.debug("Chart successfully generated and written to the response.");
    } catch (ItemNotFoundException e) {
        logger.debug("{}", e.getMessage());
        res.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
    } catch (IllegalArgumentException e) {
        logger.warn("Illegal argument in chart: {}", e.getMessage());
        res.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument in chart: " + e.getMessage());
    } catch (IIOException e) {
        // this can happen if the request is terminated while the image is streamed, see
        // https://github.com/openhab/openhab-distro/issues/684
        logger.debug("Failed writing image to response stream", e);
    } catch (RuntimeException e) {
        if (logger.isDebugEnabled()) {
            // we also attach the stack trace
            logger.warn("Chart generation failed: {}", e.getMessage(), e);
        } else {
            logger.warn("Chart generation failed: {}", e.getMessage());
        }
        res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
    }

Why would a runtime exception the raised?