mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 11:02:12 +01:00
Merge pull request #55 from Noltari/awnings-support
Add initial sun awnings support
This commit is contained in:
commit
a67b8401d5
3 changed files with 30 additions and 3 deletions
21
Somfy.cpp
21
Somfy.cpp
|
|
@ -91,6 +91,8 @@ String translateSomfyCommand(const somfy_commands cmd) {
|
|||
return "Step Up";
|
||||
case somfy_commands::StepDown:
|
||||
return "Step Down";
|
||||
case somfy_commands::Status:
|
||||
return "Status";
|
||||
default:
|
||||
return "Unknown(" + String((uint8_t)cmd) + ")";
|
||||
}
|
||||
|
|
@ -147,6 +149,12 @@ void somfy_frame_t::decodeFrame(byte* frame) {
|
|||
case 140:
|
||||
this->cmd = somfy_commands::Prog;
|
||||
break;
|
||||
case 141:
|
||||
this->cmd = somfy_commands::SunFlag;
|
||||
break;
|
||||
case 142:
|
||||
this->cmd = somfy_commands::Flag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->rollingCode = decoded[3] + (decoded[2] << 8);
|
||||
|
|
@ -167,9 +175,12 @@ void somfy_frame_t::decodeFrame(byte* frame) {
|
|||
case somfy_commands::SunFlag:
|
||||
case somfy_commands::Flag:
|
||||
break;
|
||||
case somfy_commands::Status:
|
||||
this->rollingCode = 0;
|
||||
this->status = decoded[3];
|
||||
break;
|
||||
case somfy_commands::UnknownC:
|
||||
case somfy_commands::UnknownD:
|
||||
case somfy_commands::UnknownE:
|
||||
case somfy_commands::RTWProto:
|
||||
this->valid = false;
|
||||
break;
|
||||
|
|
@ -280,6 +291,12 @@ void somfy_frame_t::encodeFrame(byte *frame) {
|
|||
case somfy_commands::Prog:
|
||||
frame[0] = 140;
|
||||
break;
|
||||
case somfy_commands::SunFlag:
|
||||
frame[0] = 141;
|
||||
break;
|
||||
case somfy_commands::Flag:
|
||||
frame[0] = 142;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -1420,6 +1437,8 @@ bool SomfyShade::fromJSON(JsonObject &obj) {
|
|||
this->shadeType = shade_types::drapery;
|
||||
else if(strncmp(obj["shadeType"].as<const char *>(), "blind", 5) == 0)
|
||||
this->shadeType = shade_types::blind;
|
||||
else if(strncmp(obj["shadeType"].as<const char *>(), "awning", 7) == 0)
|
||||
this->shadeType = shade_types::awning;
|
||||
}
|
||||
else {
|
||||
this->shadeType = static_cast<shade_types>(obj["shadeType"].as<uint8_t>());
|
||||
|
|
|
|||
11
Somfy.h
11
Somfy.h
|
|
@ -28,7 +28,7 @@ enum class somfy_commands : byte {
|
|||
StepDown = 0xB,
|
||||
UnknownC = 0xC,
|
||||
UnknownD = 0xD,
|
||||
UnknownE = 0xE, // This command byte has been witnessed in the wild but cannot tell if it is from Somfy. No rolling code is sent with this and it is 56-bits.
|
||||
Status = 0xE,
|
||||
RTWProto = 0xF, // RTW Protocol
|
||||
// Command extensions for 80 bit frames
|
||||
StepUp = 0x8B
|
||||
|
|
@ -36,7 +36,8 @@ enum class somfy_commands : byte {
|
|||
enum class shade_types : byte {
|
||||
roller = 0x00,
|
||||
blind = 0x01,
|
||||
drapery = 0x02
|
||||
drapery = 0x02,
|
||||
awning = 0x03,
|
||||
};
|
||||
enum class tilt_types : byte {
|
||||
none = 0x00,
|
||||
|
|
@ -93,6 +94,11 @@ typedef struct somfy_tx_queue_t {
|
|||
bool pop(somfy_tx_t *tx);
|
||||
bool push(uint32_t await, somfy_commands cmd, uint8_t repeats);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
no_sun = 0,
|
||||
sun = 2
|
||||
} somfy_status_t;
|
||||
typedef struct somfy_frame_t {
|
||||
bool valid = false;
|
||||
bool processed = false;
|
||||
|
|
@ -109,6 +115,7 @@ typedef struct somfy_frame_t {
|
|||
uint32_t await = 0;
|
||||
uint8_t bitLength = 56;
|
||||
uint16_t pulseCount = 0;
|
||||
somfy_status_t status = no_sun;
|
||||
void print();
|
||||
void encodeFrame(byte *frame);
|
||||
void decodeFrame(byte* frame);
|
||||
|
|
|
|||
|
|
@ -240,6 +240,7 @@
|
|||
<option value="0">Roller Shade</option>
|
||||
<option value="1">Blind</option>
|
||||
<option value="2">Drapery</option>
|
||||
<option value="3">Awning</option>
|
||||
</select>
|
||||
<label for="selShadeType">Type</label>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue