Skip to content

Commit

Permalink
(simatec) Fix Sunprotect End-Delay
Browse files Browse the repository at this point in the history
  • Loading branch information
simatec committed Jun 20, 2024
1 parent 3995b34 commit d5462a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ When the adapter crashes or an other Code error happens, this error message that

## Changelog
<!-- ### __WORK IN PROGRESS__ -->
### __WORK IN PROGRESS__
* (simatec) Fix Sunprotect End-Delay

### 1.7.2 (2024-06-20)
* (simatec) Fix Shutterstate enabled

Expand Down
23 changes: 8 additions & 15 deletions lib/sunProtect.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,8 @@ async function sunProtect(adapter, elevation, azimuth, shutterSettings) {
adapter.log.debug('#1 Started sunprotect end delay for ' + shutterSettings[s].shutterName);
shutterSettings[s].sunProtectEndtimerid = setTimeout(async function () {
shutterSettings[s].sunProtectEndtimerid = '0';
}, shutterSettings[s].sunProtectEndDely * 60000, i);
}, shutterSettings[s].sunProtectEndDely * 60000, s);
}

if (insideTemp < parseFloat(hysteresisInside) || (parseFloat(hysteresisOutside) > outsideTemp || shutterSettings[s].lightSensor != '' && parseFloat(hysteresisLight) > sunLight && shutterSettings[s].sunProtectEndtimerid === '0') || (parseFloat(hysteresisOutside) > outsideTemp && shutterSettings[s].lightSensor == '')) {

if (pendingAlarm == false) {
Expand Down Expand Up @@ -295,9 +294,8 @@ async function sunProtect(adapter, elevation, azimuth, shutterSettings) {
adapter.log.debug('#2 Started sunprotect end delay for ' + shutterSettings[s].shutterName);
shutterSettings[s].sunProtectEndtimerid = setTimeout(async function () {
shutterSettings[s].sunProtectEndtimerid = '0';
}, shutterSettings[s].sunProtectEndDely * 60000, i);
}, shutterSettings[s].sunProtectEndDely * 60000, s);
}

if (insideTemp < parseFloat(hysteresisInside) || (parseFloat(hysteresisOutside) > outsideTemp || shutterSettings[s].lightSensor != '' && parseFloat(hysteresisLight) > sunLight && shutterSettings[s].sunProtectEndtimerid === '0') || (parseFloat(hysteresisOutside) > outsideTemp && shutterSettings[s].lightSensor == '')) {

if (pendingAlarm == false) {
Expand Down Expand Up @@ -473,10 +471,9 @@ async function sunProtect(adapter, elevation, azimuth, shutterSettings) {
adapter.log.debug('#3 Started sunprotect end delay for ' + shutterSettings[s].shutterName);
shutterSettings[s].sunProtectEndtimerid = setTimeout(async function () {
shutterSettings[s].sunProtectEndtimerid = '0';
}, shutterSettings[s].sunProtectEndDely * 60000, i);
}, shutterSettings[s].sunProtectEndDely * 60000, s);
}


if (insideTemp < parseFloat(hysteresisInside) || (resultDirectionRangePlus) < azimuth || (parseFloat(hysteresisOutside) > outsideTemp || shutterSettings[s].lightSensor != '' && parseFloat(hysteresisLight) > sunLight && shutterSettings[s].sunProtectEndtimerid === '0') || (parseFloat(hysteresisOutside) > outsideTemp && shutterSettings[s].lightSensor == '')) {

if (pendingAlarm == false) {
Expand Down Expand Up @@ -527,9 +524,8 @@ async function sunProtect(adapter, elevation, azimuth, shutterSettings) {
adapter.log.debug('#4 Started sunprotect end delay for ' + shutterSettings[s].shutterName);
shutterSettings[s].sunProtectEndtimerid = setTimeout(async function () {
shutterSettings[s].sunProtectEndtimerid = '0';
}, shutterSettings[s].sunProtectEndDely * 60000, i);
}, shutterSettings[s].sunProtectEndDely * 60000, s);
}

if (insideTemp < parseFloat(hysteresisInside) || (resultDirectionRangePlus) < azimuth || (parseFloat(hysteresisOutside) > outsideTemp || shutterSettings[s].lightSensor != '' && parseFloat(hysteresisLight) > sunLight && shutterSettings[s].sunProtectEndtimerid === '0') || (parseFloat(hysteresisOutside) > outsideTemp && shutterSettings[s].lightSensor == '')) {

if (pendingAlarm == false) {
Expand Down Expand Up @@ -703,7 +699,7 @@ async function sunProtect(adapter, elevation, azimuth, shutterSettings) {
adapter.log.debug('#5 Started sunprotect end delay for ' + shutterSettings[s].shutterName);
shutterSettings[s].sunProtectEndtimerid = setTimeout(async function () {
shutterSettings[s].sunProtectEndtimerid = '0';
}, shutterSettings[s].sunProtectEndDely * 60000, i);
}, shutterSettings[s].sunProtectEndDely * 60000, s);
}

if ((resultDirectionRangePlus) < azimuth || (parseFloat(hysteresisOutside) > outsideTemp || shutterSettings[s].lightSensor != '' && parseFloat(hysteresisLight) > sunLight && shutterSettings[s].sunProtectEndtimerid === '0') || (parseFloat(hysteresisOutside) > outsideTemp && shutterSettings[s].lightSensor == '')) {
Expand Down Expand Up @@ -753,9 +749,8 @@ async function sunProtect(adapter, elevation, azimuth, shutterSettings) {
adapter.log.debug('#6 Started sunprotect end delay for ' + shutterSettings[s].shutterName);
shutterSettings[s].sunProtectEndtimerid = setTimeout(async function () {
shutterSettings[s].sunProtectEndtimerid = '0';
}, shutterSettings[s].sunProtectEndDely * 60000, i);
}, shutterSettings[s].sunProtectEndDely * 60000, s);
}

if ((resultDirectionRangePlus) < azimuth || (parseFloat(hysteresisOutside) > outsideTemp || shutterSettings[s].lightSensor != '' && parseFloat(hysteresisLight) > sunLight && shutterSettings[s].sunProtectEndtimerid === '0') || (parseFloat(hysteresisOutside) > outsideTemp && shutterSettings[s].lightSensor == '')) {
if (pendingAlarm == false) {
const _shutterState = await adapter.getForeignStateAsync(shutterSettings[s].name).catch((e) => adapter.log.warn(e));
Expand Down Expand Up @@ -1081,9 +1076,8 @@ async function sunProtect(adapter, elevation, azimuth, shutterSettings) {
adapter.log.debug('#7 Started sunprotect end delay for ' + shutterSettings[s].shutterName);
shutterSettings[s].sunProtectEndtimerid = setTimeout(async function () {
shutterSettings[s].sunProtectEndtimerid = '0';
}, shutterSettings[s].sunProtectEndDely * 60000, i);
}, shutterSettings[s].sunProtectEndDely * 60000, s);
}

if ((shutterSettings[s].lightSensor != '' && parseFloat(hysteresisLight) > sunLight && shutterSettings[s].sunProtectEndtimerid === '0') || (parseFloat(hysteresisOutside) > outsideTemp)) {
if (pendingAlarm == false) {
const _shutterState = await adapter.getForeignStateAsync(shutterSettings[s].name).catch((e) => adapter.log.warn(e));
Expand Down Expand Up @@ -1132,9 +1126,8 @@ async function sunProtect(adapter, elevation, azimuth, shutterSettings) {
adapter.log.debug('#8 Started sunprotect end delay for ' + shutterSettings[s].shutterName);
shutterSettings[s].sunProtectEndtimerid = setTimeout(async function () {
shutterSettings[s].sunProtectEndtimerid = '0';
}, shutterSettings[s].sunProtectEndDely * 60000, i);
}, shutterSettings[s].sunProtectEndDely * 60000, s);
}

if ((shutterSettings[s].lightSensor != '' && parseFloat(hysteresisLight) > sunLight && shutterSettings[s].sunProtectEndtimerid === '0') || (parseFloat(hysteresisOutside) > outsideTemp)) {
if (pendingAlarm == false) {
const _shutterState = await adapter.getForeignStateAsync(shutterSettings[s].name).catch((e) => adapter.log.warn(e));
Expand Down

0 comments on commit d5462a5

Please sign in to comment.