mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 11:02:12 +01:00
Added support for Tilt Only motors. Improved RTV protocol detection.
This commit is contained in:
parent
e7a95545b0
commit
fe2f50ab9f
7 changed files with 115 additions and 32 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
#ifndef configsettings_h
|
#ifndef configsettings_h
|
||||||
#define configsettings_h
|
#define configsettings_h
|
||||||
|
|
||||||
#define FW_VERSION "v2.1.2"
|
#define FW_VERSION "v2.1.3"
|
||||||
enum DeviceStatus {
|
enum DeviceStatus {
|
||||||
DS_OK = 0,
|
DS_OK = 0,
|
||||||
DS_ERROR = 1,
|
DS_ERROR = 1,
|
||||||
|
|
|
||||||
99
Somfy.cpp
99
Somfy.cpp
|
|
@ -125,7 +125,8 @@ void somfy_frame_t::decodeFrame(byte* frame) {
|
||||||
if(this->cmd == somfy_commands::StepDown)
|
if(this->cmd == somfy_commands::StepDown)
|
||||||
this->cmd = (somfy_commands)((decoded[1] >> 4) | ((decoded[8] & 0x08) << 4));
|
this->cmd = (somfy_commands)((decoded[1] >> 4) | ((decoded[8] & 0x08) << 4));
|
||||||
if(this->cmd == somfy_commands::RTWProto) {
|
if(this->cmd == somfy_commands::RTWProto) {
|
||||||
this->proto = radio_proto::RTW;
|
this->proto = this->encKey > 142 ? radio_proto::RTV : radio_proto::RTW;
|
||||||
|
|
||||||
switch(this->encKey) {
|
switch(this->encKey) {
|
||||||
case 149:
|
case 149:
|
||||||
case 133:
|
case 133:
|
||||||
|
|
@ -338,6 +339,7 @@ void somfy_frame_t::encodeFrame(byte *frame) {
|
||||||
break;
|
break;
|
||||||
case somfy_commands::Prog:
|
case somfy_commands::Prog:
|
||||||
frame[0] = 156;
|
frame[0] = 156;
|
||||||
|
frame[1] = 0xFD;
|
||||||
break;
|
break;
|
||||||
case somfy_commands::SunFlag:
|
case somfy_commands::SunFlag:
|
||||||
frame[0] = 157;
|
frame[0] = 157;
|
||||||
|
|
@ -1684,6 +1686,10 @@ void SomfyShade::processInternalCommand(somfy_commands cmd, uint8_t repeat) {
|
||||||
else
|
else
|
||||||
this->target = 0.0f;
|
this->target = 0.0f;
|
||||||
}
|
}
|
||||||
|
else if(this->tiltType == tilt_types::tiltonly) {
|
||||||
|
this->currentPos = this->target = 100.0f; // We are always 100% with this.
|
||||||
|
this->tiltTarget = 0.0f;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
this->target = this->tiltTarget = 0.0f;
|
this->target = this->tiltTarget = 0.0f;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1695,6 +1701,10 @@ void SomfyShade::processInternalCommand(somfy_commands cmd, uint8_t repeat) {
|
||||||
else
|
else
|
||||||
this->target = 100.0f;
|
this->target = 100.0f;
|
||||||
}
|
}
|
||||||
|
else if(this->tiltType == tilt_types::tiltonly) {
|
||||||
|
this->currentPos = this->target = 100.0f;
|
||||||
|
this->tiltTarget = 100.0f;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
this->target = 100.0f;
|
this->target = 100.0f;
|
||||||
if(this->tiltType != tilt_types::none) this->tiltTarget = 100.0f;
|
if(this->tiltType != tilt_types::none) this->tiltTarget = 100.0f;
|
||||||
|
|
@ -1703,11 +1713,13 @@ void SomfyShade::processInternalCommand(somfy_commands cmd, uint8_t repeat) {
|
||||||
break;
|
break;
|
||||||
case somfy_commands::My:
|
case somfy_commands::My:
|
||||||
if(this->isIdle()) {
|
if(this->isIdle()) {
|
||||||
if(this->myTiltPos >= 0.0f && this->myTiltPos >= 100.0f) this->tiltTarget = this->myTiltPos;
|
Serial.printf("Shade #%d is idle\n", this->getShadeId());
|
||||||
if(this->myPos >= 0.0f && this->myPos <= 100.0f) this->target = this->myPos;
|
if(this->myTiltPos >= 0.0f && this->myTiltPos <= 100.0f) this->tiltTarget = this->myTiltPos;
|
||||||
|
if(this->myPos >= 0.0f && this->myPos <= 100.0f && this->tiltType != tilt_types::tiltonly) this->target = this->myPos;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this->target = this->currentPos;
|
if(this->tiltType == tilt_types::tiltonly) this->currentPos = this->target = 100.0f;
|
||||||
|
else this->target = this->currentPos;
|
||||||
this->tiltTarget = this->currentTiltPos;
|
this->tiltTarget = this->currentTiltPos;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1719,6 +1731,10 @@ void SomfyShade::processInternalCommand(somfy_commands cmd, uint8_t repeat) {
|
||||||
if(this->tiltTime == 0 || this->stepSize == 0) return;
|
if(this->tiltTime == 0 || this->stepSize == 0) return;
|
||||||
this->tiltTarget = max(0.0f, this->currentTiltPos - (100.0f/(static_cast<float>(this->tiltTime/static_cast<float>(this->stepSize)))));
|
this->tiltTarget = max(0.0f, this->currentTiltPos - (100.0f/(static_cast<float>(this->tiltTime/static_cast<float>(this->stepSize)))));
|
||||||
}
|
}
|
||||||
|
else if(this->tiltType == tilt_types::tiltonly) {
|
||||||
|
if(this->tiltTime == 0 || this->stepSize == 0 || this->currentTiltPos <= 0.0f) return;
|
||||||
|
this->tiltTarget = max(0.0f, this->currentTiltPos - (100.0f/(static_cast<float>(this->tiltTime/static_cast<float>(this->stepSize)))));
|
||||||
|
}
|
||||||
else if(this->currentPos > 0.0f) {
|
else if(this->currentPos > 0.0f) {
|
||||||
if(this->downTime == 0 || this->stepSize == 0) return;
|
if(this->downTime == 0 || this->stepSize == 0) return;
|
||||||
this->target = max(0.0f, this->currentPos - (100.0f/(static_cast<float>(this->upTime/static_cast<float>(this->stepSize)))));
|
this->target = max(0.0f, this->currentPos - (100.0f/(static_cast<float>(this->upTime/static_cast<float>(this->stepSize)))));
|
||||||
|
|
@ -1733,6 +1749,10 @@ void SomfyShade::processInternalCommand(somfy_commands cmd, uint8_t repeat) {
|
||||||
if(this->tiltTime == 0 || this->stepSize == 0) return;
|
if(this->tiltTime == 0 || this->stepSize == 0) return;
|
||||||
this->tiltTarget = min(100.0f, this->currentTiltPos + (100.0f/(static_cast<float>(this->tiltTime/static_cast<float>(this->stepSize)))));
|
this->tiltTarget = min(100.0f, this->currentTiltPos + (100.0f/(static_cast<float>(this->tiltTime/static_cast<float>(this->stepSize)))));
|
||||||
}
|
}
|
||||||
|
else if(this->tiltType == tilt_types::tiltonly) {
|
||||||
|
if(this->tiltTime == 0 || this->stepSize == 0 || this->currentTiltPos >= 100.0f) return;
|
||||||
|
this->tiltTarget = min(100.0f, this->currentTiltPos + (100.0f/(static_cast<float>(this->tiltTime/static_cast<float>(this->stepSize)))));
|
||||||
|
}
|
||||||
else if(this->currentPos < 100.0f) {
|
else if(this->currentPos < 100.0f) {
|
||||||
if(this->downTime == 0 || this->stepSize == 0) return;
|
if(this->downTime == 0 || this->stepSize == 0) return;
|
||||||
this->target = min(100.0f, this->currentPos + (100.0f/(static_cast<float>(this->downTime/static_cast<float>(this->stepSize)))));
|
this->target = min(100.0f, this->currentPos + (100.0f/(static_cast<float>(this->downTime/static_cast<float>(this->stepSize)))));
|
||||||
|
|
@ -1809,9 +1829,39 @@ void SomfyShade::setMovement(int8_t dir) {
|
||||||
}
|
}
|
||||||
void SomfyShade::setMyPosition(int8_t pos, int8_t tilt) {
|
void SomfyShade::setMyPosition(int8_t pos, int8_t tilt) {
|
||||||
if(!this->isIdle()) return; // Don't do this if it is moving.
|
if(!this->isIdle()) return; // Don't do this if it is moving.
|
||||||
if(this->tiltType != tilt_types::none) {
|
if(this->tiltType == tilt_types::tiltonly) {
|
||||||
|
this->myPos = 100.0f;
|
||||||
|
if(tilt != floor(this->currentTiltPos)) {
|
||||||
|
this->settingMyPos = true;
|
||||||
|
if(tilt == floor(this->myTiltPos))
|
||||||
|
this->moveToMyPosition();
|
||||||
|
else
|
||||||
|
this->moveToTarget(100, tilt);
|
||||||
|
}
|
||||||
|
else if(tilt == floor(this->myTiltPos)) {
|
||||||
|
// Of so we need to clear the my position. These motors are finicky so send
|
||||||
|
// a my command to ensure we are actually at the my position then send the clear
|
||||||
|
// command. There really is no other way to do this.
|
||||||
|
if(this->currentTiltPos != this->myTiltPos) {
|
||||||
|
this->settingMyPos = true;
|
||||||
|
this->moveToMyPosition();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SomfyRemote::sendCommand(somfy_commands::My, this->repeats);
|
||||||
|
this->settingPos = false;
|
||||||
|
this->settingMyPos = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SomfyRemote::sendCommand(somfy_commands::My, SETMY_REPEATS);
|
||||||
|
this->myTiltPos = this->currentTiltPos;
|
||||||
|
}
|
||||||
|
this->commitMyPosition();
|
||||||
|
this->emitState();
|
||||||
|
}
|
||||||
|
else if(this->tiltType != tilt_types::none) {
|
||||||
if(tilt < 0) tilt = 0;
|
if(tilt < 0) tilt = 0;
|
||||||
if(pos != floor(this->currentPos) || tilt != floor(currentTiltPos)) {
|
if(pos != floor(this->currentPos) || tilt != floor(this->currentTiltPos)) {
|
||||||
this->settingMyPos = true;
|
this->settingMyPos = true;
|
||||||
if(pos == floor(this->myPos) && tilt == floor(this->myTiltPos))
|
if(pos == floor(this->myPos) && tilt == floor(this->myTiltPos))
|
||||||
this->moveToMyPosition();
|
this->moveToMyPosition();
|
||||||
|
|
@ -1873,6 +1923,7 @@ void SomfyShade::setMyPosition(int8_t pos, int8_t tilt) {
|
||||||
}
|
}
|
||||||
void SomfyShade::moveToMyPosition() {
|
void SomfyShade::moveToMyPosition() {
|
||||||
if(!this->isIdle()) return;
|
if(!this->isIdle()) return;
|
||||||
|
if(this->tiltType == tilt_types::tiltonly) this->currentPos = this->myPos = 100.0f;
|
||||||
if(this->currentPos == this->myPos) {
|
if(this->currentPos == this->myPos) {
|
||||||
if(this->tiltType != tilt_types::none) {
|
if(this->tiltType != tilt_types::none) {
|
||||||
if(this->currentTiltPos == this->myTiltPos) return; // Nothing to see here since we are already here.
|
if(this->currentTiltPos == this->myTiltPos) return; // Nothing to see here since we are already here.
|
||||||
|
|
@ -1881,6 +1932,7 @@ void SomfyShade::moveToMyPosition() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this->myPos == -1 && (this->tiltType == tilt_types::none || this->myTiltPos == -1)) return;
|
if(this->myPos == -1 && (this->tiltType == tilt_types::none || this->myTiltPos == -1)) return;
|
||||||
|
/*
|
||||||
Serial.print("Seeking my Position:");
|
Serial.print("Seeking my Position:");
|
||||||
Serial.print(this->myPos);
|
Serial.print(this->myPos);
|
||||||
Serial.print("% ");
|
Serial.print("% ");
|
||||||
|
|
@ -1892,7 +1944,8 @@ void SomfyShade::moveToMyPosition() {
|
||||||
Serial.print("% using ");
|
Serial.print("% using ");
|
||||||
Serial.print(translateSomfyCommand(somfy_commands::My));
|
Serial.print(translateSomfyCommand(somfy_commands::My));
|
||||||
Serial.println(this->direction);
|
Serial.println(this->direction);
|
||||||
if(this->myPos >= 0.0f && this->myPos <= 100.0f) this->target = this->myPos;
|
*/
|
||||||
|
if(this->tiltType != tilt_types::tiltonly && this->myPos >= 0.0f && this->myPos <= 100.0f) this->target = this->myPos;
|
||||||
if(this->myTiltPos >= 0.0f && this->myTiltPos <= 100.0f) this->tiltTarget = this->myTiltPos;
|
if(this->myTiltPos >= 0.0f && this->myTiltPos <= 100.0f) this->tiltTarget = this->myTiltPos;
|
||||||
this->settingPos = false;
|
this->settingPos = false;
|
||||||
SomfyRemote::sendCommand(somfy_commands::My, this->repeats);
|
SomfyRemote::sendCommand(somfy_commands::My, this->repeats);
|
||||||
|
|
@ -1904,12 +1957,14 @@ void SomfyShade::sendCommand(somfy_commands cmd, uint8_t repeat) {
|
||||||
if(this->bitLength == 0) this->bitLength = somfy.transceiver.config.type;
|
if(this->bitLength == 0) this->bitLength = somfy.transceiver.config.type;
|
||||||
if(cmd == somfy_commands::Up) {
|
if(cmd == somfy_commands::Up) {
|
||||||
SomfyRemote::sendCommand(cmd, repeat);
|
SomfyRemote::sendCommand(cmd, repeat);
|
||||||
this->target = 0.0f;
|
if(this->tiltType != tilt_types::tiltonly) this->target = 0.0f;
|
||||||
|
else this->tiltTarget = 0.0f;
|
||||||
if(this->tiltType == tilt_types::integrated) this->tiltTarget = 0.0f;
|
if(this->tiltType == tilt_types::integrated) this->tiltTarget = 0.0f;
|
||||||
}
|
}
|
||||||
else if(cmd == somfy_commands::Down) {
|
else if(cmd == somfy_commands::Down) {
|
||||||
SomfyRemote::sendCommand(cmd, repeat);
|
SomfyRemote::sendCommand(cmd, repeat);
|
||||||
this->target = 100.0f;
|
if(this->tiltType != tilt_types::tiltonly) this->target = 100.0f;
|
||||||
|
else this->tiltTarget = 100.0f;
|
||||||
if(this->tiltType == tilt_types::integrated) this->tiltTarget = 100.0f;
|
if(this->tiltType == tilt_types::integrated) this->tiltTarget = 100.0f;
|
||||||
}
|
}
|
||||||
else if(cmd == somfy_commands::My) {
|
else if(cmd == somfy_commands::My) {
|
||||||
|
|
@ -1919,7 +1974,7 @@ void SomfyShade::sendCommand(somfy_commands cmd, uint8_t repeat) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SomfyRemote::sendCommand(cmd, repeat);
|
SomfyRemote::sendCommand(cmd, repeat);
|
||||||
this->target = this->currentPos;
|
if(this->tiltType != tilt_types::tiltonly) this->target = this->currentPos;
|
||||||
this->tiltTarget = this->currentTiltPos;
|
this->tiltTarget = this->currentTiltPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1997,14 +2052,22 @@ void SomfyShade::moveToTiltTarget(float target) {
|
||||||
}
|
}
|
||||||
void SomfyShade::moveToTarget(float pos, float tilt) {
|
void SomfyShade::moveToTarget(float pos, float tilt) {
|
||||||
somfy_commands cmd = somfy_commands::My;
|
somfy_commands cmd = somfy_commands::My;
|
||||||
if(pos < this->currentPos)
|
if(this->tiltType == tilt_types::tiltonly) {
|
||||||
cmd = somfy_commands::Up;
|
this->currentPos = this->target = 100.0f;
|
||||||
else if(pos > this->currentPos)
|
pos = 100;
|
||||||
cmd = somfy_commands::Down;
|
if(tilt < this->currentTiltPos) cmd = somfy_commands::Up;
|
||||||
else if(tilt >= 0 && tilt < this->currentTiltPos)
|
else if(tilt > this->currentTiltPos) cmd = somfy_commands::Down;
|
||||||
cmd = somfy_commands::Up;
|
}
|
||||||
else if(tilt >= 0 && tilt > this->currentTiltPos)
|
else {
|
||||||
cmd = somfy_commands::Down;
|
if(pos < this->currentPos)
|
||||||
|
cmd = somfy_commands::Up;
|
||||||
|
else if(pos > this->currentPos)
|
||||||
|
cmd = somfy_commands::Down;
|
||||||
|
else if(tilt >= 0 && tilt < this->currentTiltPos)
|
||||||
|
cmd = somfy_commands::Up;
|
||||||
|
else if(tilt >= 0 && tilt > this->currentTiltPos)
|
||||||
|
cmd = somfy_commands::Down;
|
||||||
|
}
|
||||||
if(cmd != somfy_commands::My) {
|
if(cmd != somfy_commands::My) {
|
||||||
Serial.print("Moving to ");
|
Serial.print("Moving to ");
|
||||||
Serial.print(pos);
|
Serial.print(pos);
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
2.1.2
|
2.1.3
|
||||||
|
|
@ -333,7 +333,7 @@
|
||||||
<input id="fldShadeName" name="shadeName" data-bind="name" type="text" length=20 placeholder="Name">
|
<input id="fldShadeName" name="shadeName" data-bind="name" type="text" length=20 placeholder="Name">
|
||||||
<label for="fldShadeName">Name</label>
|
<label for="fldShadeName">Name</label>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top:-10px;">
|
<div id="divLiftSettings" style="margin-top:-10px;">
|
||||||
<div class="field-group" style="display:inline-block;max-width:127px;margin-right:17px;margin-top:-10px;">
|
<div class="field-group" style="display:inline-block;max-width:127px;margin-right:17px;margin-top:-10px;">
|
||||||
<input id="fldShadeUpTime" name="shadeUpTime" data-bind="upTime" data-datatype="int" type="number" length=5 placeholder="milliseconds" style="width:100%;text-align:right;" />
|
<input id="fldShadeUpTime" name="shadeUpTime" data-bind="upTime" data-datatype="int" type="number" length=5 placeholder="milliseconds" style="width:100%;text-align:right;" />
|
||||||
<label for="fldShadeUpTime">Up Time (ms)</label>
|
<label for="fldShadeUpTime">Up Time (ms)</label>
|
||||||
|
|
@ -349,6 +349,7 @@
|
||||||
<option value="0">None</option>
|
<option value="0">None</option>
|
||||||
<option value="1">Tilt Motor</option>
|
<option value="1">Tilt Motor</option>
|
||||||
<option value="2">Integrated</option>
|
<option value="2">Integrated</option>
|
||||||
|
<option value="3">Tilt Only</option>
|
||||||
</select>
|
</select>
|
||||||
<label for="selTiltType" style="cursor:pointer;">Tilt Type</label>
|
<label for="selTiltType" style="cursor:pointer;">Tilt Type</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1197,7 +1197,7 @@ var security = new Security();
|
||||||
|
|
||||||
class General {
|
class General {
|
||||||
initialized = false;
|
initialized = false;
|
||||||
appVersion = 'v2.1.2';
|
appVersion = 'v2.1.3';
|
||||||
reloadApp = false;
|
reloadApp = false;
|
||||||
init() {
|
init() {
|
||||||
if (this.initialized) return;
|
if (this.initialized) return;
|
||||||
|
|
@ -1971,8 +1971,12 @@ class Somfy {
|
||||||
divCtl += `<div class="shade-name">`;
|
divCtl += `<div class="shade-name">`;
|
||||||
|
|
||||||
divCtl += `<span class="shadectl-name">${shade.name}</span>`;
|
divCtl += `<span class="shadectl-name">${shade.name}</span>`;
|
||||||
divCtl += `<span class="shadectl-mypos"><label>My: </label><span id="spanMyPos">${shade.myPos > 0 ? shade.myPos + '%' : '---'}</span>`;
|
if (shade.tiltType === 3)
|
||||||
if (shade.myTiltPos > 0) divCtl += `<label> Tilt: </label><span id="spanMyTiltPos">${shade.myTiltPos > 0 ? shade.myTiltPos + '%' : '---'}</span>`;
|
divCtl += `<span class="shadectl-mypos"><label>My Tilt: </label><span id="spanMyTiltPos">${shade.myTiltPos > 0 ? shade.myTiltPos + '%' : '---'}</span>`
|
||||||
|
else {
|
||||||
|
divCtl += `<span class="shadectl-mypos"><label>My: </label><span id="spanMyPos">${shade.myPos > 0 ? shade.myPos + '%' : '---'}</span>`;
|
||||||
|
if (shade.myTiltPos > 0 && shade.tiltType !== 3) divCtl += `<label> Tilt: </label><span id="spanMyTiltPos">${shade.myTiltPos > 0 ? shade.myTiltPos + '%' : '---'}</span>`;
|
||||||
|
}
|
||||||
divCtl += '</div>';
|
divCtl += '</div>';
|
||||||
|
|
||||||
divCtl += `<div class="shadectl-buttons">`;
|
divCtl += `<div class="shadectl-buttons">`;
|
||||||
|
|
@ -2148,13 +2152,15 @@ class Somfy {
|
||||||
let elname = shade.querySelector(`.shadectl-name`);
|
let elname = shade.querySelector(`.shadectl-name`);
|
||||||
let shadeName = elname.innerHTML;
|
let shadeName = elname.innerHTML;
|
||||||
let html = `<div class="shade-name"><span>${shadeName}</span><div style="float:right;vertical-align:top;cursor:pointer;font-size:12px;margin-top:4px;">`;
|
let html = `<div class="shade-name"><span>${shadeName}</span><div style="float:right;vertical-align:top;cursor:pointer;font-size:12px;margin-top:4px;">`;
|
||||||
if (myPos >= 0)
|
if (myPos >= 0 && tiltType !== 3)
|
||||||
html += `<div onclick="document.getElementById('slidShadeTarget').value = ${myPos}; document.getElementById('slidShadeTarget').dispatchEvent(new Event('change'));"><span style="display:inline-block;width:47px;">Current:</span><span>${myPos}</span><span>%</span></div>`;
|
html += `<div onclick="document.getElementById('slidShadeTarget').value = ${myPos}; document.getElementById('slidShadeTarget').dispatchEvent(new Event('change'));"><span style="display:inline-block;width:47px;">Current:</span><span>${myPos}</span><span>%</span></div>`;
|
||||||
if (myTiltPos >= 0 && tiltType > 0)
|
if (myTiltPos >= 0 && tiltType > 0)
|
||||||
html += `<div onclick="document.getElementById('slidShadeTiltTarget').value = ${myTiltPos}; document.getElementById('slidShadeTarget').dispatchEvent(new Event('change'));"><span style="display:inline-block;width:47px;">Tilt:</span><span>${myTiltPos}</span><span>%</span></div>`;
|
html += `<div onclick="document.getElementById('slidShadeTiltTarget').value = ${myTiltPos}; document.getElementById('slidShadeTarget').dispatchEvent(new Event('change'));"><span style="display:inline-block;width:47px;">Tilt:</span><span>${myTiltPos}</span><span>%</span></div>`;
|
||||||
html += `</div></div >`;
|
html += `</div></div>`;
|
||||||
|
html += `<div id="divShadeTarget">`
|
||||||
html += `<input id="slidShadeTarget" name="shadeTarget" type="range" min="0" max="100" step="1" oninput="document.getElementById('spanShadeTarget').innerHTML = this.value;" />`;
|
html += `<input id="slidShadeTarget" name="shadeTarget" type="range" min="0" max="100" step="1" oninput="document.getElementById('spanShadeTarget').innerHTML = this.value;" />`;
|
||||||
html += `<label for="slidShadeTarget"><span>Target Position </span><span><span id="spanShadeTarget" class="shade-target">${currPos}</span><span>%</span></span></label>`;
|
html += `<label for="slidShadeTarget"><span>Target Position </span><span><span id="spanShadeTarget" class="shade-target">${currPos}</span><span>%</span></span></label>`;
|
||||||
|
html += `</div>`
|
||||||
html += '<div id="divTiltTarget" style="display:none;">';
|
html += '<div id="divTiltTarget" style="display:none;">';
|
||||||
html += `<input id="slidShadeTiltTarget" name="shadeTiltTarget" type="range" min="0" max="100" step="1" oninput="document.getElementById('spanShadeTiltTarget').innerHTML = this.value;" />`;
|
html += `<input id="slidShadeTiltTarget" name="shadeTiltTarget" type="range" min="0" max="100" step="1" oninput="document.getElementById('spanShadeTiltTarget').innerHTML = this.value;" />`;
|
||||||
html += `<label for="slidShadeTiltTarget"><span>Target Tilt </span><span><span id="spanShadeTiltTarget" class="shade-target">${currTiltPos}</span><span>%</span></span></label>`;
|
html += `<label for="slidShadeTiltTarget"><span>Target Tilt </span><span><span id="spanShadeTiltTarget" class="shade-target">${currTiltPos}</span><span>%</span></span></label>`;
|
||||||
|
|
@ -2175,11 +2181,19 @@ class Somfy {
|
||||||
elTarget.value = currPos;
|
elTarget.value = currPos;
|
||||||
elTiltTarget.value = currTiltPos;
|
elTiltTarget.value = currTiltPos;
|
||||||
let elBtn = div.querySelector('button#btnSetMyPosition');
|
let elBtn = div.querySelector('button#btnSetMyPosition');
|
||||||
if (tiltType > 0) div.querySelector('div#divTiltTarget').style.display = '';
|
if (tiltType === 3) {
|
||||||
|
div.querySelector('div#divTiltTarget').style.display = '';
|
||||||
|
div.querySelector('div#divShadeTarget').style.display = 'none';
|
||||||
|
}
|
||||||
|
else if (tiltType > 0) div.querySelector('div#divTiltTarget').style.display = '';
|
||||||
let fnProcessChange = () => {
|
let fnProcessChange = () => {
|
||||||
let pos = parseInt(elTarget.value, 10);
|
let pos = parseInt(elTarget.value, 10);
|
||||||
let tilt = parseInt(elTiltTarget.value, 10);
|
let tilt = parseInt(elTiltTarget.value, 10);
|
||||||
if (pos === myPos && (tiltType === 0 || tilt === myTiltPos)) {
|
if (tiltType === 3 && tilt === myTiltPos) {
|
||||||
|
elBtn.innerHTML = 'Clear My Position';
|
||||||
|
elBtn.style.background = 'orangered';
|
||||||
|
}
|
||||||
|
else if (pos === myPos && (tiltType === 0 || tilt === myTiltPos)) {
|
||||||
elBtn.innerHTML = 'Clear My Position';
|
elBtn.innerHTML = 'Clear My Position';
|
||||||
elBtn.style.background = 'orangered';
|
elBtn.style.background = 'orangered';
|
||||||
}
|
}
|
||||||
|
|
@ -2415,6 +2429,7 @@ class Somfy {
|
||||||
if (ico.classList.contains('icss-window-blind')) ico.classList.remove('icss-window-blind');
|
if (ico.classList.contains('icss-window-blind')) ico.classList.remove('icss-window-blind');
|
||||||
if (ico.classList.contains('icss-shutter')) ico.classList.remove('icss-shutter');
|
if (ico.classList.contains('icss-shutter')) ico.classList.remove('icss-shutter');
|
||||||
if (!ico.classList.contains('icss-awning')) ico.classList.add('icss-awning');
|
if (!ico.classList.contains('icss-awning')) ico.classList.add('icss-awning');
|
||||||
|
tilt = false;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
document.getElementById('divTiltSettings').style.display = 'none';
|
document.getElementById('divTiltSettings').style.display = 'none';
|
||||||
|
|
@ -2422,6 +2437,7 @@ class Somfy {
|
||||||
if (ico.classList.contains('icss-window-blind')) ico.classList.remove('icss-window-blind');
|
if (ico.classList.contains('icss-window-blind')) ico.classList.remove('icss-window-blind');
|
||||||
if (ico.classList.contains('icss-awning')) ico.classList.remove('icss-awning');
|
if (ico.classList.contains('icss-awning')) ico.classList.remove('icss-awning');
|
||||||
if (!ico.classList.contains('icss-shutter')) ico.classList.add('icss-shutter');
|
if (!ico.classList.contains('icss-shutter')) ico.classList.add('icss-shutter');
|
||||||
|
tilt = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -2434,6 +2450,7 @@ class Somfy {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
document.getElementById('fldTiltTime').parentElement.style.display = tilt ? 'inline-block' : 'none';
|
document.getElementById('fldTiltTime').parentElement.style.display = tilt ? 'inline-block' : 'none';
|
||||||
|
document.getElementById('divLiftSettings').style.display = tilt === 3 ? 'none' : '';
|
||||||
document.querySelector('#divSomfyButtons i.icss-window-tilt').style.display = tilt ? '' : 'none';
|
document.querySelector('#divSomfyButtons i.icss-window-tilt').style.display = tilt ? '' : 'none';
|
||||||
}
|
}
|
||||||
onShadeBitLengthChanged(el) {
|
onShadeBitLengthChanged(el) {
|
||||||
|
|
@ -3220,14 +3237,16 @@ class Somfy {
|
||||||
console.log('Closing shade positioner');
|
console.log('Closing shade positioner');
|
||||||
ctls[i].remove();
|
ctls[i].remove();
|
||||||
}
|
}
|
||||||
|
let tiltType = parseInt(shade.getAttribute('data-tilt'), 10) || 0;
|
||||||
let currPos = parseInt(shade.getAttribute('data-target'), 0);
|
let currPos = parseInt(shade.getAttribute('data-target'), 0);
|
||||||
let elname = shade.querySelector(`.shadectl-name`);
|
let elname = shade.querySelector(`.shadectl-name`);
|
||||||
let shadeName = elname.innerHTML;
|
let shadeName = elname.innerHTML;
|
||||||
let html = `<div class="shade-name">${shadeName}</div>`;
|
let html = `<div class="shade-name">${shadeName}</div>`;
|
||||||
html += `<input id="slidShadeTarget" name="shadeTarget" type="range" min="0" max="100" step="1" value="${currPos}" onchange="somfy.processShadeTarget(this, ${shadeId});" oninput="document.getElementById('spanShadeTarget').innerHTML = this.value;" />`;
|
if (tiltType !== 3) {
|
||||||
html += `<label for="slidShadeTarget"><span>Target Position </span><span><span id="spanShadeTarget" class="shade-target">${currPos}</span><span>%</span></span></label>`;
|
html += `<input id="slidShadeTarget" name="shadeTarget" type="range" min="0" max="100" step="1" value="${currPos}" onchange="somfy.processShadeTarget(this, ${shadeId});" oninput="document.getElementById('spanShadeTarget').innerHTML = this.value;" />`;
|
||||||
if (makeBool(shade.getAttribute('data-tilt'))) {
|
html += `<label for="slidShadeTarget"><span>Target Position </span><span><span id="spanShadeTarget" class="shade-target">${currPos}</span><span>%</span></span></label>`;
|
||||||
|
}
|
||||||
|
if (tiltType > 0) {
|
||||||
let currTiltPos = parseInt(shade.getAttribute('data-tilttarget'), 10);
|
let currTiltPos = parseInt(shade.getAttribute('data-tilttarget'), 10);
|
||||||
html += `<input id="slidShadeTiltTarget" name="shadeTarget" type="range" min="0" max="100" step="1" value="${currTiltPos}" onchange="somfy.processShadeTiltTarget(this, ${shadeId});" oninput="document.getElementById('spanShadeTiltTarget').innerHTML = this.value;" />`;
|
html += `<input id="slidShadeTiltTarget" name="shadeTarget" type="range" min="0" max="100" step="1" value="${currTiltPos}" onchange="somfy.processShadeTiltTarget(this, ${shadeId});" oninput="document.getElementById('spanShadeTiltTarget').innerHTML = this.value;" />`;
|
||||||
html += `<label for="slidShadeTiltTarget"><span>Target Tilt Position </span><span><span id="spanShadeTiltTarget" class="shade-tilt-target">${currTiltPos}</span><span>%</span></span></label>`;
|
html += `<label for="slidShadeTiltTarget"><span>Target Tilt Position </span><span><span id="spanShadeTiltTarget" class="shade-tilt-target">${currTiltPos}</span><span>%</span></span></label>`;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue