Merge pull request #8728 from ascillato/patch-1

KNX: Add Scene Support
This commit is contained in:
Theo Arends 2020-06-18 20:58:51 +02:00 committed by GitHub
commit 11ee93eaa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 98 additions and 4 deletions

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Подобрена комуникация"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Използвана енергия днес"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Communication Enhancement"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Spotřeba Dnes"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Erweiterte Kommunikation"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Energie heute"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Βελτίωση επικοινωνίας"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Ενέργεια σήμερα"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Communication Enhancement"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Energy Today"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Mejora de Comunicación"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX ESCENA TX"
#define D_KNX_RX_SCENE "KNX ESCENA RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Energía Hoy"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Amélioration de la communication"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX Scène TX"
#define D_KNX_RX_SCENE "KNX Scène RX"
// xsns_03_energy.ino
#define D_ENERGY_TODAY "Énergie aujourd'hui"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "שיפור התקשורת"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "צריכה יומית"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Communication Enhancement"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Mai energia"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Miglioramento comunicazione"
#define D_KNX_TX_SLOT "KNX - TX"
#define D_KNX_RX_SLOT "KNX - RX"
#define D_KNX_TX_SCENE "Scena - TX"
#define D_KNX_RX_SCENE "Scena - RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Energia - oggi"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "커뮤니케이션 강화"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "금일 전력 사용량"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Verbeter verbinding"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Verbruik vandaag"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Rozszerzenia"
#define D_KNX_TX_SLOT "Gniazdo TX"
#define D_KNX_RX_SLOT "Gniazdo RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Energia dzisiaj"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Melhoria da comunicação"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Consumo energético de hoje"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Melhoria de Comunicação"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Consumo energético de hoje"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Îmbunătățire Communicație"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Energia de Azi"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Communication Enhancement"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Энергия Сегодня"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Communication Enhancement"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Spotreba dnes"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Kommuniceringsförbättring"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Energi idag"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Communication Enhancement"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Energy Today"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Підвищення зв'язку"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "Енергія Сьогодні"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "通讯增强"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "今日用电量"

View File

@ -445,6 +445,8 @@
#define D_KNX_ENHANCEMENT "Communication Enhancement"
#define D_KNX_TX_SLOT "KNX TX"
#define D_KNX_RX_SLOT "KNX RX"
#define D_KNX_TX_SCENE "KNX SCENE TX"
#define D_KNX_RX_SCENE "KNX SCENE RX"
// xdrv_03_energy.ino
#define D_ENERGY_TODAY "今日用電量"

View File

