[RELEASE] Watchtower long-term metrics app

Thank you for confirming this!
I appreciate all your help!

WORKS LIKE A DREAM!!!!
Thanks for your help!

Yet another feature creep request....
I am typically looking at hours long trens and when things are going well, I want to double the time span. The same thing with days.
Could we have an alternate set of time spans,
1, 2, 4, 8, 16 hours and 1, 2, 4, 8 ,16 days. This would make the change in time span consistently doubling. Easier for my mind to grasp.

Are you talking about the dropdown in the top bar of the dashboard? If so, I just grabbed those values straight from Grafana without thinking too much about it :slight_smile:. Figured they've been doing it that way for ages, so they probably know what they're doing!

Yes, that drop down menu.

Is there any virtual device attribute that WT reports as just a binary value (0,1, or opened/closed, etc.)?

I'm presently tracking the presence or absence of a vehicle in my garage (using a DIY Zigbee LIDAR device). Currently, WT reports those values on a 0-100% scale. I'd like to either report on a 0-1 scale or (preferably) a text-based scale like "Here"/"Away".

Is any of that possible?

Watchtower stores sensor data as time-series entries in the format X = Y, where:

  • X is the timestamp, always spaced at 5-minute intervals* (e.g. 10:25:00, 10:30:00, 10:35:00, ...). This is a core design decision made to limit the strain on the hub’s limited processing and storage resources.
  • Y is the computed value for that 5-minute window, based on the type of sensor

There are three main types of sensor values:

  1. Binary/2-state sensors (e.g. on/off, opened/closed, wet/dry): These are not stored as raw binary (0/1), but as a percentage of time the sensor was in the "active" state during the 5-minute interval.

    Example: If your garage sensor reports "Here" from 10:30:00 to 10:31:00, and "Away" for the rest of the interval, the value at 10:35:00 will be Y = 20% (1 minute out of 5).

    In order to preserve true 0/1 values, Watchtower would need to store data with higher granularity (e.g. every minute), which it cannot.

  2. Oscillating sensors (e.g. temperature, humidity): These are averaged over the 5-minute window.

  3. Ever-increasing sensors (e.g. energy usage in kWh): These are stored as the delta (change) since the previous interval.

* For long-term analysis, Watchtower also calculates secondary series at 1h, 1d, and 1w intervals, all derived from the 5-minute base data.


TLDR: WT does not support true binary (0/1) or text-based ("Here"/"Away") values directly, due to how the database is structured. The closest workaround is using the Status Map chart type, where green indicates "on"/"present", and absence of green implies "off"/"away".

image

Note: There are different shades of green representing values from 0% to 100%, but visually it still reads as more of an on/off indicator.

Hope this helps!

Understood!

However, without changing the way you store data, is there some way to apply a rounding function to the 5 minute interval data when graphing the data, so that, for example, a percentage from zero up to 50% is displayed as “zero“, and any value from 50% to 100% is displayed as a “one“?

Everything is possible with the User Script feature :rofl:

  1. Create a Single Device chart
  2. Select just the attribute you want to chart (with values between 0 and 100)
  3. Add the following User Script:
    $config.data.datasets[0].data.forEach(point => point.y = point.y < 50 ? 0 : 1);
    $config.data.datasets[0].stepped = 'after';
    $config.options.scales.attr1.ticks.callback = y => y >= 1 ? 'Here' : 'Away';
    $config.options.scales.attr1.title.text = 'Vehicle';
    $config.options.plugins.tooltip.callbacks.label = context => `Vehicle: ${context.raw.y >= 1 ? 'Here' : 'Away'}`;
    
    ^ The first line is "rounding" the chart data. Rest of the lines are cosmetic: use right angles for the chart line, change scale values (Here, Away) and name (Vehicle), change tooltip text.
  4. Profit!

Example using the Hub CPU attribute (values here are not between 0-100, therefore the first line is slightly modified):

This ALMOST worked for me!

With this code:

$config.options.scales.attr1.title.text = '% Present';
$config.options.scales.attr1.title.color = '#0000FF';

$config.data.datasets[0].data.forEach(point => point.y = point.y < 50 ? 0 : 1);
$config.data.datasets[0].stepped = 'after';
$config.options.scales.attr1.ticks.callback = y => y >= 1 ? 'Here' : 'Away';
$config.options.scales.attr1.title.text = 'Rachel\'s Vehicle';
$config.options.plugins.tooltip.callbacks.label = context => `Vehicle: ${context.raw.y >= 1 ? 'Here' : 'Away'}`;

I get this graph when Auto Scale is on (after deleting ALL historical data):

