Commit b34d8ae3 authored by Jin's avatar Jin

Merge branch 'use-implementation-id' into 'master'

make use of ImplementationId and getVdcs

See merge request !8
parents 35e3bf3f 70b4bd1b
......@@ -19,14 +19,14 @@ var vdc_strings =
var vdc_config =
{
model_uid: "NetAtmo Weather Station",
implementationId: "NetAtmo Weather Station", // was: model_uid
search_intervall_ms: 20000
};
var vdc_render_no_devices = function()
{
$("#device_list").hide();
$("#empty").text("No Netatmo vDCs found, check your addon and package setup.");
$("#empty").text("Error: cannot connect to NetAtmo VDC.");
};
......@@ -307,7 +307,6 @@ var vdc_device_query_callback = function(device, data)
{
var i;
var props = [];
var modeluid = "";
var connected = false;
var username = "";
......@@ -317,11 +316,7 @@ var vdc_device_query_callback = function(device, data)
for (i = 0; i < props.length; i++)
{
var property = props[i];
if (property.name === "modelUID")
{
modeluid = property.value;
}
else if (property.name === "x-netatmo-connection-status")
if (property.name === "x-netatmo-connection-status")
{
connected = property.value;
}
......@@ -331,11 +326,6 @@ var vdc_device_query_callback = function(device, data)
}
}
if (modeluid !== vdc_config.model_uid)
{
return;
}
if (Object.keys(g_vdcs).length === 0)
{
$("#empty").empty();
......@@ -353,7 +343,7 @@ var vdc_search = function()
{
vdc_clear_search_timeout();
// load apartment structure and search for netatmo vdc's
$.getJSON("/json/apartment/getCircuits",
$.getJSON("/json/apartment/getVdcs?implementationId=" + vdc_config.implementationId,
vdc_search_callback).fail(vdc_request_failed).fail(vdc_request_failed);
};
......@@ -457,7 +447,7 @@ var vdc_query_device = function(device, remaining)
$.getJSON("/json/property/vdcquery?query=getProperty(deviceId=" +
device.dSUID +
")/modelUID,x-netatmo-connection-status,x-netatmo-username",
")/x-netatmo-connection-status,x-netatmo-username",
callback).fail(callback);
};
......@@ -470,16 +460,15 @@ var vdc_search_callback = function(data)
try
{
var circuits = data.result.circuits
for (i = 0; i < circuits.length; i++)
var vdcs = data.result.vdcs;
for (i = 0; i < vdcs.length; i++)
{
var circuit = circuits[i];
if ((circuit.isPresent === true) &&
(circuit.isValid === true) &&
(circuit.busMemberType === 33) && // vdc host
(circuit.VdcModelUID === vdc_config.model_uid)) // netatmo vdc
var vdc = vdcs[i];
if ((vdc.isPresent === true) &&
(vdc.isValid === true) &&
(vdc.VdcImplementationId === vdc_config.implementationId)) // my netatmo vdc
{
devices.push(circuits[i]);
devices.push(vdc);
}
}
} catch (err) {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment