diff --git a/tasmota/i18n.h b/tasmota/i18n.h index a1623fe14..ba7e925f8 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -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" diff --git a/tasmota/support.ino b/tasmota/support.ino index e744e1685..ae662ad66 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -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 \ No newline at end of file +#endif // USE_UNISHOX_COMPRESSION diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 31cbcd2c3..05247510b 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -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 diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index b56f00880..96cd9e49c 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -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 diff --git a/tasmota/xdrv_27_shutter.ino b/tasmota/xdrv_27_shutter.ino index 8bf783680..e5a5353f6 100644 --- a/tasmota/xdrv_27_shutter.ino +++ b/tasmota/xdrv_27_shutter.ino @@ -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.