image

With Fixed Scale, I get this graph:

image

Is there a way to suppress the extraneous "Here" instances?

I tried ChatGPT, and it suggested this fix -- which worked!

$config.options.scales.attr1.title.text = '% Present';
$config.options.scales.attr1.title.color = '#0000FF';

// Convert values into 0 or 1
$config.data.datasets[0].data.forEach(point => point.y = point.y < 50 ? 0 : 1);

// Step style line
$config.data.datasets[0].stepped = 'after';

// Force axis range to 0–1
$config.options.scales.attr1.min = 0;
$config.options.scales.attr1.max = 1;
$config.options.scales.attr1.ticks.stepSize = 1;

// Show clean labels
$config.options.scales.attr1.ticks.callback = value => {
  if (value === 0) return 'Away';
  if (value === 1) return 'Here';
  return '';
};

// Change axis title
$config.options.scales.attr1.title.text = 'Vehicle';

// Tooltip text
$config.options.plugins.tooltip.callbacks.label = context =>
  `Vehicle: ${context.raw.y >= 1 ? 'Here' : 'Away'}`;

Here's ChatGPT's explanation:

"Yes — the issue is with this line:

$config.options.scales.attr1.ticks.callback = y => y >= 1 ? 'Here' : 'Away';

In Chart.js (which Watchtower uses under the hood), the ticks.callback receives the tick value, not the data point itself. Since your dataset has only 0 and 1 on the Y axis, it will draw two ticks (0 and 1). But your callback is re-labeling every tick value ≥ 1 as "Here", so if the chart engine decides to show 1, 2, 3..., they’ll all say "Here".

Fix: explicitly map only the tick values you want:

$config.options.scales.attr1.ticks.callback = value => {
  if (value === 0) return 'Away';
  if (value === 1) return 'Here';
  return ''; // hide any extra ticks
};

This way:

  • 0 → "Away"
  • 1 → "Here"
  • Anything else → blank (so you don’t get multiple "Here" labels).

If you want to force the axis to only show those two ticks, you can also clamp it:

$config.options.scales.attr1.min = 0;
$config.options.scales.attr1.max = 1;
$config.options.scales.attr1.ticks.stepSize = 1;

That ensures the Y axis is just 0 and 1 with the labels you define."

Hello. Can you please advise me how to make a pie chart for the energy values ​​of the device? Thank you for your help.

I haven't implemented pie charts in Watchtower yet, mainly because I didn't have a personal use case for them. That said, I can explore this idea further if it proves useful to others in the community or if there's broader interest.

Could you share a bit more about the use case you had in mind? Understanding how you'd like to use pie charts for energy data could help shape a potential implementation.

Hello your app looks amazing and I'm trying to bring my data's into the app but I'm struggeling with that.
I have datas stored in google sheets and webcore LTS on the hub. I want to bring these data's into Watchtower in one shot and then have the app reading directly into my devices events.
Is this possible? And what is the best way to do it?
Thx

Maybe it would be possible to host all files somewhere in cloud and only get the device data from Hubitat Cloud?
That way it could be used with HD+ when not at home :slightly_smiling_face:

Or is there already a solution...the search didn't reveal any?

Is this data from Hubitat?? If so, could you PLEASE help me understand how to get data from Hubitat into a Google Sheet??? PLEASE?? I simply cannot figure it out...despite hours of trying

If you can get your data from Google Sheets and Webcore LTS into the Hubitat File Manager in either CSV or JSON format, you'll be able to build Watchtower graphs on top of it with very little effort (use the "Bring your own data" tile type). Just keep in mind that you need to make sure the data stays up to date with new entries over time.

If your goal is to use that data to “bootstrap” Watchtower's long-term history (so it doesn't start from scratch) that might be possible. But it does require a solid understanding of how Watchtower handles its internal files (like which ones get updated and when). There isn't a built-in UI or streamlined process for this, so it’ll take a fair amount of manual effort and experimentation.

I'll go over this again and add cloud support in the next version, when I get a bit of time.

Yes, I want to “bootstrap” Watchtower's long-term history.
I'm able to convert my datas myself, but I put them into the 5 minutes file and the app doesn't take them into account.
What should be the best approach?

I would only like to display the consumption ratio of individual devices in real time

Hello,
How can I do to have a bar graph like this?


I saw one post speaking about pixels but I don't understand exactly how should look the datas.
A dayli bar would be amazing :slightly_smiling_face:
Regarding long-term history converting to bootstrap the database, I managed to do it with power query and some formulas but yes, it took me 2 full days to make this! :dizzy_face: