Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
* dark color theme
* info type errors

Tickets: iobroker-community-adapters#5 iobroker-community-adapters#16
  • Loading branch information
oelison committed Oct 16, 2022
1 parent 7dbaab7 commit 50c1e97
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ This is just to provide you an overview of the adapter options.
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
* dark mode fix #5
* log info type error #16

### 1.3.0 (2022-10-14)
* (oelison) remove errors and warnings ocured during deploy
* (oelison) comment for zones added
Expand Down
10 changes: 5 additions & 5 deletions lib/trigger-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ class Trigger {
} else {
this.motionDuration = 0;
}
if (result.row.briThreshold && parseInt(result.row.briThreshold) > 0 && result.row.briStateId && result.row.briStateId.length > 5) {
if (result.row.briThreshold && (parseInt(result.row.briThreshold) > 0) && result.row.briStateId && result.row.briStateId.length > 5) {
this.motionBriStatePath = result.row.briStateId;
this.motionBriThreshold = result.row.briThreshold;
this.motionBriThreshold = parseInt(result.row.briThreshold);
} else {
this.motionBriStatePath = '';
this.motionBriThreshold = 0;
Expand Down Expand Up @@ -188,8 +188,8 @@ class Trigger {
/**
* Prepare: If Motion Sensor triggered - verify brightness if bri is set
*/
if (!this.mimicMotion && this.triggerIsMotion && !this.adapter.x.helper.isLikeEmpty(this.motionBriStatePath) && this.adapter.x.helper.isNumber(this.motionBriThreshold) && parseInt(this.motionBriThreshold) > 0) {

if (!this.mimicMotion && this.triggerIsMotion && !this.adapter.x.helper.isLikeEmpty(this.motionBriStatePath) && this.adapter.x.helper.isNumber(this.motionBriThreshold) && this.motionBriThreshold && (this.motionBriThreshold > 0)) {
if (this.adapter.config.motionIgnoreBriIfZoneOn && this.adapter.x.zonesIsOn[zoneName]) {
// Disregard Brightness if zone is on (if this.adapter.config.motionIgnoreBriIfZoneOn == true)
this.adapter.log.debug(`Trigger [${this.triggerName}] Zone '${zoneName}' is on and new motion detected, therefore, we disregard any current brightness.`);
Expand All @@ -200,7 +200,7 @@ class Trigger {
if (this.adapter.x.helper.isLikeEmpty(briStateValCurrent) || !this.adapter.x.helper.isNumber(briStateValCurrent) || parseInt(briStateValCurrent) < 0) {
// Bri not valid, so disregard bri and continue
this.adapter.log.debug(`Trigger [${this.triggerName}] Brightness of ${briStateValCurrent} of ${this.motionBriStatePath} is not valid. State Value: [${briStateValCurrent}]. Therefore, bri will be disregarded and we continue.`);
} else if (parseInt(briStateValCurrent) < parseInt(this.motionBriThreshold)) {
} else if (parseInt(briStateValCurrent) < this.motionBriThreshold) {
// continue
this.adapter.log.debug(`Trigger [${this.triggerName}] Brightness of ${briStateValCurrent} is < threshold of ${this.motionBriThreshold}, so we continue.`);
} else {
Expand Down
14 changes: 10 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ class SmartControl extends utils.Adapter {
if (!res) {
throw(`Certain error(s) occurred in asyncCreateStates().`);
}

// Delete all states which are no longer used.
const allAdapterStates = await this.getStatesOfAsync('options');
if (allAdapterStates != undefined) {
Expand All @@ -413,7 +412,7 @@ class SmartControl extends utils.Adapter {
if ( (statePathsOnly.indexOf(statePath) == -1) && (statePath.endsWith('active') || (statePath.endsWith('name') ) ) ) {
// State is no longer used.
await this.delObjectAsync(statePath); // Delete state.
this.x.helper.logExtendedInfo(`State '${statePath}' deleted, since option does no longer exist.'`);
this.x.helper.logExtendedInfo(`State ${statePath} deleted, since option does no longer exist.`);
}
}
}
Expand All @@ -429,10 +428,17 @@ class SmartControl extends utils.Adapter {
if(typeof optionObj.row[optionObj.field] == 'object') {
val = JSON.stringify(optionObj.row[optionObj.field]);
} else {
val = optionObj.row[optionObj.field];
if (lpStatePath.endsWith('briThreshold')) {
val = parseInt(optionObj.row[optionObj.field]);
}
else if (lpStatePath.endsWith('duration')) {
val = parseInt(optionObj.row[optionObj.field]);
}
else {
val = optionObj.row[optionObj.field];
}
}
await this.setStateAsync(lpStatePath, {val:val, ack:true});

}

/**
Expand Down

0 comments on commit 50c1e97

Please sign in to comment.