mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
parent
d3c8e6da4e
commit
d3a912f014
@ -696,24 +696,27 @@ function startWizardPhilipsHue(e) {
|
|||||||
function checkHueBridge(cb, hueUser) {
|
function checkHueBridge(cb, hueUser) {
|
||||||
var usr = (typeof hueUser != "undefined") ? hueUser : 'config';
|
var usr = (typeof hueUser != "undefined") ? hueUser : 'config';
|
||||||
if (usr == 'config') $('#wiz_hue_discovered').html("");
|
if (usr == 'config') $('#wiz_hue_discovered').html("");
|
||||||
$.ajax({
|
|
||||||
url: 'http://' + hueIPs[hueIPsinc].internalipaddress + '/api/' + usr,
|
if (hueIPs[hueIPsinc]) {
|
||||||
type: "GET",
|
$.ajax({
|
||||||
dataType: "json",
|
url: 'http://' + hueIPs[hueIPsinc].internalipaddress + '/api/' + usr,
|
||||||
success: function (json) {
|
type: "GET",
|
||||||
if (json.config) {
|
dataType: "json",
|
||||||
cb(true, usr);
|
success: function (json) {
|
||||||
} else if (json.name && json.bridgeid && json.modelid) {
|
if (json.config) {
|
||||||
$('#wiz_hue_discovered').html("Bridge: " + json.name + ", Modelid: " + json.modelid + ", API-Version: " + json.apiversion);
|
cb(true, usr);
|
||||||
cb(true);
|
} else if (json.name && json.bridgeid && json.modelid) {
|
||||||
} else {
|
$('#wiz_hue_discovered').html("Bridge: " + json.name + ", Modelid: " + json.modelid + ", API-Version: " + json.apiversion);
|
||||||
cb(false);
|
cb(true);
|
||||||
}
|
} else {
|
||||||
},
|
cb(false);
|
||||||
timeout: 2500
|
}
|
||||||
}).fail(function () {
|
},
|
||||||
cb(false);
|
timeout: 2500
|
||||||
});
|
}).fail(function () {
|
||||||
|
cb(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkBridgeResult(reply, usr) {
|
function checkBridgeResult(reply, usr) {
|
||||||
@ -788,6 +791,8 @@ function useGroupId(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function discover_hue_bridges() {
|
async function discover_hue_bridges() {
|
||||||
|
$('#wiz_hue_ipstate').html($.i18n('edt_dev_spec_devices_discovery_inprogress'));
|
||||||
|
$('#wiz_hue_discovered').html("")
|
||||||
const res = await requestLedDeviceDiscovery('philipshue');
|
const res = await requestLedDeviceDiscovery('philipshue');
|
||||||
|
|
||||||
// TODO: error case unhandled
|
// TODO: error case unhandled
|
||||||
@ -796,17 +801,31 @@ async function discover_hue_bridges() {
|
|||||||
const r = res.info;
|
const r = res.info;
|
||||||
|
|
||||||
// Process devices returned by discovery
|
// Process devices returned by discovery
|
||||||
if (r.devices.length == 0)
|
if (r.devices.length == 0) {
|
||||||
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
|
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
|
||||||
|
$('#wiz_hue_discovered').html("")
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
for (const device of r.devices) {
|
for (const device of r.devices) {
|
||||||
console.log("Device:", device);
|
//console.log("Device:", device);
|
||||||
|
if (device && device.ip && device.port) {
|
||||||
|
|
||||||
var ip = device.hostname + ":" + device.port;
|
var ip;
|
||||||
console.log("Host:", ip);
|
if (device.hostname && device.domain) {
|
||||||
|
ip = device.hostname + "." + device.domain + ":" + device.port;
|
||||||
|
} else {
|
||||||
|
ip = device.ip + ":" + device.port;
|
||||||
|
}
|
||||||
|
|
||||||
hueIPs.push({ internalipaddress: ip });
|
if (ip) {
|
||||||
|
|
||||||
|
if (!hueIPs.some(item => item.internalipaddress === ip)) {
|
||||||
|
hueIPs.push({ internalipaddress: ip });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var usr = $('#user').val();
|
var usr = $('#user').val();
|
||||||
if (usr != "") {
|
if (usr != "") {
|
||||||
checkHueBridge(checkUserResult, usr);
|
checkHueBridge(checkUserResult, usr);
|
||||||
@ -884,12 +903,12 @@ function beginWizardHue() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//check if ip is empty/reachable/search for bridge
|
//check if ip is empty/reachable/search for bridge
|
||||||
if (eV("output") == "") {
|
if (eV("host") == "") {
|
||||||
//getHueIPs();
|
//getHueIPs();
|
||||||
discover_hue_bridges();
|
discover_hue_bridges();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var ip = eV("output");
|
var ip = eV("host");
|
||||||
$('#ip').val(ip);
|
$('#ip').val(ip);
|
||||||
hueIPs.unshift({ internalipaddress: ip });
|
hueIPs.unshift({ internalipaddress: ip });
|
||||||
if (usr != "") {
|
if (usr != "") {
|
||||||
@ -954,7 +973,7 @@ function beginWizardHue() {
|
|||||||
|
|
||||||
//Start with a clean configuration
|
//Start with a clean configuration
|
||||||
var d = {};
|
var d = {};
|
||||||
d.output = $('#ip').val();
|
d.host = $('#ip').val();
|
||||||
d.username = $('#user').val();
|
d.username = $('#user').val();
|
||||||
d.type = 'philipshue';
|
d.type = 'philipshue';
|
||||||
d.colorOrder = 'rgb';
|
d.colorOrder = 'rgb';
|
||||||
@ -1534,7 +1553,7 @@ function beginWizardAtmoOrb() {
|
|||||||
configuredLights = configruedOrbIds.split(",").map(Number);
|
configuredLights = configruedOrbIds.split(",").map(Number);
|
||||||
}
|
}
|
||||||
|
|
||||||
var multiCastGroup = conf_editor.getEditor("root.specificOptions.output").getValue();
|
var multiCastGroup = conf_editor.getEditor("root.specificOptions.host").getValue();
|
||||||
var multiCastPort = parseInt(conf_editor.getEditor("root.specificOptions.port").getValue());
|
var multiCastPort = parseInt(conf_editor.getEditor("root.specificOptions.port").getValue());
|
||||||
|
|
||||||
discover_atmoorb_lights(multiCastGroup, multiCastPort);
|
discover_atmoorb_lights(multiCastGroup, multiCastPort);
|
||||||
@ -1576,7 +1595,7 @@ function beginWizardAtmoOrb() {
|
|||||||
d.orbIds = finalLights.toString();
|
d.orbIds = finalLights.toString();
|
||||||
d.useOrbSmoothing = (eV("useOrbSmoothing") == true);
|
d.useOrbSmoothing = (eV("useOrbSmoothing") == true);
|
||||||
|
|
||||||
d.output = conf_editor.getEditor("root.specificOptions.output").getValue();
|
d.host = conf_editor.getEditor("root.specificOptions.host").getValue();
|
||||||
d.port = parseInt(conf_editor.getEditor("root.specificOptions.port").getValue());
|
d.port = parseInt(conf_editor.getEditor("root.specificOptions.port").getValue());
|
||||||
d.latchTime = parseInt(conf_editor.getEditor("root.specificOptions.latchTime").getValue());;
|
d.latchTime = parseInt(conf_editor.getEditor("root.specificOptions.latchTime").getValue());;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
// Local Hyperion includes
|
// Local Hyperion includes
|
||||||
#include "ProviderUdpSSL.h"
|
#include "ProviderUdpSSL.h"
|
||||||
|
#include <utils/QStringUtils.h>
|
||||||
|
|
||||||
const int MAX_RETRY = 5;
|
const int MAX_RETRY = 5;
|
||||||
const ushort MAX_PORT_SSL = 65535;
|
const ushort MAX_PORT_SSL = 65535;
|
||||||
@ -73,6 +74,10 @@ bool ProviderUdpSSL::init(const QJsonObject &deviceConfig)
|
|||||||
if( deviceConfig.contains("hs_attempts") ) _handshake_attempts = deviceConfig["hs_attempts"].toInt(5);
|
if( deviceConfig.contains("hs_attempts") ) _handshake_attempts = deviceConfig["hs_attempts"].toInt(5);
|
||||||
|
|
||||||
QString host = deviceConfig["host"].toString(_defaultHost);
|
QString host = deviceConfig["host"].toString(_defaultHost);
|
||||||
|
//Split hostname from API-port in case given
|
||||||
|
QStringList addressparts = QStringUtils::split(host, ":", QStringUtils::SplitBehavior::SkipEmptyParts);
|
||||||
|
QString udpHost = addressparts[0];
|
||||||
|
|
||||||
QStringList debugLevels = QStringList() << "No Debug" << "Error" << "State Change" << "Informational" << "Verbose";
|
QStringList debugLevels = QStringList() << "No Debug" << "Error" << "State Change" << "Informational" << "Verbose";
|
||||||
|
|
||||||
configLog( "SSL Streamer Debug", "%s", ( _debugStreamer ) ? "yes" : "no" );
|
configLog( "SSL Streamer Debug", "%s", ( _debugStreamer ) ? "yes" : "no" );
|
||||||
@ -91,24 +96,24 @@ bool ProviderUdpSSL::init(const QJsonObject &deviceConfig)
|
|||||||
configLog( "SSL Handshake Timeout max", "%d", _handshake_timeout_max );
|
configLog( "SSL Handshake Timeout max", "%d", _handshake_timeout_max );
|
||||||
configLog( "SSL Handshake attempts", "%d", _handshake_attempts );
|
configLog( "SSL Handshake attempts", "%d", _handshake_attempts );
|
||||||
|
|
||||||
if ( _address.setAddress(host) )
|
if ( _address.setAddress(udpHost) )
|
||||||
{
|
{
|
||||||
Debug( _log, "Successfully parsed %s as an ip address.", QSTRING_CSTR( host ) );
|
Debug( _log, "Successfully parsed %s as an ip address.", QSTRING_CSTR(udpHost) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug( _log, "Failed to parse [%s] as an ip address.", QSTRING_CSTR( host ) );
|
Debug( _log, "Failed to parse [%s] as an ip address.", QSTRING_CSTR(udpHost) );
|
||||||
QHostInfo info = QHostInfo::fromName(host);
|
QHostInfo info = QHostInfo::fromName(udpHost);
|
||||||
if ( info.addresses().isEmpty() )
|
if ( info.addresses().isEmpty() )
|
||||||
{
|
{
|
||||||
Debug( _log, "Failed to parse [%s] as a hostname.", QSTRING_CSTR( host ) );
|
Debug( _log, "Failed to parse [%s] as a hostname.", QSTRING_CSTR(udpHost) );
|
||||||
QString errortext = QString("Invalid target address [%1]!").arg(host);
|
QString errortext = QString("Invalid target address [%1]!").arg(host);
|
||||||
this->setInError( errortext );
|
this->setInError( errortext );
|
||||||
isInitOK = false;
|
isInitOK = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug( _log, "Successfully parsed %s as a hostname.", QSTRING_CSTR( host ) );
|
Debug( _log, "Successfully parsed %s as a hostname.", QSTRING_CSTR(udpHost) );
|
||||||
_address = info.addresses().first();
|
_address = info.addresses().first();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user