Adds driver and HTML files for sample

This commit is contained in:
Patrick McDonagh
2017-06-20 12:01:45 -05:00
parent a865ae36ba
commit caed9a07fb
9 changed files with 387 additions and 0 deletions

1
Alerts.html Normal file
View File

@@ -0,0 +1 @@
<module>Alerts</module>

6
NodeDetailHeader.html Normal file
View File

@@ -0,0 +1,6 @@
<div class='col-xs-1'>
<div class="<%= nodecolors.statuscolor %> nodecolor"></div>
</div>
<div class='col-xs-6'>
<h3><%= node.vanityname %></h3>
</div>

35
Nodelist.html Normal file
View File

@@ -0,0 +1,35 @@
<style>
.header h4 {
position: relative;
top: 0.9em;
}
.header h2 {
text-transform: uppercase;
font-size: 14px;
color: #aaa;
margin: 0.75em 0;
}
.header p {
font-size: 24px;
color: black;
font-weight: 600;
}
</style>
<div class="row header">
<div class="col-xs-1">
<div class="<%= nodecolors.statuscolor %> nodecolor"></div>
</div>
<div class="col-xs-2">
<img src="<%= nodeimgurl %>" />
</div>
<div class="col-xs-4">
<h4><%= node.vanityname %></h4>
</div>
<div class="col-xs-2">
<h2>Pond Level</h2>
<p><%= Math.round(channels["pondlevel.pond_level"].value * 100) / 100 %> ft.</p>
</div>
</div>

173
Overview.html Normal file
View File

@@ -0,0 +1,173 @@
<div class="row row-flex box-me">
<div class='col-xs-4 text-center'>
<h2>Pond Level</h2>
<div class="gauge-box">
<div data-labelheight="10"
style="height: 170px; background: transparent; margin: 0 auto;"
id="gauge-pond_level"
data-chart="solidgauge"
data-nodename="pondlevel.pond_level"
data-units="ft."
data-min="0"
data-max="25"
data-decimalplaces="2"
data-colors="0.1:#DF5353,0.5:#DDDF0D,0.9:#55BF3B"
data-valuefontsize="18px">
</div>
<div class- "timestamp-box">
<a href="#" data-channelId="<%= channels['pondlevel.pond_level'].channelId %>" class="data-table" title="Download Channel History">
<i class="fa fa-download"></i>
</a>
</div>
<span data-timeupdate="pond_level">
<%= channels["pondlevel.pond_level"].timestamp %>
</span>
</div>
</div>
<div class='col-xs-8'>
<div style="height:300px" id="chart-pond_level" data-chart="chart" data-nodename1="pondlevel.pond_level" data-datalabel1="Pond Level" data-daysofhistory="2" data-chartlabel="Pond Level" data-ylabel="" data-xlabel="Date" data-units=" ft"></div>
</div>
</div>
<h1 class="pad15">Configuration</h1>
<div class="row row-flex">
<div class="col-md-6 box-me entry-top-level" id="low_level_limit">
<div class="pad15">
<h2>Low Level Limit</h2>
<form class="form-inline">
<div class="form-group">
<input class="form-control val_box"
type="number"
step="any"
value="<%=channels['pondlevel.low_level_limit'].value %>">
</div>
<a href="#"
data-confirm-message="Are you sure you want to do this?"
data-refreshpause="1"
data-command=""
data-staticsend=1.0
data-channelId="<%= channels["pondlevel.low_level_limit"].channelId %>"
data-techname="<%=channels["pondlevel.low_level_limit"].techName %>"
data-name="<%= channels["pondlevel.low_level_limit"].name%>"
data-nodechannelcurrentId="<%= channels["pondlevel.low_level_limit"].nodechannelcurrentId %>"
id="<%= channels["pondlevel.low_level_limit"].channelId %>"
class="btn btn-large btn-theme animated setstatic material-icons">send</a>
</form>
</div>
</div>
<div class="col-md-6 box-me entry-top-level" id="high_level_limit">
<div class="pad15">
<h2>High Level Limit</h2>
<form class="form-inline">
<div class="form-group">
<input class="form-control val_box"
type="number"
step="any"
value="<%=channels['pondlevel.high_level_limit'].value %>">
</div>
<a href="#"
data-confirm-message="Are you sure you want to do this?"
data-refreshpause="1"
data-command=""
data-staticsend=25.0
data-channelId="<%= channels["pondlevel.high_level_limit"].channelId %>"
data-techname="<%=channels["pondlevel.high_level_limit"].techName %>"
data-name="<%= channels["pondlevel.high_level_limit"].name%>"
data-nodechannelcurrentId="<%= channels["pondlevel.high_level_limit"].nodechannelcurrentId %>"
id="<%= channels["pondlevel.high_level_limit"].channelId %>"
class="btn btn-large btn-theme animated setstatic material-icons">send</a>
</form>
</div>
</div>
</div>
<style>
.box-me {
position: relative;
padding: 0.5em;
padding-bottom: 1.5em;
border: 1px solid #eee;
/*margin: 1em 0;*/
}
.box-me .gauge-box {
margin-top: -0.25em;
}
.pad15 {
margin: 15px 15px;
}
.box-me h2 {
text-transform: uppercase;
font-size: 14px;
color: #666;
font-weight: 400;
letter-spacing: 1px;
z-index: 100;
}
.dynamic-chart-form {
background-color: whiteSmoke;
padding: 1em 0.5em;
margin-top: 1em;
}
.row-flex {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
flex-wrap: wrap;
}
.row-flex > [class*='col-'] {
display: flex;
flex-direction: column;
}
#systemStatusTimelineContainer h2 {
text-transform: uppercase;
font-size: 14px;
color: #666;
font-weight: 400;
letter-spacing: 1px;
z-index: 100;
}
.slice.node-detail hr {
border-color: #ccc;
}
.slice.node-detail #alarms li {
margin-bottom: 1em;
padding: 0.5em;
}
.slice.node-detail #alarms li:nth-child(even){
background-color: whiteSmoke;
}
.slice.node-detail #alarms li span {
margin-left: 1em;
color: #aaa;
}
</style>
<script>
$('.val_box').each(function(topLevel){
$(this).change(function(){
var id = "#" + $(this).closest(".entry-top-level").attr('id');
if (id !== "#undefined"){
var val = $(id).find('.val_box').val();
var tag = $(id).find('.setstatic').attr('data-staticsend', val);
console.log($(id).find('.setstatic').attr('data-staticsend'));
}
});
});
</script>

15
Sidebar.html Normal file
View File

@@ -0,0 +1,15 @@
<a href="#"
data-channelId="<%= channels["pondlevel.log"].channelId %>"
class="data-table btn-block btn btn-theme animated"
title="Device Log"><i style='margin-left: 0.5em; cursor: pointer' class="fa fa-th-list icon-theme"></i> Device Log</a>
<a href="#"
data-refreshpause="1"
data-staticsend="1"
data-channelId="<%= channels["pondlevel.sync"].channelId %>"
data-techname="<%=channels["pondlevel.sync"].techName %>"
data-name="<%= channels["pondlevel.sync"].name%>"
data-nodechannelcurrentId="<%= channels["pondlevel.sync"].nodechannelcurrentId %>"
id="<%= channels["pondlevel.sync"].channelId %>"
class="btn btn-large btn-block btn-theme animated setstatic mqtt">
<i class="icon-repeat icon-white mqtt" ></i>Sync All Data</a>

27
Trends.html Normal file
View File

@@ -0,0 +1,27 @@
<div class='col-xs-12' style="padding-top: 1em; margin-bottom: 1em;">
<div class="input-daterange input-group" id="datepicker">
<input data-chartid="dynamicChart" id="fromDate" data-daysofhistory="7" type="text" class="form-control" name="start">
<span class="input-group-addon">to</span>
<input class="form-control" data-chartid="dynamicChart" id="toDate" type="text" name="end">
<span class='input-group-btn'>
<a href="#!" data-chartid="dynamicChart" data-otherchartids="statusTimeline" class="btn chart-update btn-theme">Run</a>
</span>
</div>
</div>
<hr>
<div class='clearfix col-xs-12' style='height: 450px' id="dynamicChart" data-chart="dynamicchart" data-daysofhistory="7" data-chartlabel="Data" data-ylabel="" data-xlabel="Date" data-units="" data-channelnames="pondlevel.pond_level"></div>
<style>
.dynamic-chart-form {
background-color: whiteSmoke;
padding: 1em 0.5em;
margin-top: 1em;
}
#systemStatusTimelineContainer h2 {
text-transform: uppercase;
font-size: 14px;
color: #666;
font-weight: 400;
letter-spacing: 1px;
z-index: 100;
}
</style>

