mirror of https://github.com/arendst/Tasmota.git
Added Commands KNX_GA and KNX_CB
* Added command KNX_GA so as to setup Group Address to Send Data/Commands Usage: KNX_GA (return the amount of GA configured) KNX_GA 1 (return the configuration of the GA#1 KNX_GAx option, area, line, member (Set the configuration of the GA#x) example: KNX_GA3 1, 2,2,4 For the GA#3, the status of Relay 1 is sent to 2.2.4 * Added command KNX_CB so as to setup Group Address to Receive Data/Commands KNX_CBx option, area, line, member example: KNX_CB2 1, 2,2,4 For the CB#2, listen to 2.2.4 to set the status of the Relay 1 Posible values of the parameter OPTION: 1 - Relay 1 2 - Relay 2 3 - Relay 3 4 - Relay 4 5 - Relay 5 6 - Relay 6 7 - Relay 7 8 - Relay 8 9 - Button 1 10 - Button 2 11 - Button 3 12 - Button 4 13 - Button 5 14 - Button 6 15 - Button 7 16 - Button 8 17 - TEMPERATURE 18 - HUMIDITY 19 - ENERGY_VOLTAGE 20 - ENERGY_CURRENT 21 - ENERGY_POWER 22 - ENERGY_POWERFACTOR 23 - ENERGY_DAILY 24 - ENERGY_START 25 - ENERGY_TOTAL 26 - KNX_SLOT1 27 - KNX_SLOT2 28 - KNX_SLOT3 29 - KNX_SLOT4 30 - KNX_SLOT5 255 - EMPTY
This commit is contained in:
parent
a294a9179d
commit
3373fff9eb
|
@ -199,9 +199,12 @@ const char *device_param_cb[] = {
|
||||||
#define D_CMND_KNX_ENABLED "Knx_Enabled"
|
#define D_CMND_KNX_ENABLED "Knx_Enabled"
|
||||||
#define D_CMND_KNX_ENHANCED "Knx_Enhanced"
|
#define D_CMND_KNX_ENHANCED "Knx_Enhanced"
|
||||||
#define D_CMND_KNX_PA "Knx_PA"
|
#define D_CMND_KNX_PA "Knx_PA"
|
||||||
enum KnxCommands { CMND_KNXTXCMND, CMND_KNXTXVAL, CMND_KNX_ENABLED, CMND_KNX_ENHANCED, CMND_KNX_PA } ;
|
#define D_CMND_KNX_GA "Knx_GA"
|
||||||
|
#define D_CMND_KNX_CB "Knx_CB"
|
||||||
|
enum KnxCommands { CMND_KNXTXCMND, CMND_KNXTXVAL, CMND_KNX_ENABLED, CMND_KNX_ENHANCED, CMND_KNX_PA,
|
||||||
|
CMND_KNX_GA, CMND_KNX_CB } ;
|
||||||
const char kKnxCommands[] PROGMEM = D_CMND_KNXTXCMND "|" D_CMND_KNXTXVAL "|" D_CMND_KNX_ENABLED "|"
|
const char kKnxCommands[] PROGMEM = D_CMND_KNXTXCMND "|" D_CMND_KNXTXVAL "|" D_CMND_KNX_ENABLED "|"
|
||||||
D_CMND_KNX_ENHANCED "|" D_CMND_KNX_PA ;
|
D_CMND_KNX_ENHANCED "|" D_CMND_KNX_PA "|" D_CMND_KNX_GA "|" D_CMND_KNX_CB ;
|
||||||
|
|
||||||
byte KNX_GA_Search( byte param, byte start = 0 )
|
byte KNX_GA_Search( byte param, byte start = 0 )
|
||||||
{
|
{
|
||||||
|
@ -1153,6 +1156,104 @@ boolean KnxCommand()
|
||||||
command, KNX_addr.pa.area, KNX_addr.pa.line, KNX_addr.pa.member );
|
command, KNX_addr.pa.area, KNX_addr.pa.line, KNX_addr.pa.member );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if ((CMND_KNX_GA == command_code) && (index > 0) && (index <= MAX_KNX_GA)) {
|
||||||
|
if (XdrvMailbox.data_len) {
|
||||||
|
if (strstr(XdrvMailbox.data, ",")) { // Process parameter entry
|
||||||
|
char sub_string[XdrvMailbox.data_len +1];
|
||||||
|
|
||||||
|
int ga_option = atoi(subStr(sub_string, XdrvMailbox.data, ",", 1));
|
||||||
|
int ga_area = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
|
||||||
|
int ga_line = atoi(subStr(sub_string, XdrvMailbox.data, ",", 3));
|
||||||
|
int ga_member = atoi(subStr(sub_string, XdrvMailbox.data, ",", 4));
|
||||||
|
|
||||||
|
if ( ((ga_area == 0) && (ga_line == 0) && (ga_member == 0))
|
||||||
|
|| (ga_area > 31) || (ga_line > 7) || (ga_member > 255)
|
||||||
|
|| (ga_option < 0) || ((ga_option > KNX_MAX_device_param ) && (ga_option != KNX_Empty))
|
||||||
|
|| (!device_param[ga_option-1].show) ) {
|
||||||
|
snprintf_P (mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"" D_ERROR "\"}"), command );
|
||||||
|
return true;
|
||||||
|
} // Invalid command
|
||||||
|
|
||||||
|
KNX_addr.ga.area = ga_area;
|
||||||
|
KNX_addr.ga.line = ga_line;
|
||||||
|
KNX_addr.ga.member = ga_member;
|
||||||
|
|
||||||
|
if ( index > Settings.knx_GA_registered ) {
|
||||||
|
Settings.knx_GA_registered ++;
|
||||||
|
index = Settings.knx_GA_registered;
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings.knx_GA_addr[index -1] = KNX_addr.value;
|
||||||
|
Settings.knx_GA_param[index -1] = ga_option;
|
||||||
|
} else {
|
||||||
|
if ( (XdrvMailbox.payload <= Settings.knx_GA_registered) && (XdrvMailbox.payload > 0) ) {
|
||||||
|
index = XdrvMailbox.payload;
|
||||||
|
} else {
|
||||||
|
snprintf_P (mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"" D_ERROR "\"}"), command );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( index <= Settings.knx_GA_registered ) {
|
||||||
|
KNX_addr.value = Settings.knx_GA_addr[index -1];
|
||||||
|
snprintf_P (mqtt_data, sizeof(mqtt_data), PSTR("{\"%s%d\":\"%s, %d/%d/%d\"}"),
|
||||||
|
command, index, device_param_ga[Settings.knx_GA_param[index-1]-1],
|
||||||
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
snprintf_P (mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"%d\"}"),
|
||||||
|
command, Settings.knx_GA_registered );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ((CMND_KNX_CB == command_code) && (index > 0) && (index <= MAX_KNX_CB)) {
|
||||||
|
if (XdrvMailbox.data_len) {
|
||||||
|
if (strstr(XdrvMailbox.data, ",")) { // Process parameter entry
|
||||||
|
char sub_string[XdrvMailbox.data_len +1];
|
||||||
|
|
||||||
|
int cb_option = atoi(subStr(sub_string, XdrvMailbox.data, ",", 1));
|
||||||
|
int cb_area = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
|
||||||
|
int cb_line = atoi(subStr(sub_string, XdrvMailbox.data, ",", 3));
|
||||||
|
int cb_member = atoi(subStr(sub_string, XdrvMailbox.data, ",", 4));
|
||||||
|
|
||||||
|
if ( ((cb_area == 0) && (cb_line == 0) && (cb_member == 0))
|
||||||
|
|| (cb_area > 31) || (cb_line > 7) || (cb_member > 255)
|
||||||
|
|| (cb_option < 0) || ((cb_option > KNX_MAX_device_param ) && (cb_option != KNX_Empty))
|
||||||
|
|| (!device_param[cb_option-1].show) ) {
|
||||||
|
snprintf_P (mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"" D_ERROR "\"}"), command );
|
||||||
|
return true;
|
||||||
|
} // Invalid command
|
||||||
|
|
||||||
|
KNX_addr.ga.area = cb_area;
|
||||||
|
KNX_addr.ga.line = cb_line;
|
||||||
|
KNX_addr.ga.member = cb_member;
|
||||||
|
|
||||||
|
if ( index > Settings.knx_CB_registered ) {
|
||||||
|
Settings.knx_CB_registered ++;
|
||||||
|
index = Settings.knx_CB_registered;
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings.knx_CB_addr[index -1] = KNX_addr.value;
|
||||||
|
Settings.knx_CB_param[index -1] = cb_option;
|
||||||
|
} else {
|
||||||
|
if ( (XdrvMailbox.payload <= Settings.knx_CB_registered) && (XdrvMailbox.payload > 0) ) {
|
||||||
|
index = XdrvMailbox.payload;
|
||||||
|
} else {
|
||||||
|
snprintf_P (mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"" D_ERROR "\"}"), command );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( index <= Settings.knx_CB_registered ) {
|
||||||
|
KNX_addr.value = Settings.knx_CB_addr[index -1];
|
||||||
|
snprintf_P (mqtt_data, sizeof(mqtt_data), PSTR("{\"%s%d\":\"%s, %d/%d/%d\"}"),
|
||||||
|
command, index, device_param_cb[Settings.knx_CB_param[index-1]-1],
|
||||||
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
snprintf_P (mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"%d\"}"),
|
||||||
|
command, Settings.knx_CB_registered );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else { return false; } // Incomplete command
|
else { return false; } // Incomplete command
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue