Merge pull request #9135 from stefanbode/patch-16

Added Status13 to support Shutter related information in reports for bugfixing
This commit is contained in:
Theo Arends 2020-08-20 17:13:16 +02:00 committed by GitHub
commit 7691abea41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 11 deletions

View File

@ -224,6 +224,7 @@
#define D_STATUS10_SENSOR "SNS"
#define D_STATUS11_STATUS "STS"
#define D_STATUS12_STATUS "STK"
#define D_STATUS13_SHUTTER "SHT"
#define D_CMND_STATE "State"
#define D_CMND_POWER "Power"
#define D_CMND_FANSPEED "FanSpeed"

View File

@ -117,6 +117,17 @@ String GetResetReason(void)
* Miscellaneous
\*********************************************************************************************/
#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
#define BYTE_TO_BINARY(byte) \
(byte & 0x80 ? '1' : '0'), \
(byte & 0x40 ? '1' : '0'), \
(byte & 0x20 ? '1' : '0'), \
(byte & 0x10 ? '1' : '0'), \
(byte & 0x08 ? '1' : '0'), \
(byte & 0x04 ? '1' : '0'), \
(byte & 0x02 ? '1' : '0'), \
(byte & 0x01 ? '1' : '0')
// Get span until single character in string
size_t strchrspn(const char *str1, int character)
{
@ -1961,4 +1972,4 @@ String Decompress(const char * compressed, size_t uncompressed_size) {
return content;
}
#endif // USE_UNISHOX_COMPRESSION
#endif // USE_UNISHOX_COMPRESSION

View File

@ -573,7 +573,24 @@ void CmndStatus(void)
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "12"));
}
}
#ifdef USE_SHUTTER
if ((0 == payload) || (13 == payload)) {
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS13_SHUTTER "\":"));
for (uint8_t i=0; i < MAX_SHUTTERS; i++)
{
if (Settings.shutter_startrelay[i]==0) break;
if (i>0) ResponseAppend_P(PSTR(","));
ResponseAppend_P(PSTR("{\"" D_STATUS13_SHUTTER "%d\":{\"Relay1\":%d,\"Relay2\":%d,\"Open\":%d,\"Close\":%d,\"50perc\":%d,\"delay\":%d,\"opt\":"BYTE_TO_BINARY_PATTERN",\"calib\":\"%d:%d:%d:%d:%d\"}"), i,
Settings.shutter_startrelay[i],Settings.shutter_startrelay[i]+1,Settings.shutter_opentime[i], Settings.shutter_closetime[i],
Settings.shutter_set50percent[i],Settings.shutter_motordelay[i],BYTE_TO_BINARY(Settings.shutter_options[i]),
Settings.shuttercoeff[0][i], Settings.shuttercoeff[1][i], Settings.shuttercoeff[2][i], Settings.shuttercoeff[3][i], Settings.shuttercoeff[4][i]);
}
ResponseJsonEnd();
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "12"));
}
#endif
#ifdef USE_SCRIPT_STATUS
if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">U",2,mqtt_data);
#endif

View File

@ -142,7 +142,7 @@ const uint32_t SOFT_BAUDRATE = 9600; // Default software serial baudrate
const uint32_t APP_BAUDRATE = 115200; // Default serial baudrate
const uint32_t SERIAL_POLLING = 100; // Serial receive polling in ms
const uint32_t ZIGBEE_POLLING = 100; // Serial receive polling in ms
const uint8_t MAX_STATUS = 12; // Max number of status lines
const uint8_t MAX_STATUS = 13; // Max number of status lines
const uint32_t START_VALID_TIME = 1451602800; // Time is synced and after 2016-01-01

View File

@ -240,14 +240,9 @@ void ShutterInit(void)
Shutter.motordelay[i] = Settings.shutter_motordelay[i];
Shutter.lastdirection[i] = (50 < Settings.shutter_position[i]) ? 1 : -1;
char shutter_open_chr[10];
dtostrfd((float)Shutter.open_time[i] / 10 , 1, shutter_open_chr);
char shutter_close_chr[10];
dtostrfd((float)Shutter.close_time[i] / 10, 1, shutter_close_chr);
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SHT: Shutter %d (Relay:%d): Init. Pos: %d [%d %%], Open Vel.: 100, Close Vel.: %d , Max Way: %d, Opentime %s [s], Closetime %s [s], CoeffCalc: c0: %d, c1 %d, c2: %d, c3: %d, c4: %d, binmask %d, is inverted %d, is locked %d, end stop time enabled %d, webButtons inverted %d, shuttermode %d, motordelay %d"),
i+1, Settings.shutter_startrelay[i], Shutter.real_position[i], Settings.shutter_position[i], Shutter.close_velocity[i], Shutter.open_max[i], shutter_open_chr, shutter_close_chr,
Settings.shuttercoeff[0][i], Settings.shuttercoeff[1][i], Settings.shuttercoeff[2][i], Settings.shuttercoeff[3][i], Settings.shuttercoeff[4][i],
Shutter.mask, (Settings.shutter_options[i]&1) ? 1 : 0, (Settings.shutter_options[i]&2) ? 1 : 0, (Settings.shutter_options[i]&4) ? 1 : 0, (Settings.shutter_options[i]&8) ? 1 : 0, Shutter.mode, Shutter.motordelay[i]);
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SHT%d: Init. Pos: %d,inverted %d, locked %d, end stop time enabled %d, webButtons inverted %d, shuttermode %d"),
i+1, Shutter.real_position[i],
(Settings.shutter_options[i]&1) ? 1 : 0, (Settings.shutter_options[i]&2) ? 1 : 0, (Settings.shutter_options[i]&4) ? 1 : 0, (Settings.shutter_options[i]&8) ? 1 : 0, Shutter.mode);
} else {
// terminate loop at first INVALID shutter.