$(document).on("mapInitFinished", function() {
syncToolbarState(['zoomin', 'zoomout', 'traffic', 'homepoint', 'homerange', 'devicelist']);
$.ajax({
type: "GET",
url: HomeAssistantWebAPIUrl + "/api/states",
beforeSend: function(request) {
request.setRequestHeader("x-ha-access", authToken);
request.setRequestHeader("Authorization", newToken);
},
cache: false,
async: true,
dataType: "json",
success: function (data) {
var idlist = DeviceTrackerIDList.replace("device_tracker.","");
for (var index in data) {
var str = JSON.stringify(data[index].entity_id);
if (str == null)
continue;
if (str.search('device_tracker') == -1)
continue;
var deviceId = data[index].entity_id.replace("device_tracker.", "");
if (idlist != "" && (idlist + ",").indexOf(deviceId) == -1)
continue;
if (data[index].attributes['longitude'] == undefined || data[index].attributes['longitude'] == null)
continue;
insertDeviceList(0, {
//checked: true,
id: deviceId,
name: 'loading...',
state: '---'
});
getDevice(deviceId);
}
}
});
});