Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
NebzHB authored Jan 28, 2024
1 parent 1b7a571 commit a4127cf
Showing 1 changed file with 21 additions and 33 deletions.
54 changes: 21 additions & 33 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6364,9 +6364,9 @@ JeedomBridgedAccessory.prototype.initAccessory = function(newAccessory) {
// -- services : services to be added
// -- Return : nothing
JeedomBridgedAccessory.prototype.addServices = function(newAccessory,services,cachedValues) {
var service;
let service;
try {
var cachedValue, characteristic;
let cachedValue, characteristic;
for (var s = 0; s < services.length; s++) {
service = services[s];

Expand Down Expand Up @@ -6412,24 +6412,23 @@ JeedomBridgedAccessory.prototype.addServices = function(newAccessory,services,ca
// -- accessory : accessory to delete the services from
// -- Return : nothing
JeedomBridgedAccessory.prototype.delServices = function(accessory) {
var service;
let service;
try {
const serviceList=[];
const cachedValues=[];
for(var t=0; t< accessory.services.length;t++) {
if(accessory.services[t].UUID != Service.AccessoryInformation.UUID &&
accessory.services[t].UUID != Service.BridgingState.UUID) {
serviceList.push(accessory.services[t]);
}
}
for(service of serviceList){ // dont work in one loop or with temp object :(
this.log('debug',' Suppression service :'+service.displayName+' subtype:'+service.subtype+' UUID:'+service.UUID);
for (const c of service.characteristics) {
this.log('debug',' Caractéristique :'+c.displayName+' valeur cache:'+c.value);
cachedValues[service.subtype+c.displayName]=c.value;
}
const cachedValues = [];
const serviceList = accessory.services.filter((svc) =>

Check failure on line 6418 in index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Mixed spaces and tabs

Check failure on line 6418 in index.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Mixed spaces and tabs

Check failure on line 6418 in index.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Mixed spaces and tabs
svc.UUID !== Service.AccessoryInformation.UUID &&

Check failure on line 6419 in index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected no linebreak before this expression

Check failure on line 6419 in index.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected no linebreak before this expression

Check failure on line 6419 in index.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Expected no linebreak before this expression
svc.UUID !== Service.BridgingState.UUID
);

Check failure on line 6421 in index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Mixed spaces and tabs

Check failure on line 6421 in index.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Mixed spaces and tabs

Check failure on line 6421 in index.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Mixed spaces and tabs

serviceList.forEach((svc) => {

Check failure on line 6423 in index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Mixed spaces and tabs

Check failure on line 6423 in index.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Mixed spaces and tabs

Check failure on line 6423 in index.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Mixed spaces and tabs
service=svc;
this.log('debug', ' Suppression service :' + service.displayName + ' subtype:' + service.subtype + ' UUID:' + service.UUID);
service.characteristics.forEach((c) => {
this.log('debug', ' Caractéristique :' + c.displayName + ' valeur cache:' + c.value);
cachedValues[service.subtype + c.displayName] = c.value;
});
accessory.removeService(service);
}
});

Check failure on line 6431 in index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Mixed spaces and tabs

Check failure on line 6431 in index.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Mixed spaces and tabs

Check failure on line 6431 in index.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Mixed spaces and tabs
return cachedValues;
}
catch(e){
Expand Down Expand Up @@ -6473,7 +6472,7 @@ function hexToB(h) {
// -- h : html color string
// -- Return : numeric value of html color
function cutHex(h) {
return (h.charAt(0) == '#') ? h.substring(1, 7) : h;
return h.charAt(0) === '#' ? h.substring(1, 7) : h;
}

// -- rgbToHex
Expand All @@ -6493,12 +6492,7 @@ function rgbToHex(R, G, B) {
// -- n : number
// -- Return : hex value
function toHex(n) {
n = parseInt(n, 10);
if (isNaN(n)) {
return '00';
}
n = Math.max(0, Math.min(n, 255));
return '0123456789ABCDEF'.charAt((n - n % 16) / 16) + '0123456789ABCDEF'.charAt(n % 16);
return parseInt(n,10).toString(16).padStart(2, '0');
}

// -- HSVtoRGB
Expand Down Expand Up @@ -6612,12 +6606,6 @@ function RGBtoHSV(r, g, b) {
// -- Params --
// -- id : id to find
// -- Return : Object found
function findMyID(obj,id) {
for(const o in obj) {
// if( obj.hasOwnProperty( o ) && obj[o] && obj[o].id && parseInt(obj[o].id) && parseInt(id) && parseInt(obj[o].id)==parseInt(id)) {
if( obj.hasOwnProperty( o ) && obj[o] && obj[o].id && obj[o].id==id) {
return obj[o];
}
}
return -1;
function findMyID(obj, id) {
return Object.values(obj).find(item => item && item.id == id) || -1;

Check failure on line 6610 in index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected parentheses around arrow function argument

Check failure on line 6610 in index.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected parentheses around arrow function argument

Check failure on line 6610 in index.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Expected parentheses around arrow function argument
}

0 comments on commit a4127cf

Please sign in to comment.