Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for: Readme, OWM API, HPM, hubigraph_gauge, hubigraph_openweather_driver and WeatherTile.js #15

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Features
1. Graphing via [Google Charts](https://developers.google.com/chart) API
- Line, Bar, Area, Time Line
- Gauges
2. Weather Conditions and Forecast via PWS or OpenWeather
- Fully Configurable Sub-tiles
3. Displaying graphs on a dashboard
- Automatic child device ( [Hubigraph Tile Device](https://github.com/tchoward/Hubitat/blob/master/hubigraph_tile.groovy) ) creation
- Add to dashboard via Graph attribute on an Attribute Tile
4. Support for all devices on Hub
5. Graph Configuration Support
- Colors - (Titles, Labels, Lines, Axes, Backgrounds, etc)
- Font Size - (Titles, Labels, Axes, etc)
- Axes - (Location, Single/Dual, Number Tics, etc)
6. Hubigraph Tile Device
- Auto install/uninstall child device with Graph Attributes
7. Real-time, Periodic Graph Updates
- Real-time updates support sub-second updates
- Periodic updates to reduce browser loading

# INSTALLATION
Due to the large number of files and the complexity involved to manually install HubiGraphs, I recommend using [HUBITAT PACKAGE MANAGER](https://community.hubitat.com/t/beta-hubitat-package-manager/38016) for install.

## LINKS
- [GITHUB REPOSITORY](https://github.com/tchoward/Hubitat)
- [HUBITAT PACKAGE MANAGER](https://community.hubitat.com/t/beta-hubitat-package-manager/38016)

## EXAMPLES AND SCREENSHOTS
### Time Graph with Overlay
[![Time Graph with Overlay](https://community.hubitat.com/uploads/default/optimized/3X/4/c/4c400721082e8bf7dbe140dfc03f0b82dacb26e4_2_1380x912.jpeg "Time Graph with Overlay")](https://community.hubitat.com/uploads/default/original/3X/4/c/4c400721082e8bf7dbe140dfc03f0b82dacb26e4.jpeg)

### Time Graph (Bar and Points)
[![Time Graph (Bar and Points)](https://community.hubitat.com/uploads/default/optimized/3X/c/3/c3afed7a04f92b5b02eedb384d6aa2bddf1de726_2_1380x894.jpeg "Time Graph (Bar and Points)")](https://community.hubitat.com/uploads/default/original/3X/c/3/c3afed7a04f92b5b02eedb384d6aa2bddf1de726.jpeg)

### TimeLine Showing Motion
[![TimeLine Showing Motion](https://community.hubitat.com/uploads/default/optimized/3X/6/8/68e6208fffc8730510eeb3e4919dbbc7f7f064f5_2_1380x776.jpeg "TimeLine Showing Motion")](https://community.hubitat.com/uploads/default/original/3X/6/8/68e6208fffc8730510eeb3e4919dbbc7f7f064f5.jpeg)

### Heat Map
[![Heat Map](https://community.hubitat.com/uploads/default/original/3X/2/6/26e485929235e743c1a39778c409e43b856ad8c5.jpeg "Heat Map")](https://community.hubitat.com/uploads/default/original/3X/2/6/26e485929235e743c1a39778c409e43b856ad8c5.jpeg)

### Weather Tile 2.0
[![Weather Tile 2.0](https://community.hubitat.com/uploads/default/optimized/3X/a/6/a6428c650f4ed26494bd058d60ecc3448242ff0b_2_864x1000.jpeg "Weather Tile 2.0")](https://community.hubitat.com/uploads/default/original/3X/a/6/a6428c650f4ed26494bd058d60ecc3448242ff0b.jpeg)

### Radar Tile
[![Radar Tile](https://community.hubitat.com/uploads/default/original/3X/1/f/1f744ec7fbef685484045a9cc8365f19bf99761c.jpeg "Radar Tile")](https://community.hubitat.com/uploads/default/original/3X/1/f/1f744ec7fbef685484045a9cc8365f19bf99761c.jpeg)

### Time Graph with Bars
[![Time Graph with Bars](https://community.hubitat.com/uploads/default/original/3X/b/0/b075a5a2421e23127953dd771b585062fe6d4c36.jpeg "Time Graph with Bars")](https://community.hubitat.com/uploads/default/original/3X/b/0/b075a5a2421e23127953dd771b585062fe6d4c36.jpeg)

[![Time Graph with Bars](https://community.hubitat.com/uploads/default/optimized/3X/f/c/fcac0a34ed34c948fc9a588095150ee63ad070f9_2_990x1000.jpeg "Time Graph with Bars")](https://community.hubitat.com/uploads/default/original/3X/f/c/fcac0a34ed34c948fc9a588095150ee63ad070f9.jpeg)

### Range Graph
[![Range Graph](https://community.hubitat.com/uploads/default/optimized/3X/5/f/5f6317b6a91a45749c3d9dc82ffef6d1ebb450f6_2_1150x1000.jpeg "Range Graph")](https://community.hubitat.com/uploads/default/original/3X/5/f/5f6317b6a91a45749c3d9dc82ffef6d1ebb450f6.jpeg)

[![Range Graph](https://community.hubitat.com/uploads/default/original/3X/e/1/e1697477a4b66e667b1d293f03cb1007a9ddf4bc.jpeg "Range Graph")](https://community.hubitat.com/uploads/default/original/3X/e/1/e1697477a4b66e667b1d293f03cb1007a9ddf4bc.jpeg)

[![Range Graph](https://community.hubitat.com/uploads/default/optimized/3X/c/d/cd6dce86f8ac8f9abb57c7628cfc1aab3bc4d17f_2_1380x808.jpeg "Range Graph")](https://community.hubitat.com/uploads/default/original/3X/c/d/cd6dce86f8ac8f9abb57c7628cfc1aab3bc4d17f.jpeg)

### Gauges
[![Gauges](https://community.hubitat.com/uploads/default/original/3X/6/f/6f3936597ac2867531feb6f216f9667ec55e378d.jpeg "Gauges")](https://community.hubitat.com/uploads/default/original/3X/6/f/6f3936597ac2867531feb6f216f9667ec55e378d.jpeg)

## DESIGN
It is important to understand the design of Hubigraphs in order to grasp both the advantages and the limitations of Hubigraphs.

1. Hubigraphs is designed to work on a dashboard. As such, when you load (or refresh) a dashboard, the "tile" queries the database for all events covering the graph's time period. This can be thousands of events (depending on your device). To be clear, it can take 20-30 seconds for the initial loading. That is the bad news.
2. Hubigraphs does not add any loading to the Hubitat Hub. Once a dashboard is loaded, the graphs update using the same endpoint as the dashboard. Therefore, all updates from that point forward DO NOT add any load to Hubitat, it is all on the device that is displaying the dashboard.
3. Hubigraphs uses [Google Charts](https://developers.google.com/chart) Therefore, all the limitations, advantages and ease/difficulty of use is inherited from Google Charts. In the alpha build, I tried to incorporate as many options as possible (axes, labels, titles, etc). Some people have asked for features that to be blunt would require designing and implementing my own graphing API.
4. Hubigraphs was designed to work without external devices. I enjoy playing around with [Grafana](https://grafana.com/), [Influxdb](https://www.influxdata.com/), and other technologies, but it has required too much maintenance and configuration. I designed Hubigraphs only within the confines of Hubitat (user apps, dashboard, etc). I have no plans to support other platforms (SharpTools, and other third party dashboards at this time). Do I care if you "steal" my code, modify it, and add native support for those platforms? Not at all (see my FAQ).

# FAQ
1. **"Your idea is stupid and slow and I don't like it"**
Don't use the app

2. **"Your app is crashing my Hub. I submitted a support ticket"**
Don't do that, the fine folks at hubitat do not maintain the app. This software is given free of charge with no support.

3. **"The latest update broke the app, FIX IT".**
I do this for fun, please don't make it un-fun.

4. **"I have a great idea for a feature".**
Go ahead and post it, I might get around to it...

5. **"You ignored my great idea".**
See #2

6. **"I hate you for getting my hopes up, your app is awful/buggy/stupid".**
Ok

7. **"Please fix your app, it's broken".**
All cards on the table, I built this app for my wife. I will continue to support and provide updates as long as she uses it.

8. **"I stole your code and made it soooo much better" Thanks. Please post it so I can start using it.

9. **"You are awfully sarcastic, I don't like you".**
I have teenagers.

10. **"You stole the "Hubi" name, your app doesn't deserve it."**
My daughter came up with it. If the hubitat owners object, I will change it.

11. **"Your latest fix made things worse."**
I already covered this and See #9
6 changes: 3 additions & 3 deletions WeatherTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ function setPressure(val) {
}

function getWeather() {
const url = `https://api.openweathermap.org/data/2.5/onecall?lat=`+latitude+`&lon=`+longitude+`&exclude=minutely&appid=`+tile_key+`&units=imperial`;
const url = `https://api.openweathermap.org/data/3.0/onecall?lat=`+latitude+`&lon=`+longitude+`&exclude=minutely,hourly,daily,alerts&appid=`+tile_key+`&units=imperial`;

let now = new Date();
let tempUnits = "fahrenheit";
Expand Down Expand Up @@ -901,7 +901,7 @@ function getWeather() {
let secs = now.getTime() / 1000.0
secs = secs.toFixed();

const url2 = `https://api.openweathermap.org/data/2.5/onecall/timemachine?lat=`+latitude+`&lon=`+longitude+`&dt=`+secs+`&appid=`+tile_key;
const url2 = `https://api.openweathermap.org/data/3.0/onecall/timemachine?lat=`+latitude+`&lon=`+longitude+`&dt=`+secs+`&appid=`+tile_key;

fetch(url2)
.then(response => response.json())
Expand Down Expand Up @@ -1061,7 +1061,7 @@ function setForecastTile(weather) {

function getWeeklyForecastWeather() {

const url = `https://api.openweathermap.org/data/2.5/onecall?lat=`+latitude+`&lon=`+longitude+`&exclude=minutely&appid=`+tile_key+`&units=imperial`;
const url = `https://api.openweathermap.org/data/3.0/onecall?lat=`+latitude+`&lon=`+longitude+`&exclude=minutely,hourly,daily,alerts&appid=`+tile_key+`&units=imperial`;

let now = new Date();
console.log("OpenWeather Data Refresh at " + now.toLocaleString());
Expand Down
29 changes: 12 additions & 17 deletions hubigraph_gauge.groovy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Hubigraph Timeline Child App
* Hubigraph Gauge Child App
*
* Copyright 2020, but let's behonest, you'll copy it
* Copyright 2020, but let's be honest, you'll copy it
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
Expand Down Expand Up @@ -155,11 +155,7 @@ def graphSetupPage(){
container << parent.hubiForm_text_input (this, "Gauge Title", "gauge_title", "Gauge Title", false);
container << parent.hubiForm_text_input (this, "Gauge Units", "gauge_units", "Units", false);
container << parent.hubiForm_text_input (this, "Gauge Number Formatting<br><small>Example</small>", "gauge_number_format", "##.#", false);



container << parent.hubiForm_slider (this, title: "Select Number of Highlight Areas on Gauge", name: "num_highlights", default_value: 3, min: 0, max: 3, units: " highlights", submit_on_change: true);

parent.hubiForm_container(this, container, 1);
}

Expand All @@ -170,20 +166,19 @@ def graphSetupPage(){
num_ = num_highlights.toInteger();
}


if (num_ > 0){
parent.hubiForm_section(this,"HighLight Regions", 1){
container = [];
for (i=0; i<num_; i+=1){
for (i=0; i<num_; i++){
switch (i) {
case 0 : color_ = "#00FF00"; break;
case 1 : color_ = "#a9a67e"; break;
case 2 : color_ = "#FF0000"; break;
}
container << parent.hubiForm_color (this, "Highlight $i", "highlight${i}", color_, false);
container << parent.hubiForm_text_input (this, "Select Highlight Start Region Value ${i}", "highlight${i}_start", "", false);
container << parent.hubiForm_text_input (this, "Start Region Value", "highlight${i}_start", "", false);
container << parent.hubiForm_text_input (this, "End Region Value", "highlight${i}_end", "", false);
}
container << parent.hubiForm_text_input (this, "Select Highlight End Region Value ${i-1}", "highlight_end", "", false);
parent.hubiForm_container(this, container, 1);
}

Expand Down Expand Up @@ -353,35 +348,35 @@ def getChartOptions(){
case 3:
redColor = highlight2_color_transparent ? "transparent" : highlight2_color;
redFrom = highlight2_start;
redTo = highlight_end;
redTo = highlight2_end;

yellowColor = highlight1_color_transparent ? "transparent" : highlight1_color;
yellowFrom = highlight1_start;
yellowTo = highlight2_start;
yellowTo = highlight1_end;

greenColor = highlight0_color_transparent ? "transparent" : highlight0_color;
greenFrom = highlight0_start;
greenTo = highlight1_start;
greenTo = highlight0_end;

break;

case 2:

yellowColor = highlight1_color_transparent ? "transparent" : highlight1_color;
yellowFrom = highlight1_start;
yellowTo = highlight_end;
yellowTo = highlight1_end;

greenColor = highlight0_color_transparent ? "transparent" : highlight0_color;
greenFrom = highlight0_start;
greenTo = highlight1_start;
greenTo = highlight0_end;

break;

case 1:

greenColor = highlight0_color_transparent ? "transparent" : highlight0_color;
greenColor = highlight0_color_transparent ? "transparent" : highlight0_color;
greenFrom = highlight0_start;
greenTo = highlight_end
greenTo = highlight0_end

break;
}
Expand Down
29 changes: 24 additions & 5 deletions hubigraph_openweather_driver.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,22 @@ metadata {
capability 'Sensor'

attribute 'current_weather', 'string'

attribute 'sunrise', 'number'
attribute 'temp', 'number'
attribute 'visibility', 'number'
attribute 'uvi', 'number'
attribute 'pressure', 'number'
attribute 'clouds', 'number'
attribute 'feels_like', 'number'
attribute 'wind_gust', 'number'
attribute 'dt', 'number'
attribute 'wind_deg', 'number'
attribute 'dew_point', 'number'
attribute 'humidity', 'number'
attribute 'wind_speed', 'number'
attribute 'sunset', 'number'
attribute 'weather', 'vector3'

command 'pollData'
}

Expand Down Expand Up @@ -61,7 +76,7 @@ void pollOpenWeather() {

def ParamsOWM;

state.ow_uri = 'https://api.openweathermap.org/data/2.5/onecall?lat=' + latitude + '&lon=' + longitude + '&exclude=minutely&mode=json&units=imperial&appid=' + apiKey;
state.ow_uri = 'https://api.openweathermap.org/data/3.0/onecall?lat=' + latitude + '&lon=' + longitude + '&exclude=minutely,hourly,daily,alerts&mode=json&units=imperial&appid=' + apiKey;
ParamsOWM = [ uri: state.ow_uri]
//log.debug('Poll OpenWeatherMap.org: ' + ParamsOWM)
asynchttpGet('openWeatherHandler', ParamsOWM)
Expand All @@ -77,12 +92,16 @@ void openWeatherHandler(resp, data) {
} else {
now = new Date();
sendEvent(name: 'current_weather', value: now.getTime());
state.weatherData = resp.data;
weatherData = parseJson(resp.data);
weatherData.current.each{k, v ->
sendEvent(name: k, value: v);
}
state.weatherData = weatherData.current;
//state.weatherData = resp.data;
}
}

String getWeatherData(){
return state.weatherData;
}



Loading