Skip to content

Commit

Permalink
Merge pull request #74 from Samsung/dev
Browse files Browse the repository at this point in the history
Fix : SmartThings PAT 'location' permission bug
  • Loading branch information
jongsu2 authored Jun 29, 2023
2 parents 78f2ab8 + 33a811e commit cb89ee1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
43 changes: 26 additions & 17 deletions 101-SmartThings.html
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ <h3>Properties</h3>
return locationEl;
}
function createRoomEl(room){
const roomEl = document.querySelector(`.md_list__room[data-location-id="${location.locationId}"][data-room-id="${room.roomId}"]`)|| document.createElement('div');
const roomEl = document.querySelector(`.md_list__room[data-location-id="${room.locationId}"][data-room-id="${room.roomId}"]`)|| document.createElement('div');
Object.assign(roomEl.dataset,{locationId:room.locationId,roomId:room.roomId,name:room.name});
roomEl.className = `md_list__item md_list__room ${room.name==undefined?'md_list__item--unknown':''}`;
roomEl.innerHTML=`<input type="checkbox"> ${room.name} <i class="fa fa-angle-down"></i>`;
Expand Down Expand Up @@ -1216,22 +1216,31 @@ <h3>Properties</h3>
locationEl.append(createRoomEl(room));
})
})
}

mydevice.devices.forEach(function(device){
let locationEl = document.querySelector(`.md_list__location[data-location-id="${device.locationId}"]`);
let roomEl = document.querySelector(`.md_list__room[data-location-id="${device.locationId}"][data-room-id="${device.roomId}"]`);

if(!locationEl){
locationEl = createLocationEl({locationId:device.locationId});
mdContainerEl.append(locationEl);
}
if(!roomEl){
roomEl = createRoomEl({locationID:device.locationId, roomId:device.roomId});
locationEl.append(roomEl);
}
roomEl.append(createDeviceEl(device));
})
mydevice.devices.forEach(function (device) {
let roomEl = document.querySelector(`.md_list__room[data-location-id="${device.locationId}"][data-room-id="${device.roomId}"]`);
roomEl.append(createDeviceEl(device));
});
} else {
let locationIds = [];
let roomIds = [];
mydevice.devices.forEach(function (device) {
let locationEl = document.querySelector(`.md_list__location[data-location-id="${device.locationId}"]`);
let roomEl = document.querySelector(`.md_list__room[data-location-id="${device.locationId}"][data-room-id="${device.roomId}"]`);

if (!locationIds.includes(device.locationId)) {
locationIds.push(device.locationId)
locationEl = createLocationEl({ locationId: device.locationId, name: "undefined" });
mdContainerEl.append(locationEl);
}
if (!roomIds.includes(device.roomId)) {
roomIds.push(device.roomId)
roomEl = createRoomEl({ locationId: device.locationId, roomId: device.roomId, name: "undefined" });
locationEl.append(roomEl);
}

roomEl.append(createDeviceEl(device));
});
}

if(selectedDevices){
selectedDevices.forEach(deviceId=>{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-samsung-automation-studio-nodes",
"version": "1.1.14",
"version": "1.1.15",
"description": "Samsung Automation Studio Nodes for Node-RED",
"keywords": [
"SmartThings",
Expand Down

0 comments on commit cb89ee1

Please sign in to comment.