@ -203,7 +203,8 @@ const uint32_t LOOP_SLEEP_DELAY = 50; // Lowest number of milliseconds to
#define KNX_SLOT3 28
#define KNX_SLOT4 29
#define KNX_SLOT5 30
#define KNX_MAX_device_param 30
#define KNX_SCENE 31
#define KNX_MAX_device_param 31
#define MAX_KNXTX_CMNDS 5
/*********************************************************************************************\

View File

@ -114,6 +114,7 @@ device_parameters_t device_param[] = {
{ KNX_SLOT3 , false, false, KNX_Empty },
{ KNX_SLOT4 , false, false, KNX_Empty },
{ KNX_SLOT5 , false, false, KNX_Empty },
{ KNX_SCENE , false, false, KNX_Empty },
{ KNX_Empty, false, false, KNX_Empty}
};
@ -149,6 +150,7 @@ const char * device_param_ga[] = {
D_KNX_TX_SLOT " 3",
D_KNX_TX_SLOT " 4",
D_KNX_TX_SLOT " 5",
D_KNX_TX_SCENE ,
nullptr
};
@ -184,6 +186,7 @@ const char *device_param_cb[] = {
D_KNX_RX_SLOT " 3",
D_KNX_RX_SLOT " 4",
D_KNX_RX_SLOT " 5",
D_KNX_RX_SCENE ,
nullptr
};
@ -196,12 +199,14 @@ const char *device_param_cb[] = {
#define D_CMND_KNX_PA "_PA"
#define D_CMND_KNX_GA "_GA"
#define D_CMND_KNX_CB "_CB"
#define D_CMND_KNXTXSCENE "Tx_Scene"
const char kKnxCommands[] PROGMEM = D_PRFX_KNX "|" // Prefix
D_CMND_KNXTXCMND "|" D_CMND_KNXTXVAL "|" D_CMND_KNX_ENABLED "|" D_CMND_KNX_ENHANCED "|" D_CMND_KNX_PA "|" D_CMND_KNX_GA "|" D_CMND_KNX_CB ;
D_CMND_KNXTXCMND "|" D_CMND_KNXTXVAL "|" D_CMND_KNX_ENABLED "|" D_CMND_KNX_ENHANCED "|" D_CMND_KNX_PA "|" D_CMND_KNX_GA "|" D_CMND_KNX_CB "|" D_CMND_KNXTXSCENE ;
void (* const KnxCommand[])(void) PROGMEM = {
&CmndKnxTxCmnd, &CmndKnxTxVal, &CmndKnxEnabled, &CmndKnxEnhanced, &CmndKnxPa, &CmndKnxGa, &CmndKnxCb };
&CmndKnxTxCmnd, &CmndKnxTxVal, &CmndKnxEnabled, &CmndKnxEnhanced, &CmndKnxPa, &CmndKnxGa, &CmndKnxCb, &CmndKnxTxScene };
uint8_t KNX_GA_Search( uint8_t param, uint8_t start = 0 )
{
@ -518,6 +523,7 @@ void KNX_INIT(void)
device_param[KNX_SLOT3-1].show = true;
device_param[KNX_SLOT4-1].show = true;
device_param[KNX_SLOT5-1].show = true;
device_param[KNX_SCENE-1].show = true;
#endif
// Delete from KNX settings all configuration is not anymore related to this device
@ -557,7 +563,11 @@ void KNX_CB_Action(message_t const &msg, void *arg)
if (msg.data_len == 1) {
// COMMAND
sprintf(tempchar,"%d",msg.data[0]);
} else {
} else if (chan->type == KNX_SCENE) {
// VALUE
uint8_t tempvar = knx.data_to_1byte_uint(msg.data);
dtostrfd(tempvar,2,tempchar);
} else {
// VALUE
float tempvar = knx.data_to_2byte_float(msg.data);
dtostrfd(tempvar,2,tempchar);
@ -602,6 +612,18 @@ void KNX_CB_Action(message_t const &msg, void *arg)
}
}
}
else if (chan->type == KNX_SCENE) // KNX RX SCENE SLOT (write command)
{
if (!toggle_inhibit) {
char command[25];
// Value received
snprintf_P(command, sizeof(command), PSTR("event KNX_SCENE=%s"), tempchar);
ExecuteCommand(command, SRC_KNX);
if (Settings.flag.knx_enable_enhancement) {
toggle_inhibit = TOGGLE_INHIBIT_TIME;
}
}
}
#endif
break;
@ -1054,6 +1076,31 @@ void CmndKnxTxVal(void)
}
}
void CmndKnxTxScene(void)
{
if ( (XdrvMailbox.data_len > 0) && Settings.flag.knx_enabled ) {
// XdrvMailbox.payload <- scene number to send
uint8_t i = KNX_GA_Search(KNX_SCENE);
if ( i != KNX_Empty ) {
KNX_addr.value = Settings.knx_GA_addr[i];
uint8_t tempvar = TextToInt(XdrvMailbox.data);
dtostrfd(tempvar,0,XdrvMailbox.data);
knx.write_1byte_uint(KNX_addr, tempvar);
if (Settings.flag.knx_enable_enhancement) {
knx.write_1byte_uint(KNX_addr, tempvar);
knx.write_1byte_uint(KNX_addr, tempvar);
}
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %s " D_SENT_TO " %d.%d.%d"),
device_param_ga[KNX_SCENE-1], XdrvMailbox.data,
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
ResponseCmndIdxChar (XdrvMailbox.data);
}
}
}
void CmndKnxEnabled(void)
{
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) {