mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 16:17:30 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cca9a6be78 | ||
|
|
5d5b68209a | ||
|
|
d2e906caa3 | ||
|
|
a1708f2a88 | ||
|
|
49c3b85894 |
@@ -15,19 +15,21 @@ java -jar -Dupnp.config.address=A.B.C.D -Dvera.address=E.F.G.H -Dharmony.addres
|
||||
### -Dupnp.config.address=`<ip address>`
|
||||
The server defaults to the first available address on the host if this is not given. This default may NOT be the correct IP that is your public IP for your host on the network. It is best to set this parameter to not have discovery issues. Replace the -Dupnp.config.address=`<ip address>` value with the server ipv4 address you would like to use as the address that any upnp device will call after discovery.
|
||||
### -Dvera.address=`<ip address>` | `<{devices:[{name:avera,ip:x.y.w.z},{name:anothervera,ip:a.b.c.d}]}>`
|
||||
The argument for the vera address should be given as it the system does not have a way to find the address. Supply -Dvera.address=X.Y.Z.A on the command line to provide it. If a vera is not used, do not set it. To provide multiple veras, use the json style notation outlined above to provide the list. This argument is backwards compatible.
|
||||
The argument for the vera address should be given as it the system does not have a way to find the address. Supply -Dvera.address=X.Y.Z.A on the command line to provide it. If a vera is not used, do not set it. To provide multiple veras, use the json style notation outlined above to provide the list. The json notation may need to be surrounded by quotation marks when starting from a shell script. Most service scripts will not need the quotation marks. This argument is backwards compatible.
|
||||
### -Dserver.port=`<port>`
|
||||
The server defaults to running on port 8080. If you're already running a server (like openHAB) on 8080, -Dserver.port=`<port>` on the command line.
|
||||
### -Dupnp.device.db=`<filepath>`
|
||||
The default location for the db to contain the devices as they are added is "data/devices.db". If you would like a different filename or directory, specify -Dupnp.devices.db=`<directory>/<filename> or <filename>` if it is the same directory.
|
||||
The default location for the db to contain the devices as they are added is the relative path from where the bridge is started in "data/device.db". If you would like a different filename or directory, specify -Dupnp.devices.db=`<directory>/<filename>` explicitly.
|
||||
### -Dupnp.response.port=`<port>`
|
||||
The upnp response port that will be used. The default is 50000.
|
||||
### -Dharmony.address=`<ip address>` | `<{devices:[{name:ahub,ip:x.y.w.z},{name:anotherhub,ip:a.b.c.d}]}>`
|
||||
The argument for the Harmony Hub address should be given as the system does not have a way to find the address. Supply -Dharmony.address=X.Y.Z.A on the command line to provide it. If a Harmony Hub is not used, do not set it. To provide multiple harmony hubs, use the json style notation outlined above to provide the list. This argument is backwards compatible.
|
||||
The argument for the Harmony Hub address should be given as the system does not have a way to find the address. Supply -Dharmony.address=X.Y.Z.A on the command line to provide it. If a Harmony Hub is not used, do not set it. To provide multiple harmony hubs, use the json style notation outlined above to provide the list. The json notation may need to be surrounded by quotation marks when starting from a shell script. Most service scripts will not need the quotation marks. This argument is backwards compatible.
|
||||
### -Dharmony.user=`<username>`
|
||||
The user name of the MyHarmony.com account for the Harmony Hub. This needs to be given if you are using the Harmony Hub features, provide -Dharmony.user=`<username>` on the command line.
|
||||
### -Dharmony.pwd=`<password>`
|
||||
The password for the user name of the MyHarmony.com account for the Harmony Hub. This needs to be given if you are using the Harmony Hub Features, provide -Dharmony.pwd=`<password>` on the command line.
|
||||
### -Dbutton.sleep=`<time in milliseconds>`
|
||||
The default button press sleep time interval is 100 milliseconds. If you need more time add this parameter. For example 1000 ms is 1 second and you could set -Dbutton.sleep=1000 for the longer interval if you are having issues on your devices not handling button presses fast enough.
|
||||
### -Dnest.user=`<username>`
|
||||
The user name of the home.nest.com account for the Nest user. This needs to be given if you are using the Nest features, provide -Dnest.user=`<username>` on the command line. There is no need to give any ip address or host information as this contacts your cloud account.
|
||||
### -Dnest.pwd=`<password>`
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.bwssystems.HABridge</groupId>
|
||||
<artifactId>ha-bridge</artifactId>
|
||||
<version>1.3.6</version>
|
||||
<version>1.3.8</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HA Bridge</name>
|
||||
|
||||
@@ -11,7 +11,7 @@ public class BridgeSettings {
|
||||
private IpList harmonyaddress;
|
||||
private String harmonyuser;
|
||||
private String harmonypwd;
|
||||
private Integer upnpresponsedevices;
|
||||
private Integer buttonsleep;
|
||||
private boolean upnpstrict;
|
||||
private boolean traceupnp;
|
||||
private boolean devmode;
|
||||
@@ -67,12 +67,6 @@ public class BridgeSettings {
|
||||
public void setHarmonyPwd(String harmonypwd) {
|
||||
this.harmonypwd = harmonypwd;
|
||||
}
|
||||
public Integer getUpnpResponseDevices() {
|
||||
return upnpresponsedevices;
|
||||
}
|
||||
public void setUpnpResponseDevices(Integer upnpresponsedevices) {
|
||||
this.upnpresponsedevices = upnpresponsedevices;
|
||||
}
|
||||
public boolean isUpnpStrict() {
|
||||
return upnpstrict;
|
||||
}
|
||||
@@ -109,6 +103,12 @@ public class BridgeSettings {
|
||||
public void setNestConfigured(boolean isNestConfigured) {
|
||||
this.nestconfigured = isNestConfigured;
|
||||
}
|
||||
public Integer getButtonsleep() {
|
||||
return buttonsleep;
|
||||
}
|
||||
public void setButtonsleep(Integer buttonsleep) {
|
||||
this.buttonsleep = buttonsleep;
|
||||
}
|
||||
public Boolean isValidVera() {
|
||||
List<NamedIP> devicesList = this.veraaddress.getDevices();
|
||||
if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS))
|
||||
|
||||
@@ -11,4 +11,5 @@ public class Configuration {
|
||||
public final static String DEFAULT_USER = "";
|
||||
public final static String DEFAULT_PWD = "";
|
||||
public final static String DFAULT_WEB_PORT = "8080";
|
||||
public final static String DFAULT_BUTTON_SLEEP = "100";
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class HABridge {
|
||||
bridgeSettings.setUpnpStrict(Boolean.parseBoolean(System.getProperty("upnp.strict", "true")));
|
||||
bridgeSettings.setTraceupnp(Boolean.parseBoolean(System.getProperty("trace.upnp", "false")));
|
||||
bridgeSettings.setDevMode(Boolean.parseBoolean(System.getProperty("dev.mode", "false")));
|
||||
bridgeSettings.setUpnpResponseDevices(Integer.parseInt(System.getProperty("upnp.response.devices", Configuration.UPNP_RESPONSE_DEVICES)));
|
||||
bridgeSettings.setButtonsleep(Integer.parseInt(System.getProperty("button.sleep", Configuration.DFAULT_BUTTON_SLEEP)));
|
||||
bridgeSettings.setNestuser(System.getProperty("nest.user", Configuration.DEFAULT_USER));
|
||||
bridgeSettings.setNestpwd(System.getProperty("nest.pwd", Configuration.DEFAULT_PWD));
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ public class HueMulator {
|
||||
else {
|
||||
for(int i = 0; i < deviceButtons.length; i++) {
|
||||
if( i > 0)
|
||||
Thread.sleep(100);
|
||||
Thread.sleep(bridgeSettings.getButtonsleep());
|
||||
log.debug("pressing button: " + deviceButtons[i].getDevice() + " - " + deviceButtons[i].getButton() + " - iteration: " + String.valueOf(i));
|
||||
myHarmony.pressButton(deviceButtons[i]);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class UpnpSettingsResource {
|
||||
this.theSettings.setTraceupnp(theBridgeSettings.isTraceupnp());
|
||||
this.theSettings.setUpnpConfigAddress(theBridgeSettings.getUpnpConfigAddress());
|
||||
this.theSettings.setUpnpDeviceDb(theBridgeSettings.getUpnpDeviceDb());
|
||||
this.theSettings.setUpnpResponseDevices(theBridgeSettings.getUpnpResponseDevices());
|
||||
this.theSettings.setButtonsleep(theBridgeSettings.getButtonsleep());
|
||||
this.theSettings.setUpnpResponsePort(theBridgeSettings.getUpnpResponsePort());
|
||||
this.theSettings.setUpnpStrict(theBridgeSettings.isUpnpStrict());
|
||||
this.theSettings.setVeraAddress(theBridgeSettings.getVeraAddress());
|
||||
|
||||
7
src/main/resources/public/css/ngToast.min.css
vendored
Normal file
7
src/main/resources/public/css/ngToast.min.css
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* ngToast v1.5.6 (http://tameraydin.github.io/ngToast)
|
||||
* Copyright 2015 Tamer Aydin (http://tamerayd.in)
|
||||
* Licensed under MIT (http://tameraydin.mit-license.org/)
|
||||
*/
|
||||
|
||||
.ng-toast{position:fixed;z-index:1080;width:100%;height:0;margin-top:20px;text-align:center}.ng-toast.ng-toast--top,.ng-toast.ng-toast--top .ng-toast__list{top:0;bottom:auto}.ng-toast.ng-toast--top.ng-toast--center .ng-toast__list{position:static}.ng-toast.ng-toast--bottom,.ng-toast.ng-toast--bottom .ng-toast__list{top:auto;bottom:0}.ng-toast.ng-toast--bottom.ng-toast--center .ng-toast__list{pointer-events:none}.ng-toast.ng-toast--bottom.ng-toast--center .ng-toast__message .alert{pointer-events:auto}.ng-toast.ng-toast--right .ng-toast__list{left:auto;right:0;margin-right:20px}.ng-toast.ng-toast--right .ng-toast__message{text-align:right}.ng-toast.ng-toast--left .ng-toast__list{right:auto;left:0;margin-left:20px}.ng-toast.ng-toast--left .ng-toast__message{text-align:left}.ng-toast .ng-toast__list{display:inline-block;position:absolute;right:0;left:0;margin:0 auto;padding:0;list-style:none}.ng-toast .ng-toast__message{display:block;width:100%;text-align:center}.ng-toast .ng-toast__message .alert{display:inline-block}.ng-toast .ng-toast__message__count{display:inline-block;margin:0 15px 0 5px}
|
||||
@@ -7,6 +7,7 @@
|
||||
<title>HA Bridge</title>
|
||||
<link href="css/main.css" rel="stylesheet">
|
||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="css/ngToast.min.css" rel="stylesheet">
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script type="text/javascript" src="js/html5shiv.min.js"></script>
|
||||
@@ -14,6 +15,7 @@
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<toast></toast>
|
||||
|
||||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container" ng-controller="VersionController">
|
||||
@@ -54,6 +56,8 @@
|
||||
<script src="js/jquery-1.11.3.min.js"></script>
|
||||
<script src="js/angular.min.js"></script>
|
||||
<script src="js/angular-route.min.js"></script>
|
||||
<script src="js/angular-sanitize.min.js"></script>
|
||||
<script src="js/ngToast.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
<script src="scripts/app.js"></script>
|
||||
</body>
|
||||
|
||||
16
src/main/resources/public/js/angular-sanitize.min.js
vendored
Normal file
16
src/main/resources/public/js/angular-sanitize.min.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
AngularJS v1.4.3
|
||||
(c) 2010-2015 Google, Inc. http://angularjs.org
|
||||
License: MIT
|
||||
*/
|
||||
(function(n,h,p){'use strict';function E(a){var f=[];r(f,h.noop).chars(a);return f.join("")}function g(a,f){var d={},c=a.split(","),b;for(b=0;b<c.length;b++)d[f?h.lowercase(c[b]):c[b]]=!0;return d}function F(a,f){function d(a,b,d,l){b=h.lowercase(b);if(s[b])for(;e.last()&&t[e.last()];)c("",e.last());u[b]&&e.last()==b&&c("",b);(l=v[b]||!!l)||e.push(b);var m={};d.replace(G,function(b,a,f,c,d){m[a]=q(f||c||d||"")});f.start&&f.start(b,m,l)}function c(b,a){var c=0,d;if(a=h.lowercase(a))for(c=e.length-
|
||||
1;0<=c&&e[c]!=a;c--);if(0<=c){for(d=e.length-1;d>=c;d--)f.end&&f.end(e[d]);e.length=c}}"string"!==typeof a&&(a=null===a||"undefined"===typeof a?"":""+a);var b,k,e=[],m=a,l;for(e.last=function(){return e[e.length-1]};a;){l="";k=!0;if(e.last()&&w[e.last()])a=a.replace(new RegExp("([\\W\\w]*)<\\s*\\/\\s*"+e.last()+"[^>]*>","i"),function(a,b){b=b.replace(H,"$1").replace(I,"$1");f.chars&&f.chars(q(b));return""}),c("",e.last());else{if(0===a.indexOf("\x3c!--"))b=a.indexOf("--",4),0<=b&&a.lastIndexOf("--\x3e",
|
||||
b)===b&&(f.comment&&f.comment(a.substring(4,b)),a=a.substring(b+3),k=!1);else if(x.test(a)){if(b=a.match(x))a=a.replace(b[0],""),k=!1}else if(J.test(a)){if(b=a.match(y))a=a.substring(b[0].length),b[0].replace(y,c),k=!1}else K.test(a)&&((b=a.match(z))?(b[4]&&(a=a.substring(b[0].length),b[0].replace(z,d)),k=!1):(l+="<",a=a.substring(1)));k&&(b=a.indexOf("<"),l+=0>b?a:a.substring(0,b),a=0>b?"":a.substring(b),f.chars&&f.chars(q(l)))}if(a==m)throw L("badparse",a);m=a}c()}function q(a){if(!a)return"";A.innerHTML=
|
||||
a.replace(/</g,"<");return A.textContent}function B(a){return a.replace(/&/g,"&").replace(M,function(a){var d=a.charCodeAt(0);a=a.charCodeAt(1);return"&#"+(1024*(d-55296)+(a-56320)+65536)+";"}).replace(N,function(a){return"&#"+a.charCodeAt(0)+";"}).replace(/</g,"<").replace(/>/g,">")}function r(a,f){var d=!1,c=h.bind(a,a.push);return{start:function(a,k,e){a=h.lowercase(a);!d&&w[a]&&(d=a);d||!0!==C[a]||(c("<"),c(a),h.forEach(k,function(d,e){var k=h.lowercase(e),g="img"===a&&"src"===k||
|
||||
"background"===k;!0!==O[k]||!0===D[k]&&!f(d,g)||(c(" "),c(e),c('="'),c(B(d)),c('"'))}),c(e?"/>":">"))},end:function(a){a=h.lowercase(a);d||!0!==C[a]||(c("</"),c(a),c(">"));a==d&&(d=!1)},chars:function(a){d||c(B(a))}}}var L=h.$$minErr("$sanitize"),z=/^<((?:[a-zA-Z])[\w:-]*)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*(>?)/,y=/^<\/\s*([\w:-]+)[^>]*>/,G=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,K=/^</,J=/^<\//,H=/\x3c!--(.*?)--\x3e/g,x=/<!DOCTYPE([^>]*?)>/i,
|
||||
I=/<!\[CDATA\[(.*?)]]\x3e/g,M=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,N=/([^\#-~| |!])/g,v=g("area,br,col,hr,img,wbr");n=g("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr");p=g("rp,rt");var u=h.extend({},p,n),s=h.extend({},n,g("address,article,aside,blockquote,caption,center,del,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,h6,header,hgroup,hr,ins,map,menu,nav,ol,pre,script,section,table,ul")),t=h.extend({},p,g("a,abbr,acronym,b,bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,q,ruby,rp,rt,s,samp,small,span,strike,strong,sub,sup,time,tt,u,var"));
|
||||
n=g("circle,defs,desc,ellipse,font-face,font-face-name,font-face-src,g,glyph,hkern,image,linearGradient,line,marker,metadata,missing-glyph,mpath,path,polygon,polyline,radialGradient,rect,stop,svg,switch,text,title,tspan,use");var w=g("script,style"),C=h.extend({},v,s,t,u,n),D=g("background,cite,href,longdesc,src,usemap,xlink:href");n=g("abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace,ismap,lang,language,nohref,nowrap,rel,rev,rows,rowspan,rules,scope,scrolling,shape,size,span,start,summary,tabindex,target,title,type,valign,value,vspace,width");
|
||||
p=g("accent-height,accumulate,additive,alphabetic,arabic-form,ascent,baseProfile,bbox,begin,by,calcMode,cap-height,class,color,color-rendering,content,cx,cy,d,dx,dy,descent,display,dur,end,fill,fill-rule,font-family,font-size,font-stretch,font-style,font-variant,font-weight,from,fx,fy,g1,g2,glyph-name,gradientUnits,hanging,height,horiz-adv-x,horiz-origin-x,ideographic,k,keyPoints,keySplines,keyTimes,lang,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mathematical,max,min,offset,opacity,orient,origin,overline-position,overline-thickness,panose-1,path,pathLength,points,preserveAspectRatio,r,refX,refY,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,rotate,rx,ry,slope,stemh,stemv,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,systemLanguage,target,text-anchor,to,transform,type,u1,u2,underline-position,underline-thickness,unicode,unicode-range,units-per-em,values,version,viewBox,visibility,width,widths,x,x-height,x1,x2,xlink:actuate,xlink:arcrole,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,xml:space,xmlns,xmlns:xlink,y,y1,y2,zoomAndPan",
|
||||
!0);var O=h.extend({},D,p,n),A=document.createElement("pre");h.module("ngSanitize",[]).provider("$sanitize",function(){this.$get=["$$sanitizeUri",function(a){return function(f){var d=[];F(f,r(d,function(c,b){return!/^unsafe/.test(a(c,b))}));return d.join("")}}]});h.module("ngSanitize").filter("linky",["$sanitize",function(a){var f=/((ftp|https?):\/\/|(www\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"\u201d\u2019]/i,d=/^mailto:/i;return function(c,b){function k(a){a&&g.push(E(a))}function e(a,
|
||||
c){g.push("<a ");h.isDefined(b)&&g.push('target="',b,'" ');g.push('href="',a.replace(/"/g,"""),'">');k(c);g.push("</a>")}if(!c)return c;for(var m,l=c,g=[],n,p;m=l.match(f);)n=m[0],m[2]||m[4]||(n=(m[3]?"http://":"mailto:")+n),p=m.index,k(l.substr(0,p)),e(n,m[0].replace(d,"")),l=l.substring(p+m[0].length);k(l);return a(g.join(""))}}])})(window,window.angular);
|
||||
//# sourceMappingURL=angular-sanitize.min.js.map
|
||||
6
src/main/resources/public/js/ngToast.min.js
vendored
Normal file
6
src/main/resources/public/js/ngToast.min.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* ngToast v1.5.6 (http://tameraydin.github.io/ngToast)
|
||||
* Copyright 2015 Tamer Aydin (http://tamerayd.in)
|
||||
* Licensed under MIT (http://tameraydin.mit-license.org/)
|
||||
*/
|
||||
!function(a,b,c){"use strict";b.module("ngToast.provider",[]).provider("ngToast",[function(){function a(a){for(var d=Math.floor(1e3*Math.random());c.indexOf(d)>-1;)d=Math.floor(1e3*Math.random());this.id=d,this.count=0,this.animation=e.animation,this.className=e.className,this.additionalClasses=e.additionalClasses,this.dismissOnTimeout=e.dismissOnTimeout,this.timeout=e.timeout,this.dismissButton=e.dismissButton,this.dismissButtonHtml=e.dismissButtonHtml,this.dismissOnClick=e.dismissOnClick,this.compileContent=e.compileContent,b.extend(this,a)}var c=[],d=[],e={animation:!1,className:"success",additionalClasses:null,dismissOnTimeout:!0,timeout:4e3,dismissButton:!1,dismissButtonHtml:"×",dismissOnClick:!0,compileContent:!1,combineDuplications:!1,horizontalPosition:"right",verticalPosition:"top",maxNumber:0};this.configure=function(a){b.extend(e,a)},this.$get=[function(){var b=function(a,b){return b="object"==typeof b?b:{content:b},b.className=a,this.create(b)};return{settings:e,messages:c,dismiss:function(a){if(a){for(var b=c.length-1;b>=0;b--)if(c[b].id===a)return c.splice(b,1),void d.splice(d.indexOf(a),1)}else{for(;c.length>0;)c.pop();d=[]}},create:function(b){if(b="object"==typeof b?b:{content:b},e.combineDuplications)for(var f=d.length-1;f>=0;f--){var g=c[f],h=b.className||"success";if(g.content===b.content&&g.className===h)return void c[f].count++}e.maxNumber>0&&d.length>=e.maxNumber&&this.dismiss(d[0]);var i=new a(b);return"bottom"===e.verticalPosition?c.unshift(i):c.push(i),d.push(i.id),i.id},success:function(a){return b.call(this,"success",a)},info:function(a){return b.call(this,"info",a)},warning:function(a){return b.call(this,"warning",a)},danger:function(a){return b.call(this,"danger",a)}}}]}])}(window,window.angular),function(a,b){"use strict";b.module("ngToast.directives",["ngToast.provider"]).run(["$templateCache",function(a){a.put("ngToast/toast.html",'<div class="ng-toast ng-toast--{{hPos}} ng-toast--{{vPos}} {{animation ? \'ng-toast--animate-\' + animation : \'\'}}"><ul class="ng-toast__list"><toast-message ng-repeat="message in messages" message="message" count="message.count"><span ng-bind-html="message.content"></span></toast-message></ul></div>'),a.put("ngToast/toastMessage.html",'<li class="ng-toast__message {{message.additionalClasses}}"ng-mouseenter="onMouseEnter()"ng-mouseleave="onMouseLeave()"><div class="alert alert-{{message.className}}" ng-class="{\'alert-dismissible\': message.dismissButton}"><button type="button" class="close" ng-if="message.dismissButton" ng-bind-html="message.dismissButtonHtml" ng-click="!message.dismissOnClick && dismiss()"></button><span ng-if="count" class="ng-toast__message__count">{{count + 1}}</span><span ng-if="!message.compileContent" ng-transclude></span></div></li>')}]).directive("toast",["ngToast","$templateCache","$log",function(a,b,c){return{replace:!0,restrict:"EA",templateUrl:"ngToast/toast.html",compile:function(d,e){if(e.template){var f=b.get(e.template);f?d.replaceWith(f):c.warn("ngToast: Provided template could not be loaded. Please be sure that it is populated before the <toast> element is represented.")}return function(b){b.hPos=a.settings.horizontalPosition,b.vPos=a.settings.verticalPosition,b.animation=a.settings.animation,b.messages=a.messages}}}}]).directive("toastMessage",["$timeout","$compile","ngToast",function(a,b,c){return{replace:!0,transclude:!0,restrict:"EA",scope:{message:"=",count:"="},controller:["$scope","ngToast",function(a,b){a.dismiss=function(){b.dismiss(a.message.id)}}],templateUrl:"ngToast/toastMessage.html",link:function(d,e,f,g,h){e.attr("data-message-id",d.message.id);var i,j=d.message.compileContent;if(d.cancelTimeout=function(){a.cancel(i)},d.startTimeout=function(){d.message.dismissOnTimeout&&(i=a(function(){c.dismiss(d.message.id)},d.message.timeout))},d.onMouseEnter=function(){d.cancelTimeout()},d.onMouseLeave=function(){d.startTimeout()},j){var k;h(d,function(a){k=a,e.children().append(k)}),a(function(){b(k.contents())("boolean"==typeof j?d.$parent:j,function(a){k.replaceWith(a)})},0)}d.startTimeout(),d.message.dismissOnClick&&e.bind("click",function(){c.dismiss(d.message.id),d.$apply()})}}}])}(window,window.angular),function(a,b){"use strict";b.module("ngToast",["ngSanitize","ngToast.directives","ngToast.provider"])}(window,window.angular);
|
||||
@@ -1,4 +1,4 @@
|
||||
var app = angular.module('habridge', ['ngRoute']);
|
||||
var app = angular.module('habridge', ['ngRoute','ngToast']);
|
||||
|
||||
app.config(function ($routeProvider) {
|
||||
$routeProvider.when('/#', {
|
||||
@@ -36,9 +36,9 @@ app.run( function (bridgeService) {
|
||||
bridgeService.getHABridgeVersion();
|
||||
});
|
||||
|
||||
app.service('bridgeService', function ($http, $window) {
|
||||
app.service('bridgeService', function ($http, $window, ngToast) {
|
||||
var self = this;
|
||||
this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/settings", huebase: window.location.origin + "/api", backups: [], devices: [], device: [], settings: [], error: "", showVera: false, showHarmony: false, showNest: false, habridgeversion: ""};
|
||||
this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/settings", huebase: window.location.origin + "/api", backups: [], devices: [], device: [], settings: [], olddevicename: "", error: "", showVera: false, showHarmony: false, showNest: false, habridgeversion: ""};
|
||||
|
||||
this.viewDevices = function () {
|
||||
this.state.error = "";
|
||||
@@ -304,7 +304,7 @@ app.service('bridgeService', function ($http, $window) {
|
||||
if (error.data) {
|
||||
$window.alert("Add new Device Error: " + error.data.message);
|
||||
}
|
||||
$window.alert("Add new Device Error: unknown");
|
||||
self.state.error = "Add new Device Error: unknown";
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -322,7 +322,7 @@ app.service('bridgeService', function ($http, $window) {
|
||||
if (error.data) {
|
||||
self.state.error = error.data.message;
|
||||
}
|
||||
$window.alert("Backup Device Db Error: unknown");
|
||||
self.state.error = "Backup Device Db Error: unknown";
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -340,7 +340,7 @@ app.service('bridgeService', function ($http, $window) {
|
||||
if (error.data) {
|
||||
self.state.error = error.data.message;
|
||||
}
|
||||
$window.alert("Backup Db Restore Error: unknown");
|
||||
self.state.error = "Backup Db Restore Error: unknown";
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -357,7 +357,7 @@ app.service('bridgeService', function ($http, $window) {
|
||||
if (error.data) {
|
||||
self.state.error = error.data.message;
|
||||
}
|
||||
$window.alert("Backup Db Frlryr Error: unknown");
|
||||
self.state.error = "Backup Db File Error: unknown";
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -372,7 +372,7 @@ app.service('bridgeService', function ($http, $window) {
|
||||
if (error.data) {
|
||||
self.state.error = error.data.message;
|
||||
}
|
||||
$window.alert("Delete Device Error: unknown");
|
||||
self.state.error = "Delete Device Error: unknown";
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -386,16 +386,21 @@ app.service('bridgeService', function ($http, $window) {
|
||||
|
||||
this.editDevice = function (device) {
|
||||
self.state.device = device;
|
||||
self.state.olddevicename = device.name;
|
||||
};
|
||||
|
||||
this.testUrl = function (device, type) {
|
||||
if(type == "on") {
|
||||
$http.put(this.state.huebase + "/test/lights/" + device.id + "/state", "{\"on\":true}").then(
|
||||
function (response) {
|
||||
$window.alert("Request Exceuted: " + response.statusText);
|
||||
ngToast.create({
|
||||
className: "success",
|
||||
content:"Request Exceuted: " + response.statusText});
|
||||
},
|
||||
function (error) {
|
||||
$window.alert("Request Error: " + error.statusText + ", with status: " + error.status + ", Pleae look in your console log.");
|
||||
ngToast.create({
|
||||
className: "warning",
|
||||
content:"Request Error: " + error.statusText + ", with status: " + error.status + ", Pleae look in your console log."});
|
||||
}
|
||||
);
|
||||
return;
|
||||
@@ -403,10 +408,14 @@ app.service('bridgeService', function ($http, $window) {
|
||||
else {
|
||||
$http.put(this.state.huebase + "/test/lights/" + device.id + "/state", "{\"on\":false}").then(
|
||||
function (response) {
|
||||
$window.alert("Request Exceuted: " + response.statusText);
|
||||
ngToast.create({
|
||||
className: "success",
|
||||
content:"Request Exceuted: " + response.statusText});
|
||||
},
|
||||
function (error) {
|
||||
$window.alert("Request Error: " + error.statusText + ", with status: " + error.status + ", Pleae look in your console log.");
|
||||
ngToast.create({
|
||||
className: "warning",
|
||||
content:"Request Error: " + error.statusText + ", with status: " + error.status + ", Pleae look in your console log."});
|
||||
}
|
||||
);
|
||||
return;
|
||||
@@ -477,7 +486,8 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
|
||||
$scope.device = $scope.bridge.device;
|
||||
$scope.device_dim_control = "";
|
||||
$scope.bulk = { devices: [] };
|
||||
$scope.vera = {base: "http://" + $scope.bridge.settings.veraaddress, port: "3480", id: ""};
|
||||
var veraList = angular.fromJson($scope.bridge.settings.veraaddress);
|
||||
$scope.vera = {base: "http://" + veraList.devices[0].ip, port: "3480", id: ""};
|
||||
bridgeService.viewVeraDevices();
|
||||
bridgeService.viewVeraScenes();
|
||||
bridgeService.viewHarmonyActivities();
|
||||
@@ -506,6 +516,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
|
||||
$scope.device.contentType = null;
|
||||
$scope.device.contentBody = null;
|
||||
$scope.device.contentBodyOff = null;
|
||||
$scope.bridge.olddevicename = "";
|
||||
};
|
||||
|
||||
$scope.buildUrlsUsingDevice = function (dim_control) {
|
||||
@@ -513,7 +524,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
|
||||
$scope.vera.base = "http://" + $scope.vera.base;
|
||||
}
|
||||
$scope.device.deviceType = "switch";
|
||||
$scope.device.targetDevice = $scope.bridge.settings.veraaddress;
|
||||
$scope.device.targetDevice = "Encapsulated";
|
||||
$scope.device.mapType = "veraDevice";
|
||||
$scope.device.mapId = $scope.vera.id;
|
||||
if(dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0)
|
||||
@@ -536,7 +547,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
|
||||
$scope.vera.base = "http://" + $scope.vera.base;
|
||||
}
|
||||
$scope.device.deviceType = "scene";
|
||||
$scope.device.targetDevice = $scope.bridge.settings.veraaddress;
|
||||
$scope.device.targetDevice = "Encapsulated";
|
||||
$scope.device.mapType = "veraScene";
|
||||
$scope.device.mapId = $scope.vera.id;
|
||||
$scope.device.onUrl = $scope.vera.base + ":" + $scope.vera.port
|
||||
@@ -548,42 +559,36 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
|
||||
};
|
||||
|
||||
$scope.buildDeviceUrls = function (veradevice, dim_control) {
|
||||
if ($scope.vera.base.indexOf("http") < 0) {
|
||||
$scope.vera.base = "http://" + $scope.vera.base;
|
||||
}
|
||||
$scope.device.deviceType = "switch";
|
||||
$scope.device.name = veradevice.name;
|
||||
$scope.device.targetDevice = veradevice.veraname;
|
||||
$scope.device.mapType = "veraDevice";
|
||||
$scope.device.mapId = veradevice.id;
|
||||
if(dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0)
|
||||
$scope.device.onUrl = $scope.vera.base + ":" + $scope.vera.port
|
||||
$scope.device.onUrl = "http://" + veradevice.veraaddress + ":" + $scope.vera.port
|
||||
+ "/data_request?id=action&output_format=json&DeviceNum="
|
||||
+ veradevice.id
|
||||
+ "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget="
|
||||
+ dim_control;
|
||||
else
|
||||
$scope.device.onUrl = $scope.vera.base + ":" + $scope.vera.port
|
||||
$scope.device.onUrl = "http://" + veradevice.veraaddress + ":" + $scope.vera.port
|
||||
+ "/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum="
|
||||
+ veradevice.id;
|
||||
$scope.device.offUrl = $scope.vera.base + ":" + $scope.vera.port
|
||||
$scope.device.offUrl = "http://" + veradevice.veraaddress + ":" + $scope.vera.port
|
||||
+ "/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum="
|
||||
+ veradevice.id;
|
||||
};
|
||||
|
||||
$scope.buildSceneUrls = function (verascene) {
|
||||
if ($scope.vera.base.indexOf("http") < 0) {
|
||||
$scope.vera.base = "http://" + $scope.vera.base;
|
||||
}
|
||||
$scope.device.deviceType = "scene";
|
||||
$scope.device.name = verascene.name;
|
||||
$scope.device.targetDevice = verascene.veraname;
|
||||
$scope.device.mapType = "veraScene";
|
||||
$scope.device.mapId = verascene.id;
|
||||
$scope.device.onUrl = $scope.vera.base + ":" + $scope.vera.port
|
||||
$scope.device.onUrl = "http://" + verascene.veraaddress + ":" + $scope.vera.port
|
||||
+ "/data_request?id=action&output_format=json&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="
|
||||
+ verascene.id;
|
||||
$scope.device.offUrl = $scope.vera.base + ":" + $scope.vera.port
|
||||
$scope.device.offUrl = "http://" + verascene.veraaddress + + ":" + $scope.vera.port
|
||||
+ "/data_request?id=action&output_format=json&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="
|
||||
+ verascene.id;
|
||||
};
|
||||
@@ -705,6 +710,27 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
|
||||
|
||||
};
|
||||
|
||||
$scope.copyDevice = function () {
|
||||
if($scope.device.name == "" && $scope.device.onUrl == "") {
|
||||
$scope.clearDevice();
|
||||
return;
|
||||
}
|
||||
|
||||
if($scope.device.name == $scope.bridge.olddevicename) {
|
||||
$scope.clearDevice();
|
||||
return;
|
||||
}
|
||||
$scope.device.id = null;
|
||||
bridgeService.addDevice($scope.device).then(
|
||||
function () {
|
||||
$scope.clearDevice();
|
||||
},
|
||||
function (error) {
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
$scope.bulkAddDevices = function(dim_control) {
|
||||
for(var i = 0; i < $scope.bulk.devices.length; i++) {
|
||||
for(var x = 0; x < bridgeService.state.veradevices.length; x++) {
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<button class="btn btn-info" type="submit"
|
||||
ng-click="testUrl(device, 'off')">Test OFF</button>
|
||||
<button class="btn btn-warning" type="submit"
|
||||
ng-click="editDevice(device)">Edit</button>
|
||||
ng-click="editDevice(device)">Edit/Copy</button>
|
||||
<button class="btn btn-danger" type="submit"
|
||||
ng-click="deleteDevice(device)">Delete</button>
|
||||
</td>
|
||||
@@ -133,6 +133,10 @@
|
||||
<td>nest.configured</td>
|
||||
<td>{{bridge.settings.nestconfigured}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>button.sleep</td>
|
||||
<td>{{bridge.settings.buttonsleep}} ms</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
|
||||
<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title">Edit a device</h2>
|
||||
<h2 class="panel-title">Edit/Copy a device</h2>
|
||||
</div>
|
||||
<p class="text-muted">This screen allows the modification of many fields the bridge uses. Please use care when
|
||||
updating these fields as you may break the settings used by the bridge to call a specific end point device.</p>
|
||||
<p>When copying, update the name and select the "Add Bridge Device" Button.</p>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<form class="form-horizontal">
|
||||
@@ -26,7 +27,7 @@
|
||||
<input type="text" class="form-control" id="device-name"
|
||||
ng-model="device.name" placeholder="Device Name">
|
||||
</div>
|
||||
<button type="submit" class="col-xs-4 col-sm-2 btn btn-primary" ng-click="addDevice()">
|
||||
<button type="submit" class="col-xs-4 col-sm-2 btn btn-success" ng-click="addDevice()">
|
||||
Update Bridge Device</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -37,8 +38,8 @@
|
||||
<input type="text" class="form-control" id="device-target"
|
||||
ng-model="device.targetDevice" placeholder="default">
|
||||
</div>
|
||||
<button class="btn btn-danger" ng-click="clearDevice()">
|
||||
Clear Device</button>
|
||||
<button class="btn btn-primary" ng-click="copyDevice()">
|
||||
Add Bridge Device</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
@@ -56,6 +57,8 @@
|
||||
<option value="nestThermoSet">Nest Thermostat</option>
|
||||
</select>
|
||||
</div>
|
||||
<button class="btn btn-danger" ng-click="clearDevice()">
|
||||
Clear Device</button>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-if="device.mapType" class="form-group">
|
||||
|
||||
Reference in New Issue
Block a user