mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
fix: turn a group's sun flag on, not off, for MQTT sunFlag 1
groups/+/sunFlag/set sent Flag for 1 and SunFlag for 0, the opposite of the shade topic. SunFlag turns the flag on. Both topics now take the command from sunFlagCommand() so they can't drift apart again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b51292889f
commit
d85b3d30c8
4 changed files with 11 additions and 6 deletions
|
|
@ -127,8 +127,7 @@ void MQTTClass::receive(const char *topic, byte*payload, uint32_t length) {
|
||||||
shade->setMyPosition(shade->myPos, val);
|
shade->setMyPosition(shade->myPos, val);
|
||||||
}
|
}
|
||||||
else if(strncmp(command, "sunFlag", sizeof(command)) == 0) {
|
else if(strncmp(command, "sunFlag", sizeof(command)) == 0) {
|
||||||
if(val > 0) shade->sendCommand(somfy_commands::SunFlag);
|
shade->sendCommand(sunFlagCommand(val > 0));
|
||||||
else shade->sendCommand(somfy_commands::Flag);
|
|
||||||
}
|
}
|
||||||
else if(strncmp(command, "position", sizeof(command)) == 0) {
|
else if(strncmp(command, "position", sizeof(command)) == 0) {
|
||||||
if(val >= 0 && val <= 100) {
|
if(val >= 0 && val <= 100) {
|
||||||
|
|
@ -164,10 +163,7 @@ void MQTTClass::receive(const char *topic, byte*payload, uint32_t length) {
|
||||||
group->sendCommand(somfy_commands::My);
|
group->sendCommand(somfy_commands::My);
|
||||||
}
|
}
|
||||||
else if(strncmp(command, "sunFlag", sizeof(command)) == 0) {
|
else if(strncmp(command, "sunFlag", sizeof(command)) == 0) {
|
||||||
if(val > 0)
|
group->sendCommand(sunFlagCommand(val > 0));
|
||||||
group->sendCommand(somfy_commands::Flag);
|
|
||||||
else
|
|
||||||
group->sendCommand(somfy_commands::SunFlag);
|
|
||||||
}
|
}
|
||||||
else if(strncmp(command, "sunny", sizeof(command)) == 0) {
|
else if(strncmp(command, "sunny", sizeof(command)) == 0) {
|
||||||
if(val >= 0) group->sendSensorCommand(-1, val, group->repeats);
|
if(val >= 0) group->sendSensorCommand(-1, val, group->repeats);
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ somfy_commands flipCommand(somfy_commands cmd) {
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
somfy_commands sunFlagCommand(bool on) { return on ? somfy_commands::SunFlag : somfy_commands::Flag; }
|
||||||
byte somfy_frame_t::calc80Checksum(byte b0, byte b1, byte b2) {
|
byte somfy_frame_t::calc80Checksum(byte b0, byte b1, byte b2) {
|
||||||
byte cs80 = 0;
|
byte cs80 = 0;
|
||||||
cs80 = (((b0 & 0xF0) >> 4) ^ ((b1 & 0xF0) >> 4));
|
cs80 = (((b0 & 0xF0) >> 4) ^ ((b1 & 0xF0) >> 4));
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ String translateSomfyCommand(const somfy_commands cmd);
|
||||||
somfy_commands translateSomfyCommand(const String& string);
|
somfy_commands translateSomfyCommand(const String& string);
|
||||||
// The command with up and down swapped, for motors wired the other way round.
|
// The command with up and down swapped, for motors wired the other way round.
|
||||||
somfy_commands flipCommand(somfy_commands cmd);
|
somfy_commands flipCommand(somfy_commands cmd);
|
||||||
|
// The command that turns the sun flag on (SunFlag) or off (Flag).
|
||||||
|
somfy_commands sunFlagCommand(bool on);
|
||||||
|
|
||||||
struct somfy_rx_t;
|
struct somfy_rx_t;
|
||||||
struct somfy_frame_t {
|
struct somfy_frame_t {
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,11 @@ static void test_command_names_round_trip() {
|
||||||
}
|
}
|
||||||
TEST_ASSERT_EQUAL_STRING_MESSAGE("", failed.c_str(), "These names don't parse back to their command");
|
TEST_ASSERT_EQUAL_STRING_MESSAGE("", failed.c_str(), "These names don't parse back to their command");
|
||||||
}
|
}
|
||||||
|
static void test_sun_flag_command() {
|
||||||
|
// sunFlag/set 1 must turn the flag on for shades and groups alike.
|
||||||
|
TEST_ASSERT_EQUAL_UINT8((uint8_t)somfy_commands::SunFlag, (uint8_t)sunFlagCommand(true));
|
||||||
|
TEST_ASSERT_EQUAL_UINT8((uint8_t)somfy_commands::Flag, (uint8_t)sunFlagCommand(false));
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
(void)argc;
|
(void)argc;
|
||||||
|
|
@ -262,5 +267,6 @@ int main(int argc, char **argv) {
|
||||||
RUN_TEST(test_parse_command_names);
|
RUN_TEST(test_parse_command_names);
|
||||||
RUN_TEST(test_command_display_names);
|
RUN_TEST(test_command_display_names);
|
||||||
RUN_TEST(test_command_names_round_trip);
|
RUN_TEST(test_command_names_round_trip);
|
||||||
|
RUN_TEST(test_sun_flag_command);
|
||||||
return UNITY_END();
|
return UNITY_END();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue