node-red-contrib-deconz
Advanced tools
Comparing version 0.1.6 to 0.2.0
@@ -34,3 +34,3 @@ { | ||
}, | ||
"version": "0.1.6" | ||
"version": "0.2.0" | ||
} |
@@ -168,3 +168,2 @@ function deconz_getDeviceMeta(uniqueid) { | ||
if (controller) { | ||
@@ -246,2 +245,65 @@ $.getJSON('/deconz/statelist', { | ||
}); | ||
} | ||
} | ||
function deconz_initSettings(callback) { | ||
$.get("https://dresden-light.appspot.com/discover", function( data ) {}).done(function(data) { | ||
var settings = { | ||
name:data[0].name, | ||
ip:data[0].internalipaddress, | ||
port:data[0].internalport, | ||
apikey:'', | ||
ws_port:'' | ||
}; | ||
$.ajax({ | ||
type: "POST", | ||
dataType: 'json', | ||
url: 'http://'+settings.ip+':'+settings.port+'/api', | ||
data: JSON.stringify({"devicetype":"Node-red"}), | ||
success: function(response){ | ||
var resp = response[0]; | ||
if ('success' in resp) { | ||
settings.apikey = resp.success.username; | ||
$.ajax({ | ||
type: "GET", | ||
dataType: 'json', | ||
url: 'http://'+settings.ip+':'+settings.port+'/api/'+settings.apikey+'/config', | ||
success: function(response){ | ||
if ('websocketport' in response) { | ||
settings.ws_port = response.websocketport; | ||
} | ||
}, | ||
error: function (err) { | ||
var response = (JSON.parse(err.responseText)); | ||
var resp = response[0]; | ||
if ('error' in resp) { | ||
alert(resp.error.description); | ||
} | ||
}, | ||
complete: function() { | ||
callback(settings); | ||
return settings; | ||
} | ||
}); | ||
} | ||
}, | ||
error: function (err) { | ||
var response = (JSON.parse(err.responseText)); | ||
var resp = response[0]; | ||
if ('error' in resp) { | ||
alert(resp.error.description); | ||
} | ||
callback(settings); | ||
return settings; | ||
}, | ||
complete: function() { | ||
} | ||
}); | ||
}).fail(function() { | ||
alert( "Remote server did not answer. Internet problems?" ); | ||
}); | ||
} |
@@ -27,3 +27,19 @@ RED.nodes.registerType('deconz-server', { | ||
return this.name || this.ip+':'+this.port; | ||
} | ||
}, | ||
oneditprepare: function () { | ||
var node = this; | ||
var $refreshBtn = $('#force-refresh'); | ||
$refreshBtn.on('click', function(){ | ||
deconz_initSettings(function(settings){ | ||
$('#node-config-input-name').val(settings.name); | ||
$('#node-config-input-ip').val(settings.ip); | ||
$('#node-config-input-port').val(settings.port); | ||
$('#node-config-input-apikey').val(settings.apikey); | ||
$('#node-config-input-ws_port').val(settings.ws_port); | ||
}); | ||
}); | ||
}, | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
519288
33
1932
1