10
config.txt Normal file
View File

@@ -0,0 +1,10 @@
{
"driverFileName":"pondlevel.py",
"deviceName":"pondlevel",
"driverId":"0130",
"releaseVersion":"1",
"files": {
"file1":"pondlevel.py"}
}

88
pondlevel.py Normal file
View File

@@ -0,0 +1,88 @@
"""Driver for connecting Pond Level to Meshify."""
import threading
from device_base import deviceBase
import time
import random
_ = None
pond_level = {
'value': 15.0,
'timestamp': 0
}
send_delta = 0.5
send_time = 300
temp_pl = pond_level['value']
class start(threading.Thread, deviceBase):
"""Start class required by Meshify."""
def __init__(self, name=None, number=None, mac=None, Q=None, mcu=None, companyId=None, offset=None, mqtt=None, Nodes=None):
"""Initialize the driver."""
threading.Thread.__init__(self)
deviceBase.__init__(self, name=name, number=number, mac=mac, Q=Q, mcu=mcu, companyId=companyId, offset=offset, mqtt=mqtt, Nodes=Nodes)
self.daemon = True
self.version = "1"
self.finished = threading.Event()
self.forceSend = False
threading.Thread.start(self)
# this is a required function for all drivers, its goal is to upload some piece of data
# about your device so it can be seen on the web
def register(self):
"""Register the driver."""
self.sendtodb("log", "BOOM! Booted.", 0)
def run(self):
"""Actually run the driver."""
global pond_level, temp_pl, send_delta, send_time
wait_sec = 10
for i in range(0, wait_sec):
print("pondlevel driver will start in {} seconds".format(wait_sec - i))
time.sleep(1)
print("BOOM! Starting pondlevel driver...")
send_loops = 0
while True:
send_now = False
if self.forceSend:
print "FORCE SEND: TRUE"
send_now = True
up_down = 1
if bool(random.getrandbits(1)):
up_down = -1
temp_pl = pond_level['value'] + up_down * random.random()
if abs(temp_pl - pond_level['value']) > send_delta:
print("Sending {} due to value change".format(temp_pl))
send_now = True
elif (time.time() - pond_level['timestamp']) > send_time:
print("Sending {} due to time limit".format(temp_pl))
send_now = True
if send_now:
self.sendtodb('pond_level', temp_pl, 0)
pond_level['value'] = temp_pl
pond_level['timestamp'] = time.time()
print("pondlevel driver still alive...")
if self.forceSend:
if send_loops > 2:
print("Turning off forceSend")
self.forceSend = False
send_loops = 0
else:
send_loops += 1
time.sleep(10)
def pondlevel_sync(self, name, value):
"""Sync all data from the driver."""
self.forceSend = True
self.sendtodb("log", "synced", 0)
return True

32
test.html Normal file
View File

@@ -0,0 +1,32 @@
<div id="pit"></div>
<style>
#pit {
width:25%;
height: 400px;
border-left: 2px solid #000000;
border-right: 2px solid #000000;
border-bottom: 2px solid #000000;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
position: relative;
overflow: hidden;
}
#pit::before {
content: '';
position: absolute;
background: #04ACFF;
width: 100%;
bottom: 0;
animation: wipe 1s cubic-bezier(.2,.6,.8,.4) forwards;
}
@keyframes wipe {
0% {
height: 0;
}
100% {
height: 100%;
}
}
</style>