2018-04-18 16:28:45 +01:00
|
|
|
/*
|
2019-10-27 10:13:24 +00:00
|
|
|
xdrv_11_knx.ino - KNX IP Protocol support for Tasmota
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2021-01-01 12:44:04 +00:00
|
|
|
Copyright (C) 2021 Adrian Scillato (https://github.com/ascillato)
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef USE_KNX
|
|
|
|
/*********************************************************************************************\
|
|
|
|
* KNX support
|
|
|
|
*
|
|
|
|
* Using libraries:
|
2018-04-19 19:27:57 +01:00
|
|
|
* ESP KNX IP library (https://github.com/envy/esp-knx-ip)
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2019-11-03 14:37:33 +00:00
|
|
|
Constants in tasmota.h
|
2018-04-18 16:28:45 +01:00
|
|
|
-----------------------
|
|
|
|
|
|
|
|
#define MAX_KNX_GA 10 Max number of KNX Group Addresses to read that can be set
|
|
|
|
#define MAX_KNX_CB 10 Max number of KNX Group Addresses to write that can be set
|
|
|
|
If you change MAX_KNX_CB you also have to change on the esp-knx-ip.h file the following:
|
|
|
|
#define MAX_CALLBACK_ASSIGNMENTS 10
|
|
|
|
#define MAX_CALLBACKS 10
|
|
|
|
Both to MAX_KNX_CB
|
|
|
|
|
|
|
|
Variables in settings.h
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
bool Settings.flag.knx_enabled Enable/Disable KNX Protocol
|
|
|
|
uint16_t Settings.knx_physsical_addr Physical KNX address of this device
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t Settings.knx_GA_registered Number of group address to read
|
|
|
|
uint8_t Settings.knx_CB_registered Number of group address to write
|
2018-04-18 16:28:45 +01:00
|
|
|
uint16_t Settings.knx_GA_addr[MAX_KNX_GA] Group address to read
|
|
|
|
uint16_t Settings.knx_CB_addr[MAX_KNX_CB] Group address to write
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t Settings.knx_GA_param[MAX_KNX_GA] Type of Input (relay changed, button pressed, sensor read)
|
|
|
|
uint8_t Settings.knx_CB_param[MAX_KNX_CB] Type of Output (set relay, toggle relay, reply sensor value)
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2018-11-07 09:30:03 +00:00
|
|
|
#define XDRV_11 11
|
|
|
|
|
2018-05-18 23:57:16 +01:00
|
|
|
#include <esp-knx-ip.h> // KNX Library
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
address_t KNX_physs_addr; // Physical KNX address of this device
|
|
|
|
address_t KNX_addr; // KNX Address converter variable
|
|
|
|
|
|
|
|
#define KNX_Empty 255
|
2018-05-17 05:46:10 +01:00
|
|
|
|
2018-05-18 23:57:16 +01:00
|
|
|
#define TOGGLE_INHIBIT_TIME 15 // 15*50mseg = 750mseg (inhibit time for not toggling again relays by a KNX toggle command)
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
float last_temp;
|
|
|
|
float last_hum;
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t toggle_inhibit;
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
typedef struct __device_parameters
|
|
|
|
{
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t type; // PARAMETER_ID. Used as type of GA = relay, button, sensor, etc, (INPUTS)
|
2018-04-18 16:28:45 +01:00
|
|
|
// used when an action on device triggers a MSG to send on KNX
|
|
|
|
// Needed because this is the value that the ESP_KNX_IP library will pass as parameter
|
|
|
|
// to identify the action to perform when a MSG is received
|
|
|
|
|
|
|
|
bool show; // HARDWARE related. to identify if the parameter exists on the device.
|
|
|
|
|
|
|
|
bool last_state; // LAST_STATE of relays
|
|
|
|
|
|
|
|
callback_id_t CB_id; // ACTION_ID. To store the ID value of Registered_CB to the library.
|
|
|
|
// The ESP_KNX_IP requires to register the callbacks, and then, to assign an address to the registered callback
|
|
|
|
// So CB_id is needed to store the ID of the callback to then, assign multiple addresses to the same ID (callback)
|
|
|
|
// It is used as type of CB = set relay, toggle relay, reply sensor, etc, (OUTPUTS)
|
|
|
|
// used when a MSG receive KNX triggers an action on the device
|
|
|
|
// - Multiples address to the same callback (i.e. Set Relay 1 Status) are used on scenes for example
|
|
|
|
} device_parameters_t;
|
|
|
|
|
|
|
|
// device parameters (information that can be sent)
|
|
|
|
device_parameters_t device_param[] = {
|
|
|
|
{ 1, false, false, KNX_Empty }, // device_param[ 0] = Relay 1
|
|
|
|
{ 2, false, false, KNX_Empty }, // device_param[ 1] = Relay 2
|
|
|
|
{ 3, false, false, KNX_Empty }, // device_param[ 2] = Relay 3
|
|
|
|
{ 4, false, false, KNX_Empty }, // device_param[ 3] = Relay 4
|
|
|
|
{ 5, false, false, KNX_Empty }, // device_param[ 4] = Relay 5
|
|
|
|
{ 6, false, false, KNX_Empty }, // device_param[ 5] = Relay 6
|
|
|
|
{ 7, false, false, KNX_Empty }, // device_param[ 6] = Relay 7
|
|
|
|
{ 8, false, false, KNX_Empty }, // device_param[ 7] = Relay 8
|
|
|
|
{ 9, false, false, KNX_Empty }, // device_param[ 8] = Button 1
|
|
|
|
{ 10, false, false, KNX_Empty }, // device_param[ 9] = Button 2
|
|
|
|
{ 11, false, false, KNX_Empty }, // device_param[10] = Button 3
|
|
|
|
{ 12, false, false, KNX_Empty }, // device_param[11] = Button 4
|
|
|
|
{ 13, false, false, KNX_Empty }, // device_param[12] = Button 5
|
|
|
|
{ 14, false, false, KNX_Empty }, // device_param[13] = Button 6
|
|
|
|
{ 15, false, false, KNX_Empty }, // device_param[14] = Button 7
|
|
|
|
{ 16, false, false, KNX_Empty }, // device_param[15] = Button 8
|
|
|
|
{ KNX_TEMPERATURE, false, false, KNX_Empty }, // device_param[16] = Temperature
|
|
|
|
{ KNX_HUMIDITY , false, false, KNX_Empty }, // device_param[17] = humidity
|
2018-05-17 05:46:10 +01:00
|
|
|
{ KNX_ENERGY_VOLTAGE , false, false, KNX_Empty },
|
|
|
|
{ KNX_ENERGY_CURRENT , false, false, KNX_Empty },
|
|
|
|
{ KNX_ENERGY_POWER , false, false, KNX_Empty },
|
|
|
|
{ KNX_ENERGY_POWERFACTOR , false, false, KNX_Empty },
|
|
|
|
{ KNX_ENERGY_DAILY , false, false, KNX_Empty },
|
|
|
|
{ KNX_ENERGY_START , false, false, KNX_Empty },
|
|
|
|
{ KNX_ENERGY_TOTAL , false, false, KNX_Empty },
|
2018-05-31 06:58:54 +01:00
|
|
|
{ KNX_SLOT1 , false, false, KNX_Empty },
|
|
|
|
{ KNX_SLOT2 , false, false, KNX_Empty },
|
|
|
|
{ KNX_SLOT3 , false, false, KNX_Empty },
|
|
|
|
{ KNX_SLOT4 , false, false, KNX_Empty },
|
|
|
|
{ KNX_SLOT5 , false, false, KNX_Empty },
|
2020-06-18 19:07:01 +01:00
|
|
|
{ KNX_SCENE , false, false, KNX_Empty },
|
2018-04-18 16:28:45 +01:00
|
|
|
{ KNX_Empty, false, false, KNX_Empty}
|
|
|
|
};
|
|
|
|
|
|
|
|
// device parameters (information that can be sent)
|
|
|
|
const char * device_param_ga[] = {
|
2018-05-14 01:16:02 +01:00
|
|
|
D_TIMER_OUTPUT " 1", // Relay 1
|
|
|
|
D_TIMER_OUTPUT " 2", // Relay 2
|
|
|
|
D_TIMER_OUTPUT " 3", // Relay 3
|
|
|
|
D_TIMER_OUTPUT " 4", // Relay 4
|
|
|
|
D_TIMER_OUTPUT " 5", // Relay 5
|
|
|
|
D_TIMER_OUTPUT " 6", // Relay 6
|
|
|
|
D_TIMER_OUTPUT " 7", // Relay 7
|
|
|
|
D_TIMER_OUTPUT " 8", // Relay 8
|
2018-04-18 16:28:45 +01:00
|
|
|
D_SENSOR_BUTTON " 1", // Button 1
|
|
|
|
D_SENSOR_BUTTON " 2", // Button 2
|
|
|
|
D_SENSOR_BUTTON " 3", // Button 3
|
|
|
|
D_SENSOR_BUTTON " 4", // Button 4
|
|
|
|
D_SENSOR_BUTTON " 5", // Button 5
|
|
|
|
D_SENSOR_BUTTON " 6", // Button 6
|
|
|
|
D_SENSOR_BUTTON " 7", // Button 7
|
|
|
|
D_SENSOR_BUTTON " 8", // Button 8
|
|
|
|
D_TEMPERATURE , // Temperature
|
|
|
|
D_HUMIDITY , // Humidity
|
2018-05-17 05:46:10 +01:00
|
|
|
D_VOLTAGE ,
|
|
|
|
D_CURRENT ,
|
|
|
|
D_POWERUSAGE ,
|
|
|
|
D_POWER_FACTOR ,
|
|
|
|
D_ENERGY_TODAY ,
|
|
|
|
D_ENERGY_YESTERDAY ,
|
|
|
|
D_ENERGY_TOTAL ,
|
2018-05-31 06:58:54 +01:00
|
|
|
D_KNX_TX_SLOT " 1",
|
|
|
|
D_KNX_TX_SLOT " 2",
|
|
|
|
D_KNX_TX_SLOT " 3",
|
|
|
|
D_KNX_TX_SLOT " 4",
|
|
|
|
D_KNX_TX_SLOT " 5",
|
2020-06-18 19:07:01 +01:00
|
|
|
D_KNX_TX_SCENE ,
|
2018-04-18 16:28:45 +01:00
|
|
|
nullptr
|
|
|
|
};
|
|
|
|
|
|
|
|
// device actions (posible actions to be performed on the device)
|
|
|
|
const char *device_param_cb[] = {
|
2018-05-14 01:16:02 +01:00
|
|
|
D_TIMER_OUTPUT " 1", // Set Relay 1 (1-On or 0-OFF)
|
|
|
|
D_TIMER_OUTPUT " 2",
|
|
|
|
D_TIMER_OUTPUT " 3",
|
|
|
|
D_TIMER_OUTPUT " 4",
|
|
|
|
D_TIMER_OUTPUT " 5",
|
|
|
|
D_TIMER_OUTPUT " 6",
|
|
|
|
D_TIMER_OUTPUT " 7",
|
|
|
|
D_TIMER_OUTPUT " 8",
|
|
|
|
D_TIMER_OUTPUT " 1 " D_BUTTON_TOGGLE, // Relay 1 Toggle (1 or 0 will toggle)
|
|
|
|
D_TIMER_OUTPUT " 2 " D_BUTTON_TOGGLE,
|
|
|
|
D_TIMER_OUTPUT " 3 " D_BUTTON_TOGGLE,
|
|
|
|
D_TIMER_OUTPUT " 4 " D_BUTTON_TOGGLE,
|
|
|
|
D_TIMER_OUTPUT " 5 " D_BUTTON_TOGGLE,
|
|
|
|
D_TIMER_OUTPUT " 6 " D_BUTTON_TOGGLE,
|
|
|
|
D_TIMER_OUTPUT " 7 " D_BUTTON_TOGGLE,
|
|
|
|
D_TIMER_OUTPUT " 8 " D_BUTTON_TOGGLE,
|
2018-04-18 16:28:45 +01:00
|
|
|
D_REPLY " " D_TEMPERATURE, // Reply Temperature
|
|
|
|
D_REPLY " " D_HUMIDITY, // Reply Humidity
|
2018-05-17 05:46:10 +01:00
|
|
|
D_REPLY " " D_VOLTAGE ,
|
|
|
|
D_REPLY " " D_CURRENT ,
|
|
|
|
D_REPLY " " D_POWERUSAGE ,
|
|
|
|
D_REPLY " " D_POWER_FACTOR ,
|
|
|
|
D_REPLY " " D_ENERGY_TODAY ,
|
|
|
|
D_REPLY " " D_ENERGY_YESTERDAY ,
|
|
|
|
D_REPLY " " D_ENERGY_TOTAL ,
|
2018-05-31 06:58:54 +01:00
|
|
|
D_KNX_RX_SLOT " 1",
|
|
|
|
D_KNX_RX_SLOT " 2",
|
|
|
|
D_KNX_RX_SLOT " 3",
|
|
|
|
D_KNX_RX_SLOT " 4",
|
|
|
|
D_KNX_RX_SLOT " 5",
|
2020-06-18 19:07:01 +01:00
|
|
|
D_KNX_RX_SCENE ,
|
2018-04-18 16:28:45 +01:00
|
|
|
nullptr
|
|
|
|
};
|
|
|
|
|
2018-05-31 06:58:54 +01:00
|
|
|
// Commands
|
2019-08-11 17:12:18 +01:00
|
|
|
#define D_PRFX_KNX "Knx"
|
|
|
|
#define D_CMND_KNXTXCMND "Tx_Cmnd"
|
|
|
|
#define D_CMND_KNXTXVAL "Tx_Val"
|
|
|
|
#define D_CMND_KNX_ENABLED "_Enabled"
|
|
|
|
#define D_CMND_KNX_ENHANCED "_Enhanced"
|
|
|
|
#define D_CMND_KNX_PA "_PA"
|
|
|
|
#define D_CMND_KNX_GA "_GA"
|
|
|
|
#define D_CMND_KNX_CB "_CB"
|
2020-06-18 19:07:01 +01:00
|
|
|
#define D_CMND_KNXTXSCENE "Tx_Scene"
|
|
|
|
|
2019-08-11 17:12:18 +01:00
|
|
|
|
|
|
|
const char kKnxCommands[] PROGMEM = D_PRFX_KNX "|" // Prefix
|
2020-06-18 19:07:01 +01:00
|
|
|
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 ;
|
2019-08-02 17:33:38 +01:00
|
|
|
|
|
|
|
void (* const KnxCommand[])(void) PROGMEM = {
|
2020-06-18 19:07:01 +01:00
|
|
|
&CmndKnxTxCmnd, &CmndKnxTxVal, &CmndKnxEnabled, &CmndKnxEnhanced, &CmndKnxPa, &CmndKnxGa, &CmndKnxCb, &CmndKnxTxScene };
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t KNX_GA_Search( uint8_t param, uint8_t start = 0 )
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = start; i < Settings.knx_GA_registered; ++i)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
if ( Settings.knx_GA_param[i] == param )
|
|
|
|
{
|
|
|
|
if ( Settings.knx_GA_addr[i] != 0 ) // Relay has group address set? GA=0/0/0 can not be used as KNX address, so it is used here as a: not set value
|
|
|
|
{
|
|
|
|
if ( i >= start ) { return i; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return KNX_Empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t KNX_CB_Search( uint8_t param, uint8_t start = 0 )
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = start; i < Settings.knx_CB_registered; ++i)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
if ( Settings.knx_CB_param[i] == param )
|
|
|
|
{
|
|
|
|
if ( Settings.knx_CB_addr[i] != 0 )
|
|
|
|
{
|
|
|
|
if ( i >= start ) { return i; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return KNX_Empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
void KNX_ADD_GA( uint8_t GAop, uint8_t GA_FNUM, uint8_t GA_AREA, uint8_t GA_FDEF )
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
// Check if all GA were assigned. If yes-> return
|
|
|
|
if ( Settings.knx_GA_registered >= MAX_KNX_GA ) { return; }
|
|
|
|
if ( GA_FNUM == 0 && GA_AREA == 0 && GA_FDEF == 0 ) { return; }
|
|
|
|
|
|
|
|
// Assign a GA to that address
|
|
|
|
Settings.knx_GA_param[Settings.knx_GA_registered] = GAop;
|
|
|
|
KNX_addr.ga.area = GA_FNUM;
|
|
|
|
KNX_addr.ga.line = GA_AREA;
|
|
|
|
KNX_addr.ga.member = GA_FDEF;
|
|
|
|
Settings.knx_GA_addr[Settings.knx_GA_registered] = KNX_addr.value;
|
|
|
|
|
|
|
|
Settings.knx_GA_registered++;
|
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ADD " GA #%d: %s " D_TO " %d/%d/%d"),
|
2018-04-18 16:28:45 +01:00
|
|
|
Settings.knx_GA_registered,
|
|
|
|
device_param_ga[GAop-1],
|
|
|
|
GA_FNUM, GA_AREA, GA_FDEF );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
void KNX_DEL_GA( uint8_t GAnum )
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t dest_offset = 0;
|
|
|
|
uint8_t src_offset = 0;
|
|
|
|
uint8_t len = 0;
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
// Delete GA
|
|
|
|
Settings.knx_GA_param[GAnum-1] = 0;
|
|
|
|
|
|
|
|
if (GAnum == 1)
|
|
|
|
{
|
|
|
|
// start of array, so delete first entry
|
|
|
|
src_offset = 1;
|
|
|
|
// Settings.knx_GA_registered will be 1 in case of only one entry
|
|
|
|
// Settings.knx_GA_registered will be 2 in case of two entries, etc..
|
|
|
|
// so only copy anything, if there is it at least more then one element
|
|
|
|
len = (Settings.knx_GA_registered - 1);
|
|
|
|
}
|
|
|
|
else if (GAnum == Settings.knx_GA_registered)
|
|
|
|
{
|
|
|
|
// last element, don't do anything, simply decrement counter
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// somewhere in the middle
|
|
|
|
// need to calc offsets
|
|
|
|
|
|
|
|
// skip all prev elements
|
|
|
|
dest_offset = GAnum -1 ; // GAnum -1 is equal to how many element are in front of it
|
|
|
|
src_offset = dest_offset + 1; // start after the current element
|
|
|
|
len = (Settings.knx_GA_registered - GAnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len > 0)
|
|
|
|
{
|
2019-01-28 13:08:33 +00:00
|
|
|
memmove(Settings.knx_GA_param + dest_offset, Settings.knx_GA_param + src_offset, len * sizeof(uint8_t));
|
2018-04-18 16:28:45 +01:00
|
|
|
memmove(Settings.knx_GA_addr + dest_offset, Settings.knx_GA_addr + src_offset, len * sizeof(uint16_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings.knx_GA_registered--;
|
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " GA #%d"),
|
2018-04-18 16:28:45 +01:00
|
|
|
GAnum );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
void KNX_ADD_CB( uint8_t CBop, uint8_t CB_FNUM, uint8_t CB_AREA, uint8_t CB_FDEF )
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
// Check if all callbacks were assigned. If yes-> return
|
|
|
|
if ( Settings.knx_CB_registered >= MAX_KNX_CB ) { return; }
|
|
|
|
if ( CB_FNUM == 0 && CB_AREA == 0 && CB_FDEF == 0 ) { return; }
|
|
|
|
|
|
|
|
// Check if a CB for CBop was registered on the ESP-KNX-IP Library
|
|
|
|
if ( device_param[CBop-1].CB_id == KNX_Empty )
|
|
|
|
{
|
|
|
|
// if no, register the CB for CBop
|
|
|
|
device_param[CBop-1].CB_id = knx.callback_register("", KNX_CB_Action, &device_param[CBop-1]);
|
|
|
|
// KNX IP Library requires a parameter
|
|
|
|
// to identify which action was requested on the KNX network
|
|
|
|
// to be performed on this device (set relay, etc.)
|
|
|
|
// Is going to be used device_param[j].type that stores the type number (1: relay 1, etc)
|
|
|
|
}
|
|
|
|
// Assign a callback to CB address
|
|
|
|
Settings.knx_CB_param[Settings.knx_CB_registered] = CBop;
|
|
|
|
KNX_addr.ga.area = CB_FNUM;
|
|
|
|
KNX_addr.ga.line = CB_AREA;
|
|
|
|
KNX_addr.ga.member = CB_FDEF;
|
|
|
|
Settings.knx_CB_addr[Settings.knx_CB_registered] = KNX_addr.value;
|
|
|
|
|
|
|
|
knx.callback_assign( device_param[CBop-1].CB_id, KNX_addr );
|
|
|
|
|
|
|
|
Settings.knx_CB_registered++;
|
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ADD " CB #%d: %d/%d/%d " D_TO " %s"),
|
2018-04-18 16:28:45 +01:00
|
|
|
Settings.knx_CB_registered,
|
|
|
|
CB_FNUM, CB_AREA, CB_FDEF,
|
|
|
|
device_param_cb[CBop-1] );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
void KNX_DEL_CB( uint8_t CBnum )
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t oldparam = Settings.knx_CB_param[CBnum-1];
|
|
|
|
uint8_t dest_offset = 0;
|
|
|
|
uint8_t src_offset = 0;
|
|
|
|
uint8_t len = 0;
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
// Delete assigment
|
|
|
|
knx.callback_unassign(CBnum-1);
|
|
|
|
Settings.knx_CB_param[CBnum-1] = 0;
|
|
|
|
|
|
|
|
if (CBnum == 1)
|
|
|
|
{
|
|
|
|
// start of array, so delete first entry
|
|
|
|
src_offset = 1;
|
|
|
|
// Settings.knx_CB_registered will be 1 in case of only one entry
|
|
|
|
// Settings.knx_CB_registered will be 2 in case of two entries, etc..
|
|
|
|
// so only copy anything, if there is it at least more then one element
|
|
|
|
len = (Settings.knx_CB_registered - 1);
|
|
|
|
}
|
|
|
|
else if (CBnum == Settings.knx_CB_registered)
|
|
|
|
{
|
|
|
|
// last element, don't do anything, simply decrement counter
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// somewhere in the middle
|
|
|
|
// need to calc offsets
|
|
|
|
|
|
|
|
// skip all prev elements
|
|
|
|
dest_offset = CBnum -1 ; // GAnum -1 is equal to how many element are in front of it
|
|
|
|
src_offset = dest_offset + 1; // start after the current element
|
|
|
|
len = (Settings.knx_CB_registered - CBnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len > 0)
|
|
|
|
{
|
2019-01-28 13:08:33 +00:00
|
|
|
memmove(Settings.knx_CB_param + dest_offset, Settings.knx_CB_param + src_offset, len * sizeof(uint8_t));
|
2018-04-18 16:28:45 +01:00
|
|
|
memmove(Settings.knx_CB_addr + dest_offset, Settings.knx_CB_addr + src_offset, len * sizeof(uint16_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings.knx_CB_registered--;
|
|
|
|
|
|
|
|
// Check if there is no other assigment to that callback. If there is not. delete that callback register
|
|
|
|
if ( KNX_CB_Search( oldparam ) == KNX_Empty ) {
|
|
|
|
knx.callback_deregister( device_param[oldparam-1].CB_id );
|
|
|
|
device_param[oldparam-1].CB_id = KNX_Empty;
|
|
|
|
}
|
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " CB #%d"), CBnum );
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-14 13:32:09 +00:00
|
|
|
bool KNX_CONFIG_NOT_MATCH(void)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
2018-08-20 04:12:37 +01:00
|
|
|
// Check for configured parameters that the device does not have (module changed)
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = 0; i < KNX_MAX_device_param; ++i)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
if ( !device_param[i].show ) { // device has this parameter ?
|
|
|
|
// if not, search for all registered group address to this parameter for deletion
|
2018-05-31 06:58:54 +01:00
|
|
|
|
|
|
|
// Checks all GA
|
2018-04-18 16:28:45 +01:00
|
|
|
if ( KNX_GA_Search(i+1) != KNX_Empty ) { return true; }
|
2018-05-31 06:58:54 +01:00
|
|
|
// Check all CB
|
|
|
|
if ( i < 8 ) // check relays (i from 8 to 15 are toggle relays parameters)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
if ( KNX_CB_Search(i+1) != KNX_Empty ) { return true; }
|
2018-05-05 08:51:46 +01:00
|
|
|
if ( KNX_CB_Search(i+9) != KNX_Empty ) { return true; }
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
2018-08-20 04:12:37 +01:00
|
|
|
// check sensors and others
|
|
|
|
if ( i > 15 )
|
2018-05-31 06:58:54 +01:00
|
|
|
{
|
|
|
|
if ( KNX_CB_Search(i+1) != KNX_Empty ) { return true; }
|
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
}
|
2018-08-20 04:12:37 +01:00
|
|
|
|
|
|
|
// Check for invalid or erroneous configuration (tasmota flashed without clearing the memory)
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = 0; i < Settings.knx_GA_registered; ++i)
|
2018-08-20 04:12:37 +01:00
|
|
|
{
|
|
|
|
if ( Settings.knx_GA_param[i] != 0 ) // the GA[i] have a parameter defined?
|
|
|
|
{
|
|
|
|
if ( Settings.knx_GA_addr[i] == 0 ) // the GA[i] with parameter have the 0/0/0 as address?
|
|
|
|
{
|
|
|
|
return true; // So, it is invalid. Reset KNX configuration
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = 0; i < Settings.knx_CB_registered; ++i)
|
2018-08-20 04:12:37 +01:00
|
|
|
{
|
|
|
|
if ( Settings.knx_CB_param[i] != 0 ) // the CB[i] have a parameter defined?
|
|
|
|
{
|
|
|
|
if ( Settings.knx_CB_addr[i] == 0 ) // the CB[i] with parameter have the 0/0/0 as address?
|
|
|
|
{
|
|
|
|
return true; // So, it is invalid. Reset KNX configuration
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-18 16:28:45 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-14 13:32:09 +00:00
|
|
|
void KNXStart(void)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
knx.start(nullptr);
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_START));
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-14 13:32:09 +00:00
|
|
|
void KNX_INIT(void)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
// Check for incompatible config
|
|
|
|
if (Settings.knx_GA_registered > MAX_KNX_GA) { Settings.knx_GA_registered = MAX_KNX_GA; }
|
|
|
|
if (Settings.knx_CB_registered > MAX_KNX_CB) { Settings.knx_CB_registered = MAX_KNX_CB; }
|
|
|
|
|
|
|
|
// Set Physical KNX Address of the device
|
|
|
|
KNX_physs_addr.value = Settings.knx_physsical_addr;
|
|
|
|
knx.physical_address_set( KNX_physs_addr );
|
|
|
|
|
|
|
|
// Read Configuration
|
|
|
|
// Check which relays, buttons and sensors where configured for this device
|
|
|
|
// and activate options according to the hardware
|
2020-11-13 10:21:28 +00:00
|
|
|
/*
|
|
|
|
for (uint32_t i = 0; i < 8; i++) {
|
|
|
|
if (PinUsed(GPIO_REL1, i)) {
|
|
|
|
device_param[i].show = true;
|
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
2020-11-13 10:21:28 +00:00
|
|
|
*/
|
|
|
|
for (uint32_t i = 0; i < TasmotaGlobal.devices_present; ++i) {
|
2018-05-14 01:16:02 +01:00
|
|
|
device_param[i].show = true;
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
2020-11-13 10:21:28 +00:00
|
|
|
for (uint32_t i = 0; i < 4; i++) {
|
|
|
|
if (PinUsed(GPIO_KEY1, i)) {
|
|
|
|
device_param[8 + i].show = true;
|
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
2020-11-13 10:21:28 +00:00
|
|
|
for (uint32_t i = 0; i < 8; i++) {
|
|
|
|
if (PinUsed(GPIO_SWT1, i)) {
|
|
|
|
device_param[8 + i].show = true;
|
|
|
|
}
|
2018-12-01 19:26:15 +00:00
|
|
|
}
|
2020-11-13 10:21:28 +00:00
|
|
|
if (PinUsed(GPIO_DHT11) || PinUsed(GPIO_DHT22) || PinUsed(GPIO_SI7021)) {
|
|
|
|
device_param[KNX_TEMPERATURE-1].show = true;
|
|
|
|
device_param[KNX_HUMIDITY-1].show = true;
|
2018-12-01 19:26:15 +00:00
|
|
|
}
|
2019-10-16 13:04:01 +01:00
|
|
|
#ifdef USE_DS18x20
|
2020-11-13 10:21:28 +00:00
|
|
|
if (PinUsed(GPIO_DSB)) {
|
|
|
|
device_param[KNX_TEMPERATURE-1].show = true;
|
|
|
|
}
|
2019-10-16 13:04:01 +01:00
|
|
|
#endif
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2019-12-17 00:23:25 +00:00
|
|
|
#if defined(USE_ENERGY_SENSOR)
|
2019-02-04 13:57:20 +00:00
|
|
|
// Any device with a Power Monitoring
|
2020-10-30 11:29:48 +00:00
|
|
|
if ( TasmotaGlobal.energy_driver != ENERGY_NONE ) {
|
2018-05-17 05:46:10 +01:00
|
|
|
device_param[KNX_ENERGY_POWER-1].show = true;
|
|
|
|
device_param[KNX_ENERGY_DAILY-1].show = true;
|
|
|
|
device_param[KNX_ENERGY_START-1].show = true;
|
|
|
|
device_param[KNX_ENERGY_TOTAL-1].show = true;
|
|
|
|
device_param[KNX_ENERGY_VOLTAGE-1].show = true;
|
|
|
|
device_param[KNX_ENERGY_CURRENT-1].show = true;
|
|
|
|
device_param[KNX_ENERGY_POWERFACTOR-1].show = true;
|
|
|
|
}
|
2019-12-17 00:23:25 +00:00
|
|
|
#endif
|
2018-05-17 05:46:10 +01:00
|
|
|
|
2018-05-31 06:58:54 +01:00
|
|
|
#ifdef USE_RULES
|
|
|
|
device_param[KNX_SLOT1-1].show = true;
|
|
|
|
device_param[KNX_SLOT2-1].show = true;
|
|
|
|
device_param[KNX_SLOT3-1].show = true;
|
|
|
|
device_param[KNX_SLOT4-1].show = true;
|
|
|
|
device_param[KNX_SLOT5-1].show = true;
|
2020-06-18 19:07:01 +01:00
|
|
|
device_param[KNX_SCENE-1].show = true;
|
2018-05-31 06:58:54 +01:00
|
|
|
#endif
|
|
|
|
|
2018-04-18 16:28:45 +01:00
|
|
|
// Delete from KNX settings all configuration is not anymore related to this device
|
|
|
|
if (KNX_CONFIG_NOT_MATCH()) {
|
|
|
|
Settings.knx_GA_registered = 0;
|
|
|
|
Settings.knx_CB_registered = 0;
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " " D_KNX_PARAMETERS));
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Register Group Addresses to listen to
|
|
|
|
// Search on the settings if there is a group address set for receive KNX messages for the type: device_param[j].type
|
|
|
|
// If there is, register the group address on the KNX_IP Library to Receive data for Executing Callbacks
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t j;
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = 0; i < Settings.knx_CB_registered; ++i)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
j = Settings.knx_CB_param[i];
|
|
|
|
if ( j > 0 )
|
|
|
|
{
|
|
|
|
device_param[j-1].CB_id = knx.callback_register("", KNX_CB_Action, &device_param[j-1]); // KNX IP Library requires a parameter
|
|
|
|
// to identify which action was requested on the KNX network
|
|
|
|
// to be performed on this device (set relay, etc.)
|
|
|
|
// Is going to be used device_param[j].type that stores the type number (1: relay 1, etc)
|
|
|
|
KNX_addr.value = Settings.knx_CB_addr[i];
|
|
|
|
knx.callback_assign( device_param[j-1].CB_id, KNX_addr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KNX_CB_Action(message_t const &msg, void *arg)
|
|
|
|
{
|
|
|
|
device_parameters_t *chan = (device_parameters_t *)arg;
|
|
|
|
if (!(Settings.flag.knx_enabled)) { return; }
|
|
|
|
|
2018-12-21 15:17:06 +00:00
|
|
|
char tempchar[33];
|
2018-07-23 02:40:28 +01:00
|
|
|
|
|
|
|
if (msg.data_len == 1) {
|
|
|
|
// COMMAND
|
2020-04-11 07:10:48 +01:00
|
|
|
sprintf(tempchar,"%d",msg.data[0]);
|
2020-06-18 19:07:01 +01:00
|
|
|
} else if (chan->type == KNX_SCENE) {
|
|
|
|
// VALUE
|
2020-10-30 11:29:48 +00:00
|
|
|
uint8_t tempvar = knx.data_to_1byte_uint(msg.data);
|
2020-10-19 17:39:36 +01:00
|
|
|
dtostrfd(tempvar,0,tempchar);
|
2020-06-18 19:07:01 +01:00
|
|
|
} else {
|
2018-07-23 02:40:28 +01:00
|
|
|
// VALUE
|
2020-11-16 18:10:16 +00:00
|
|
|
float tempvar = knx.data_to_4byte_float(msg.data);
|
2018-07-23 02:40:28 +01:00
|
|
|
dtostrfd(tempvar,2,tempchar);
|
|
|
|
}
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX D_RECEIVED_FROM " %d.%d.%d " D_COMMAND " %s: %s " D_TO " %s"),
|
2019-03-08 14:15:42 +00:00
|
|
|
msg.received_on.ga.area, msg.received_on.ga.line, msg.received_on.ga.member,
|
|
|
|
(msg.ct == KNX_CT_WRITE) ? D_KNX_COMMAND_WRITE : (msg.ct == KNX_CT_READ) ? D_KNX_COMMAND_READ : D_KNX_COMMAND_OTHER,
|
|
|
|
tempchar,
|
|
|
|
device_param_cb[(chan->type)-1]);
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
switch (msg.ct)
|
|
|
|
{
|
|
|
|
case KNX_CT_WRITE:
|
|
|
|
if (chan->type < 9) // Set Relays
|
|
|
|
{
|
2018-05-28 14:52:42 +01:00
|
|
|
ExecuteCommandPower(chan->type, msg.data[0], SRC_KNX);
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
else if (chan->type < 17) // Toggle Relays
|
|
|
|
{
|
2018-05-16 09:56:09 +01:00
|
|
|
if (!toggle_inhibit) {
|
2019-09-04 11:20:04 +01:00
|
|
|
ExecuteCommandPower((chan->type) -8, POWER_TOGGLE, SRC_KNX);
|
2018-05-16 09:56:09 +01:00
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
toggle_inhibit = TOGGLE_INHIBIT_TIME;
|
|
|
|
}
|
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
2018-05-31 06:58:54 +01:00
|
|
|
#ifdef USE_RULES
|
|
|
|
else if ((chan->type >= KNX_SLOT1) && (chan->type <= KNX_SLOT5)) // KNX RX SLOTs (write command)
|
|
|
|
{
|
|
|
|
if (!toggle_inhibit) {
|
2021-01-01 12:44:04 +00:00
|
|
|
char command[35]; //4294967295.00 13chars + 17
|
2018-07-23 02:40:28 +01:00
|
|
|
if (msg.data_len == 1) {
|
|
|
|
// Command received
|
|
|
|
snprintf_P(command, sizeof(command), PSTR("event KNXRX_CMND%d=%d"), ((chan->type) - KNX_SLOT1 + 1 ), msg.data[0]);
|
|
|
|
} else {
|
|
|
|
// Value received
|
|
|
|
snprintf_P(command, sizeof(command), PSTR("event KNXRX_VAL%d=%s"), ((chan->type) - KNX_SLOT1 + 1 ), tempchar);
|
|
|
|
}
|
2018-05-31 06:58:54 +01:00
|
|
|
ExecuteCommand(command, SRC_KNX);
|
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
toggle_inhibit = TOGGLE_INHIBIT_TIME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-18 19:07:01 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2020-10-30 11:29:48 +00:00
|
|
|
}
|
2018-05-31 06:58:54 +01:00
|
|
|
#endif
|
2018-04-18 16:28:45 +01:00
|
|
|
break;
|
2018-05-31 06:58:54 +01:00
|
|
|
|
2018-04-18 16:28:45 +01:00
|
|
|
case KNX_CT_READ:
|
|
|
|
if (chan->type < 9) // reply Relays status
|
|
|
|
{
|
|
|
|
knx.answer_1bit(msg.received_on, chan->last_state);
|
2018-05-16 09:56:09 +01:00
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
knx.answer_1bit(msg.received_on, chan->last_state);
|
|
|
|
knx.answer_1bit(msg.received_on, chan->last_state);
|
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
2018-06-08 03:56:52 +01:00
|
|
|
else if (chan->type == KNX_TEMPERATURE) // Reply Temperature
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
2020-11-16 18:10:16 +00:00
|
|
|
knx.answer_4byte_float(msg.received_on, last_temp);
|
2018-05-16 09:56:09 +01:00
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
2020-11-16 18:10:16 +00:00
|
|
|
knx.answer_4byte_float(msg.received_on, last_temp);
|
|
|
|
knx.answer_4byte_float(msg.received_on, last_temp);
|
2018-05-16 09:56:09 +01:00
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
2018-06-08 03:56:52 +01:00
|
|
|
else if (chan->type == KNX_HUMIDITY) // Reply Humidity
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
2020-11-16 18:10:16 +00:00
|
|
|
knx.answer_4byte_float(msg.received_on, last_hum);
|
2018-05-16 09:56:09 +01:00
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
2020-11-16 18:10:16 +00:00
|
|
|
knx.answer_4byte_float(msg.received_on, last_hum);
|
|
|
|
knx.answer_4byte_float(msg.received_on, last_hum);
|
2018-05-16 09:56:09 +01:00
|
|
|
}
|
2020-11-16 20:55:16 +00:00
|
|
|
}
|
|
|
|
else if (chan->type == KNX_ENERGY_VOLTAGE) // Reply KNX_ENERGY_VOLTAGE
|
|
|
|
{
|
|
|
|
if (Energy.data_valid[0]) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.voltage[0]);
|
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.voltage[0]);
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.voltage[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (chan->type == KNX_ENERGY_CURRENT) // Reply KNX_ENERGY_CURRENT
|
|
|
|
{
|
|
|
|
if (Energy.data_valid[0]) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.current[0]);
|
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.current[0]);
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.current[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (chan->type == KNX_ENERGY_POWER) // Reply KNX_ENERGY_POWER
|
|
|
|
{
|
|
|
|
if (Energy.data_valid[0]) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.active_power[0]);
|
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.active_power[0]);
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.active_power[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (chan->type == KNX_ENERGY_POWERFACTOR) // Reply KNX_ENERGY_POWERFACTOR
|
|
|
|
{
|
|
|
|
if (Energy.data_valid[0]) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.power_factor[0]);
|
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.power_factor[0]);
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.power_factor[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (chan->type == KNX_ENERGY_START) // Reply KNX_ENERGY_START
|
|
|
|
{
|
|
|
|
if (Energy.data_valid[0]) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.start_energy);
|
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.start_energy);
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.start_energy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (chan->type == KNX_ENERGY_DAILY) // Reply KNX_ENERGY_DAILY
|
|
|
|
{
|
|
|
|
if (Energy.data_valid[0]) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.daily);
|
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.daily);
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.daily);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (chan->type == KNX_ENERGY_TOTAL) // Reply KNX_ENERGY_TOTAL
|
|
|
|
{
|
|
|
|
if (Energy.data_valid[0]) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.total);
|
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.total);
|
|
|
|
knx.answer_4byte_float(msg.received_on, Energy.total);
|
|
|
|
}
|
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
2018-05-31 06:58:54 +01:00
|
|
|
#ifdef USE_RULES
|
|
|
|
else if ((chan->type >= KNX_SLOT1) && (chan->type <= KNX_SLOT5)) // KNX RX SLOTs (read command)
|
|
|
|
{
|
|
|
|
if (!toggle_inhibit) {
|
|
|
|
char command[25];
|
|
|
|
snprintf_P(command, sizeof(command), PSTR("event KNXRX_REQ%d"), ((chan->type) - KNX_SLOT1 + 1 ) );
|
|
|
|
ExecuteCommand(command, SRC_KNX);
|
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
toggle_inhibit = TOGGLE_INHIBIT_TIME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2018-04-18 16:28:45 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
void KnxUpdatePowerState(uint8_t device, power_t state)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
if (!(Settings.flag.knx_enabled)) { return; }
|
|
|
|
|
|
|
|
device_param[device -1].last_state = bitRead(state, device -1); // power state (on/off)
|
|
|
|
|
|
|
|
// Search all the registered GA that has that output (variable: device) as parameter
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t i = KNX_GA_Search(device);
|
2018-04-18 16:28:45 +01:00
|
|
|
while ( i != KNX_Empty ) {
|
|
|
|
KNX_addr.value = Settings.knx_GA_addr[i];
|
|
|
|
knx.write_1bit(KNX_addr, device_param[device -1].last_state);
|
2018-05-16 09:56:09 +01:00
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
knx.write_1bit(KNX_addr, device_param[device -1].last_state);
|
|
|
|
knx.write_1bit(KNX_addr, device_param[device -1].last_state);
|
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
|
2018-04-18 16:28:45 +01:00
|
|
|
device_param_ga[device -1], device_param[device -1].last_state,
|
|
|
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
|
|
|
|
|
|
|
|
i = KNX_GA_Search(device, i + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-24 08:47:28 +01:00
|
|
|
void KnxSendButtonPower(void)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
2019-10-24 08:47:28 +01:00
|
|
|
if (!(Settings.flag.knx_enabled)) { return; }
|
|
|
|
|
|
|
|
uint32_t key = (XdrvMailbox.payload >> 16) & 0xFF;
|
|
|
|
uint32_t device = XdrvMailbox.payload & 0xFF;
|
|
|
|
uint32_t state = (XdrvMailbox.payload >> 8) & 0xFF;
|
2018-04-18 16:28:45 +01:00
|
|
|
// key 0 = button_topic
|
|
|
|
// key 1 = switch_topic
|
|
|
|
// state 0 = off
|
|
|
|
// state 1 = on
|
|
|
|
// state 2 = toggle
|
|
|
|
// state 3 = hold
|
|
|
|
// state 9 = clear retain flag
|
|
|
|
|
|
|
|
// Search all the registered GA that has that output (variable: device) as parameter
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t i = KNX_GA_Search(device + 8);
|
2018-04-18 16:28:45 +01:00
|
|
|
while ( i != KNX_Empty ) {
|
|
|
|
KNX_addr.value = Settings.knx_GA_addr[i];
|
|
|
|
knx.write_1bit(KNX_addr, !(state == 0));
|
2018-05-16 09:56:09 +01:00
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
knx.write_1bit(KNX_addr, !(state == 0));
|
|
|
|
knx.write_1bit(KNX_addr, !(state == 0));
|
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
|
2018-05-05 08:51:46 +01:00
|
|
|
device_param_ga[device + 7], !(state == 0),
|
2018-04-18 16:28:45 +01:00
|
|
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
|
|
|
|
|
|
|
|
i = KNX_GA_Search(device + 8, i + 1);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
void KnxSensor(uint8_t sensor_type, float value)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
if (sensor_type == KNX_TEMPERATURE)
|
|
|
|
{
|
|
|
|
last_temp = value;
|
|
|
|
} else if (sensor_type == KNX_HUMIDITY)
|
|
|
|
{
|
|
|
|
last_hum = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(Settings.flag.knx_enabled)) { return; }
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t i = KNX_GA_Search(sensor_type);
|
2018-04-18 16:28:45 +01:00
|
|
|
while ( i != KNX_Empty ) {
|
|
|
|
KNX_addr.value = Settings.knx_GA_addr[i];
|
2020-11-16 18:10:16 +00:00
|
|
|
knx.write_4byte_float(KNX_addr, value);
|
2018-05-16 09:56:09 +01:00
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
2020-11-16 18:10:16 +00:00
|
|
|
knx.write_4byte_float(KNX_addr, value);
|
|
|
|
knx.write_4byte_float(KNX_addr, value);
|
2018-05-16 09:56:09 +01:00
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s " D_SENT_TO " %d.%d.%d "),
|
2018-04-29 09:35:14 +01:00
|
|
|
device_param_ga[sensor_type -1],
|
2018-04-18 16:28:45 +01:00
|
|
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
|
|
|
|
|
|
|
|
i = KNX_GA_Search(sensor_type, i+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************************\
|
|
|
|
* Presentation
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
|
|
|
#ifdef USE_WEBSERVER
|
2018-07-23 03:16:46 +01:00
|
|
|
#ifdef USE_KNX_WEB_MENU
|
2018-10-10 21:21:44 +01:00
|
|
|
const char HTTP_BTN_MENU_KNX[] PROGMEM =
|
2019-02-13 15:05:25 +00:00
|
|
|
"<p><form action='kn' method='get'><button>" D_CONFIGURE_KNX "</button></form></p>";
|
2018-10-10 21:21:44 +01:00
|
|
|
|
2018-04-18 16:28:45 +01:00
|
|
|
const char HTTP_FORM_KNX[] PROGMEM =
|
2019-03-04 17:16:07 +00:00
|
|
|
"<fieldset style='min-width:530px;'>"
|
|
|
|
"<legend style='text-align:left;'><b> " D_KNX_PARAMETERS " </b></legend>"
|
|
|
|
"<form method='post' action='kn'>"
|
2019-05-31 17:24:56 +01:00
|
|
|
"<br><center>"
|
2018-04-18 16:28:45 +01:00
|
|
|
"<b>" D_KNX_PHYSICAL_ADDRESS " </b>"
|
2019-03-04 17:16:07 +00:00
|
|
|
"<input style='width:12%%;' type='number' name='area' min='0' max='15' value='%d'> . "
|
|
|
|
"<input style='width:12%%;' type='number' name='line' min='0' max='15' value='%d'> . "
|
|
|
|
"<input style='width:12%%;' type='number' name='member' min='0' max='255' value='%d'>"
|
2019-05-31 17:24:56 +01:00
|
|
|
"<br><br>" D_KNX_PHYSICAL_ADDRESS_NOTE "<br><br>"
|
2020-04-05 13:11:49 +01:00
|
|
|
"<label><input id='b1' type='checkbox'";
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2018-05-16 09:56:09 +01:00
|
|
|
const char HTTP_FORM_KNX1[] PROGMEM =
|
2020-04-05 13:11:49 +01:00
|
|
|
"><b>" D_KNX_ENABLE "</b></label> <label><input id='b2' type='checkbox'";
|
2018-05-16 09:56:09 +01:00
|
|
|
|
2018-04-18 16:28:45 +01:00
|
|
|
const char HTTP_FORM_KNX2[] PROGMEM =
|
2020-04-05 13:11:49 +01:00
|
|
|
"><b>" D_KNX_ENHANCEMENT "</b></label><br></center><br>"
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
"<fieldset><center>"
|
|
|
|
"<b>" D_KNX_GROUP_ADDRESS_TO_WRITE "</b><hr>"
|
|
|
|
|
2019-03-10 14:36:34 +00:00
|
|
|
"<select name='GAop' style='width:25%%;'>";
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
const char HTTP_FORM_KNX_OPT[] PROGMEM =
|
2019-03-04 17:16:07 +00:00
|
|
|
"<option value='%d'>%s</option>";
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
const char HTTP_FORM_KNX_GA[] PROGMEM =
|
2019-06-02 15:44:02 +01:00
|
|
|
"<input style='width:12%%;' type='number' id='%s' min='0' max='31' value='0'> / "
|
|
|
|
"<input style='width:12%%;' type='number' id='%s' min='0' max='7' value='0'> / "
|
|
|
|
"<input style='width:12%%;' type='number' id='%s' min='0' max='255' value='0'> ";
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
const char HTTP_FORM_KNX_ADD_BTN[] PROGMEM =
|
2019-05-31 17:24:56 +01:00
|
|
|
"<button type='submit' onclick='%s()' %s name='btn_add' value='%d' style='width:18%%;'>" D_ADD "</button><br><br>"
|
2019-03-04 17:16:07 +00:00
|
|
|
"<table style='width:80%%; font-size: 14px;'><col width='250'><col width='30'>";
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
const char HTTP_FORM_KNX_ADD_TABLE_ROW[] PROGMEM =
|
2019-03-04 17:16:07 +00:00
|
|
|
"<tr><td><b>%s -> %d / %d / %d </b></td>"
|
|
|
|
"<td><button type='submit' name='btn_del_ga' value='%d' class='button bred'> " D_DELETE " </button></td></tr>";
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
const char HTTP_FORM_KNX3[] PROGMEM =
|
2019-05-31 17:24:56 +01:00
|
|
|
"</table></center></fieldset><br>"
|
2018-04-18 16:28:45 +01:00
|
|
|
"<fieldset><form method='post' action='kn'><center>"
|
|
|
|
"<b>" D_KNX_GROUP_ADDRESS_TO_READ "</b><hr>";
|
|
|
|
|
|
|
|
const char HTTP_FORM_KNX4[] PROGMEM =
|
2019-03-10 14:36:34 +00:00
|
|
|
"-> <select name='CBop' style='width:25%%;'>";
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
const char HTTP_FORM_KNX_ADD_TABLE_ROW2[] PROGMEM =
|
2019-03-04 17:16:07 +00:00
|
|
|
"<tr><td><b>%d / %d / %d -> %s</b></td>"
|
|
|
|
"<td><button type='submit' name='btn_del_cb' value='%d' class='button bred'> " D_DELETE " </button></td></tr>";
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2018-11-14 13:32:09 +00:00
|
|
|
void HandleKNXConfiguration(void)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
2019-01-10 11:57:42 +00:00
|
|
|
if (!HttpCheckPriviledgedAccess()) { return; }
|
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_KNX));
|
2018-09-21 10:15:42 +01:00
|
|
|
|
2018-04-18 16:28:45 +01:00
|
|
|
char tmp[100];
|
|
|
|
String stmp;
|
|
|
|
|
2020-04-15 08:58:38 +01:00
|
|
|
if ( Webserver->hasArg("save") ) {
|
2018-04-18 16:28:45 +01:00
|
|
|
KNX_Save_Settings();
|
|
|
|
HandleConfiguration();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-15 08:58:38 +01:00
|
|
|
if ( Webserver->hasArg("btn_add") ) {
|
|
|
|
if ( Webserver->arg("btn_add") == "1" ) {
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("GAop"); //option selected
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t GAop = stmp.toInt();
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("GA_FNUM");
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t GA_FNUM = stmp.toInt();
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("GA_AREA");
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t GA_AREA = stmp.toInt();
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("GA_FDEF");
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t GA_FDEF = stmp.toInt();
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2018-05-14 01:16:02 +01:00
|
|
|
if (GAop) {
|
|
|
|
KNX_ADD_GA( GAop, GA_FNUM, GA_AREA, GA_FDEF );
|
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("CBop"); //option selected
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t CBop = stmp.toInt();
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("CB_FNUM");
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t CB_FNUM = stmp.toInt();
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("CB_AREA");
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t CB_AREA = stmp.toInt();
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("CB_FDEF");
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t CB_FDEF = stmp.toInt();
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2018-05-14 01:16:02 +01:00
|
|
|
if (CBop) {
|
|
|
|
KNX_ADD_CB( CBop, CB_FNUM, CB_AREA, CB_FDEF );
|
|
|
|
}
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-15 08:58:38 +01:00
|
|
|
else if ( Webserver->hasArg("btn_del_ga") )
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("btn_del_ga");
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t GA_NUM = stmp.toInt();
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
KNX_DEL_GA(GA_NUM);
|
|
|
|
|
|
|
|
}
|
2020-04-15 08:58:38 +01:00
|
|
|
else if ( Webserver->hasArg("btn_del_cb") )
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("btn_del_cb");
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t CB_NUM = stmp.toInt();
|
2018-04-18 16:28:45 +01:00
|
|
|
|
|
|
|
KNX_DEL_CB(CB_NUM);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-11-06 16:09:13 +00:00
|
|
|
WSContentStart_P(PSTR(D_CONFIGURE_KNX));
|
2019-03-10 14:36:34 +00:00
|
|
|
WSContentSend_P(
|
|
|
|
PSTR("function GAwarning()"
|
|
|
|
"{"
|
|
|
|
"var GA_FNUM=eb('GA_FNUM');"
|
|
|
|
"var GA_AREA=eb('GA_AREA');"
|
|
|
|
"var GA_FDEF=eb('GA_FDEF');"
|
|
|
|
"if(GA_FNUM!=null&&GA_FNUM.value=='0'&&GA_AREA.value=='0'&&GA_FDEF.value=='0'){"
|
|
|
|
"alert('" D_KNX_WARNING "');"
|
|
|
|
"}"
|
2019-03-04 17:16:07 +00:00
|
|
|
"}"
|
2019-03-10 14:36:34 +00:00
|
|
|
"function CBwarning()"
|
|
|
|
"{"
|
|
|
|
"var CB_FNUM=eb('CB_FNUM');"
|
|
|
|
"var CB_AREA=eb('CB_AREA');"
|
|
|
|
"var CB_FDEF=eb('CB_FDEF');"
|
|
|
|
"if(CB_FNUM!=null&&CB_FNUM.value=='0'&&CB_AREA.value=='0'&&CB_FDEF.value=='0'){"
|
|
|
|
"alert('" D_KNX_WARNING "');"
|
|
|
|
"}"
|
|
|
|
"}"));
|
2019-03-04 17:16:07 +00:00
|
|
|
WSContentSendStyle();
|
2019-04-03 01:41:52 +01:00
|
|
|
KNX_physs_addr.value = Settings.knx_physsical_addr;
|
2019-03-04 17:16:07 +00:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX, KNX_physs_addr.pa.area, KNX_physs_addr.pa.line, KNX_physs_addr.pa.member);
|
2019-03-10 14:36:34 +00:00
|
|
|
if ( Settings.flag.knx_enabled ) { WSContentSend_P(PSTR(" checked")); }
|
|
|
|
WSContentSend_P(HTTP_FORM_KNX1);
|
|
|
|
if ( Settings.flag.knx_enable_enhancement ) { WSContentSend_P(PSTR(" checked")); }
|
2019-03-04 17:16:07 +00:00
|
|
|
|
2019-03-10 14:36:34 +00:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX2);
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = 0; i < KNX_MAX_device_param ; i++)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
if ( device_param[i].show )
|
|
|
|
{
|
2019-03-04 17:16:07 +00:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX_OPT, device_param[i].type, device_param_ga[i]);
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
}
|
2019-03-10 14:36:34 +00:00
|
|
|
WSContentSend_P(PSTR("</select> -> "));
|
2019-06-02 15:44:02 +01:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX_GA, "GA_FNUM", "GA_AREA", "GA_FDEF");
|
2019-03-04 17:16:07 +00:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX_ADD_BTN, "GAwarning", (Settings.knx_GA_registered < MAX_KNX_GA) ? "" : "disabled", 1);
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = 0; i < Settings.knx_GA_registered ; ++i)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
if ( Settings.knx_GA_param[i] )
|
|
|
|
{
|
|
|
|
KNX_addr.value = Settings.knx_GA_addr[i];
|
2019-03-04 17:16:07 +00:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX_ADD_TABLE_ROW, device_param_ga[Settings.knx_GA_param[i]-1], KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member, i +1);
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
}
|
2018-05-05 08:51:46 +01:00
|
|
|
|
2019-03-10 14:36:34 +00:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX3);
|
2019-06-02 15:44:02 +01:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX_GA, "CB_FNUM", "CB_AREA", "CB_FDEF");
|
2019-03-10 14:36:34 +00:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX4);
|
2019-03-04 17:16:07 +00:00
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
uint8_t j;
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = 0; i < KNX_MAX_device_param ; i++)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
2018-04-29 09:35:14 +01:00
|
|
|
// Check How many Relays are available and add: RelayX and TogleRelayX
|
|
|
|
if ( (i > 8) && (i < 16) ) { j=i-8; } else { j=i; }
|
|
|
|
if ( i == 8 ) { j = 0; }
|
|
|
|
if ( device_param[j].show )
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
2019-03-04 17:16:07 +00:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX_OPT, device_param[i].type, device_param_cb[i]);
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
}
|
2019-03-10 14:36:34 +00:00
|
|
|
WSContentSend_P(PSTR("</select> "));
|
2019-03-04 17:16:07 +00:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX_ADD_BTN, "CBwarning", (Settings.knx_CB_registered < MAX_KNX_CB) ? "" : "disabled", 2);
|
2018-05-05 08:51:46 +01:00
|
|
|
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = 0; i < Settings.knx_CB_registered ; ++i)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
if ( Settings.knx_CB_param[i] )
|
|
|
|
{
|
|
|
|
KNX_addr.value = Settings.knx_CB_addr[i];
|
2019-03-04 17:16:07 +00:00
|
|
|
WSContentSend_P(HTTP_FORM_KNX_ADD_TABLE_ROW2, KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member, device_param_cb[Settings.knx_CB_param[i]-1], i +1);
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
}
|
2019-03-10 14:36:34 +00:00
|
|
|
WSContentSend_P(PSTR("</table></center></fieldset>"));
|
|
|
|
WSContentSend_P(HTTP_FORM_END);
|
2019-03-11 09:38:41 +00:00
|
|
|
WSContentSpaceButton(BUTTON_CONFIGURATION);
|
2019-03-16 15:23:41 +00:00
|
|
|
WSContentStop();
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-14 13:32:09 +00:00
|
|
|
void KNX_Save_Settings(void)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
String stmp;
|
|
|
|
address_t KNX_addr;
|
|
|
|
|
2020-04-15 08:58:38 +01:00
|
|
|
Settings.flag.knx_enabled = Webserver->hasArg("b1");
|
|
|
|
Settings.flag.knx_enable_enhancement = Webserver->hasArg("b2");
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ENABLED ": %d, " D_KNX_ENHANCEMENT ": %d"),
|
2018-05-16 09:56:09 +01:00
|
|
|
Settings.flag.knx_enabled, Settings.flag.knx_enable_enhancement );
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("area");
|
2018-04-18 16:28:45 +01:00
|
|
|
KNX_addr.pa.area = stmp.toInt();
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("line");
|
2018-04-18 16:28:45 +01:00
|
|
|
KNX_addr.pa.line = stmp.toInt();
|
2020-04-15 08:58:38 +01:00
|
|
|
stmp = Webserver->arg("member");
|
2018-04-18 16:28:45 +01:00
|
|
|
KNX_addr.pa.member = stmp.toInt();
|
|
|
|
Settings.knx_physsical_addr = KNX_addr.value;
|
|
|
|
knx.physical_address_set( KNX_addr ); // Set Physical KNX Address of the device
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_KNX_PHYSICAL_ADDRESS ": %d.%d.%d "),
|
2018-04-18 16:28:45 +01:00
|
|
|
KNX_addr.pa.area, KNX_addr.pa.line, KNX_addr.pa.member );
|
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "GA: %d"),
|
2018-04-18 16:28:45 +01:00
|
|
|
Settings.knx_GA_registered );
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = 0; i < Settings.knx_GA_registered ; ++i)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
KNX_addr.value = Settings.knx_GA_addr[i];
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "GA #%d: %s " D_TO " %d/%d/%d"),
|
2018-04-18 16:28:45 +01:00
|
|
|
i+1, device_param_ga[Settings.knx_GA_param[i]-1],
|
|
|
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member );
|
2019-03-08 14:15:42 +00:00
|
|
|
|
2018-04-18 16:28:45 +01:00
|
|
|
}
|
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB: %d"),
|
2018-04-18 16:28:45 +01:00
|
|
|
Settings.knx_CB_registered );
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = 0; i < Settings.knx_CB_registered ; ++i)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
|
|
|
KNX_addr.value = Settings.knx_CB_addr[i];
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB #%d: %d/%d/%d " D_TO " %s"),
|
2018-04-18 16:28:45 +01:00
|
|
|
i+1,
|
|
|
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member,
|
|
|
|
device_param_cb[Settings.knx_CB_param[i]-1] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-23 03:16:46 +01:00
|
|
|
#endif // USE_KNX_WEB_MENU
|
2018-04-18 16:28:45 +01:00
|
|
|
#endif // USE_WEBSERVER
|
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* Commands
|
|
|
|
\*********************************************************************************************/
|
2018-04-18 16:28:45 +01:00
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
void CmndKnxTxCmnd(void)
|
2018-05-31 06:58:54 +01:00
|
|
|
{
|
2019-08-02 17:33:38 +01:00
|
|
|
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_KNXTX_CMNDS) && (XdrvMailbox.data_len > 0) && Settings.flag.knx_enabled) {
|
|
|
|
// XdrvMailbox.index <- KNX SLOT to use
|
2018-05-31 06:58:54 +01:00
|
|
|
// XdrvMailbox.payload <- data to send
|
|
|
|
// Search all the registered GA that has that output (variable: KNX SLOTx) as parameter
|
2019-08-02 17:33:38 +01:00
|
|
|
uint8_t i = KNX_GA_Search(XdrvMailbox.index + KNX_SLOT1 -1);
|
2018-05-31 06:58:54 +01:00
|
|
|
while ( i != KNX_Empty ) {
|
|
|
|
KNX_addr.value = Settings.knx_GA_addr[i];
|
|
|
|
knx.write_1bit(KNX_addr, !(XdrvMailbox.payload == 0));
|
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
|
|
|
knx.write_1bit(KNX_addr, !(XdrvMailbox.payload == 0));
|
|
|
|
knx.write_1bit(KNX_addr, !(XdrvMailbox.payload == 0));
|
|
|
|
}
|
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
|
2019-08-02 17:33:38 +01:00
|
|
|
device_param_ga[XdrvMailbox.index + KNX_SLOT1 -2], !(XdrvMailbox.payload == 0),
|
2018-05-31 06:58:54 +01:00
|
|
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
|
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
i = KNX_GA_Search(XdrvMailbox.index + KNX_SLOT1 -1, i + 1);
|
2018-05-31 06:58:54 +01:00
|
|
|
}
|
2019-08-03 12:01:34 +01:00
|
|
|
ResponseCmndIdxChar (XdrvMailbox.data );
|
2018-05-31 06:58:54 +01:00
|
|
|
}
|
2019-08-02 17:33:38 +01:00
|
|
|
}
|
2018-05-31 06:58:54 +01:00
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
void CmndKnxTxVal(void)
|
|
|
|
{
|
|
|
|
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_KNXTX_CMNDS) && (XdrvMailbox.data_len > 0) && Settings.flag.knx_enabled) {
|
|
|
|
// XdrvMailbox.index <- KNX SLOT to use
|
2018-05-31 06:58:54 +01:00
|
|
|
// XdrvMailbox.payload <- data to send
|
|
|
|
// Search all the registered GA that has that output (variable: KNX SLOTx) as parameter
|
2019-08-02 17:33:38 +01:00
|
|
|
uint8_t i = KNX_GA_Search(XdrvMailbox.index + KNX_SLOT1 -1);
|
2018-05-31 06:58:54 +01:00
|
|
|
while ( i != KNX_Empty ) {
|
|
|
|
KNX_addr.value = Settings.knx_GA_addr[i];
|
2018-06-28 16:52:05 +01:00
|
|
|
|
2019-07-01 17:20:43 +01:00
|
|
|
float tempvar = CharToFloat(XdrvMailbox.data);
|
2018-06-28 16:52:05 +01:00
|
|
|
dtostrfd(tempvar,2,XdrvMailbox.data);
|
|
|
|
|
2020-11-16 18:10:16 +00:00
|
|
|
knx.write_4byte_float(KNX_addr, tempvar);
|
2018-05-31 06:58:54 +01:00
|
|
|
if (Settings.flag.knx_enable_enhancement) {
|
2020-11-16 18:10:16 +00:00
|
|
|
knx.write_4byte_float(KNX_addr, tempvar);
|
|
|
|
knx.write_4byte_float(KNX_addr, tempvar);
|
2018-05-31 06:58:54 +01:00
|
|
|
}
|
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %s " D_SENT_TO " %d.%d.%d"),
|
2019-08-02 17:33:38 +01:00
|
|
|
device_param_ga[XdrvMailbox.index + KNX_SLOT1 -2], XdrvMailbox.data,
|
2018-05-31 06:58:54 +01:00
|
|
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
|
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
i = KNX_GA_Search(XdrvMailbox.index + KNX_SLOT1 -1, i + 1);
|
2018-05-31 06:58:54 +01:00
|
|
|
}
|
2019-08-03 12:01:34 +01:00
|
|
|
ResponseCmndIdxChar (XdrvMailbox.data );
|
2018-05-31 06:58:54 +01:00
|
|
|
}
|
2019-08-02 17:33:38 +01:00
|
|
|
}
|
2018-05-31 06:58:54 +01:00
|
|
|
|
2020-06-18 19:07:01 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-01-23 16:24:54 +00:00
|
|
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %s " D_SENT_TO " %d.%d.%d"),
|
2020-06-18 19:07:01 +01:00
|
|
|
device_param_ga[KNX_SCENE-1], XdrvMailbox.data,
|
|
|
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
|
|
|
|
ResponseCmndIdxChar (XdrvMailbox.data);
|
2020-10-30 11:29:48 +00:00
|
|
|
}
|
2020-06-18 19:07:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
void CmndKnxEnabled(void)
|
|
|
|
{
|
|
|
|
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) {
|
|
|
|
Settings.flag.knx_enabled = XdrvMailbox.payload;
|
2018-07-23 05:01:52 +01:00
|
|
|
}
|
2019-08-03 12:01:34 +01:00
|
|
|
ResponseCmndChar (GetStateText(Settings.flag.knx_enabled) );
|
2019-08-02 17:33:38 +01:00
|
|
|
}
|
2018-05-31 06:58:54 +01:00
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
void CmndKnxEnhanced(void)
|
|
|
|
{
|
|
|
|
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) {
|
|
|
|
Settings.flag.knx_enable_enhancement = XdrvMailbox.payload;
|
2018-07-23 05:01:52 +01:00
|
|
|
}
|
2019-08-03 12:01:34 +01:00
|
|
|
ResponseCmndChar (GetStateText(Settings.flag.knx_enable_enhancement) );
|
2019-08-02 17:33:38 +01:00
|
|
|
}
|
2018-07-23 05:01:52 +01:00
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
void CmndKnxPa(void)
|
|
|
|
{
|
|
|
|
if (XdrvMailbox.data_len) {
|
2020-11-04 10:20:17 +00:00
|
|
|
if (strchr(XdrvMailbox.data, '.') != nullptr) { // Process parameter entry
|
2019-08-02 17:33:38 +01:00
|
|
|
char sub_string[XdrvMailbox.data_len];
|
|
|
|
|
|
|
|
int pa_area = atoi(subStr(sub_string, XdrvMailbox.data, ".", 1));
|
|
|
|
int pa_line = atoi(subStr(sub_string, XdrvMailbox.data, ".", 2));
|
|
|
|
int pa_member = atoi(subStr(sub_string, XdrvMailbox.data, ".", 3));
|
|
|
|
|
|
|
|
if ( ((pa_area == 0) && (pa_line == 0) && (pa_member == 0))
|
|
|
|
|| (pa_area > 15) || (pa_line > 15) || (pa_member > 255) ) {
|
2021-01-31 15:54:28 +00:00
|
|
|
ResponseCmndError();
|
2019-08-02 17:33:38 +01:00
|
|
|
return;
|
|
|
|
} // Invalid command
|
|
|
|
|
|
|
|
KNX_addr.pa.area = pa_area;
|
|
|
|
KNX_addr.pa.line = pa_line;
|
|
|
|
KNX_addr.pa.member = pa_member;
|
|
|
|
Settings.knx_physsical_addr = KNX_addr.value;
|
2018-07-23 06:15:44 +01:00
|
|
|
}
|
|
|
|
}
|
2019-08-02 17:33:38 +01:00
|
|
|
KNX_addr.value = Settings.knx_physsical_addr;
|
|
|
|
Response_P (PSTR("{\"%s\":\"%d.%d.%d\"}"),
|
|
|
|
XdrvMailbox.command, KNX_addr.pa.area, KNX_addr.pa.line, KNX_addr.pa.member );
|
|
|
|
}
|
2018-07-23 06:15:44 +01:00
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
void CmndKnxGa(void)
|
|
|
|
{
|
|
|
|
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_KNX_GA)) {
|
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
2018-07-23 08:03:57 +01:00
|
|
|
if (XdrvMailbox.data_len) {
|
2021-01-30 13:52:53 +00:00
|
|
|
if (ArgC() > 1) { // Process parameter entry
|
|
|
|
char argument[XdrvMailbox.data_len];
|
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
2018-07-23 08:03:57 +01:00
|
|
|
|
2021-01-30 13:52:53 +00:00
|
|
|
int ga_option = atoi(ArgV(argument, 1));
|
|
|
|
int ga_area = atoi(ArgV(argument, 2));
|
|
|
|
int ga_line = atoi(ArgV(argument, 3));
|
|
|
|
int ga_member = atoi(ArgV(argument, 4));
|
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
2018-07-23 08:03:57 +01:00
|
|
|
|
|
|
|
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) ) {
|
2021-01-31 15:54:28 +00:00
|
|
|
ResponseCmndIdxError();
|
2019-08-02 17:33:38 +01:00
|
|
|
return;
|
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
2018-07-23 08:03:57 +01:00
|
|
|
} // Invalid command
|
|
|
|
|
|
|
|
KNX_addr.ga.area = ga_area;
|
|
|
|
KNX_addr.ga.line = ga_line;
|
|
|
|
KNX_addr.ga.member = ga_member;
|
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
if ( XdrvMailbox.index > Settings.knx_GA_registered ) {
|
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
2018-07-23 08:03:57 +01:00
|
|
|
Settings.knx_GA_registered ++;
|
2019-08-02 17:33:38 +01:00
|
|
|
XdrvMailbox.index = Settings.knx_GA_registered;
|
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
2018-07-23 08:03:57 +01:00
|
|
|
}
|
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
Settings.knx_GA_addr[XdrvMailbox.index -1] = KNX_addr.value;
|
|
|
|
Settings.knx_GA_param[XdrvMailbox.index -1] = ga_option;
|
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
2018-07-23 08:03:57 +01:00
|
|
|
} else {
|
|
|
|
if ( (XdrvMailbox.payload <= Settings.knx_GA_registered) && (XdrvMailbox.payload > 0) ) {
|
2019-08-02 17:33:38 +01:00
|
|
|
XdrvMailbox.index = XdrvMailbox.payload;
|
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
2018-07-23 08:03:57 +01:00
|
|
|
} else {
|
2021-01-31 15:54:28 +00:00
|
|
|
ResponseCmndIdxError();
|
2019-08-02 17:33:38 +01:00
|
|
|
return;
|
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
2018-07-23 08:03:57 +01:00
|
|
|
}
|
|
|
|
}
|
2019-08-02 17:33:38 +01:00
|
|
|
if ( XdrvMailbox.index <= Settings.knx_GA_registered ) {
|
|
|
|
KNX_addr.value = Settings.knx_GA_addr[XdrvMailbox.index -1];
|
|
|
|
Response_P (PSTR("{\"%s%d\":\"%s, %d/%d/%d\"}"),
|
|
|
|
XdrvMailbox.command, XdrvMailbox.index, device_param_ga[Settings.knx_GA_param[XdrvMailbox.index-1]-1],
|
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
2018-07-23 08:03:57 +01:00
|
|
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member );
|
|
|
|
}
|
|
|
|
} else {
|
2021-01-31 15:54:28 +00:00
|
|
|
ResponseCmndIdxNumber (Settings.knx_GA_registered );
|
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
2018-07-23 08:03:57 +01:00
|
|
|
}
|
|
|
|
}
|
2019-08-02 17:33:38 +01:00
|
|
|
}
|
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
2018-07-23 08:03:57 +01:00
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
void CmndKnxCb(void)
|
|
|
|
{
|
|
|
|
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_KNX_CB)) {
|
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
2018-07-23 08:03:57 +01:00
|
|
|
if (XdrvMailbox.data_len) {
|
2021-01-30 13:52:53 +00:00
|
|
|
if (ArgC() > 1) { // Process parameter entry
|
|
|
|
char argument[XdrvMailbox.data_len];
|
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
2018-07-23 08:03:57 +01:00
|
|
|
|
2021-01-30 13:52:53 +00:00
|
|
|
int cb_option = atoi(ArgV(argument, 1));
|
|
|
|
int cb_area = atoi(ArgV(argument, 2));
|
|
|
|
int cb_line = atoi(ArgV(argument, 3));
|
|
|
|
int cb_member = atoi(ArgV(argument, 4));
|
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
2018-07-23 08:03:57 +01:00
|
|
|
|
|
|
|
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) ) {
|
2021-01-31 15:54:28 +00:00
|
|
|
ResponseCmndIdxError();
|
2019-08-02 17:33:38 +01:00
|
|
|
return;
|
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
2018-07-23 08:03:57 +01:00
|
|
|
} // Invalid command
|
|
|
|
|
|
|
|
KNX_addr.ga.area = cb_area;
|
|
|
|
KNX_addr.ga.line = cb_line;
|
|
|
|
KNX_addr.ga.member = cb_member;
|
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
if ( XdrvMailbox.index > Settings.knx_CB_registered ) {
|
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
2018-07-23 08:03:57 +01:00
|
|
|
Settings.knx_CB_registered ++;
|
2019-08-02 17:33:38 +01:00
|
|
|
XdrvMailbox.index = Settings.knx_CB_registered;
|
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
2018-07-23 08:03:57 +01:00
|
|
|
}
|
|
|
|
|
2019-08-02 17:33:38 +01:00
|
|
|
Settings.knx_CB_addr[XdrvMailbox.index -1] = KNX_addr.value;
|
|
|
|
Settings.knx_CB_param[XdrvMailbox.index -1] = cb_option;
|
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
2018-07-23 08:03:57 +01:00
|
|
|
} else {
|
|
|
|
if ( (XdrvMailbox.payload <= Settings.knx_CB_registered) && (XdrvMailbox.payload > 0) ) {
|
2019-08-02 17:33:38 +01:00
|
|
|
XdrvMailbox.index = XdrvMailbox.payload;
|
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
2018-07-23 08:03:57 +01:00
|
|
|
} else {
|
2021-01-31 15:54:28 +00:00
|
|
|
ResponseCmndIdxError();
|
2019-08-02 17:33:38 +01:00
|
|
|
return;
|
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
2018-07-23 08:03:57 +01:00
|
|
|
}
|
|
|
|
}
|
2019-08-02 17:33:38 +01:00
|
|
|
if ( XdrvMailbox.index <= Settings.knx_CB_registered ) {
|
|
|
|
KNX_addr.value = Settings.knx_CB_addr[XdrvMailbox.index -1];
|
|
|
|
Response_P (PSTR("{\"%s%d\":\"%s, %d/%d/%d\"}"),
|
|
|
|
XdrvMailbox.command, XdrvMailbox.index, device_param_cb[Settings.knx_CB_param[XdrvMailbox.index-1]-1],
|
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
2018-07-23 08:03:57 +01:00
|
|
|
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member );
|
|
|
|
}
|
|
|
|
} else {
|
2021-01-31 15:54:28 +00:00
|
|
|
ResponseCmndIdxNumber (Settings.knx_CB_registered );
|
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
2018-07-23 08:03:57 +01:00
|
|
|
}
|
|
|
|
}
|
2018-05-31 06:58:54 +01:00
|
|
|
}
|
|
|
|
|
2018-04-18 16:28:45 +01:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* Interface
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
bool Xdrv11(uint8_t function)
|
2018-04-18 16:28:45 +01:00
|
|
|
{
|
2019-01-28 13:08:33 +00:00
|
|
|
bool result = false;
|
2018-04-18 16:28:45 +01:00
|
|
|
switch (function) {
|
2019-03-30 12:03:45 +00:00
|
|
|
case FUNC_LOOP:
|
2020-10-30 11:29:48 +00:00
|
|
|
if (!TasmotaGlobal.global_state.network_down) { knx.loop(); } // Process knx events
|
2019-03-30 12:03:45 +00:00
|
|
|
break;
|
2019-10-24 08:47:28 +01:00
|
|
|
case FUNC_EVERY_50_MSECOND:
|
|
|
|
if (toggle_inhibit) {
|
|
|
|
toggle_inhibit--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FUNC_ANY_KEY:
|
|
|
|
KnxSendButtonPower();
|
2018-04-18 16:28:45 +01:00
|
|
|
break;
|
2018-10-10 21:21:44 +01:00
|
|
|
#ifdef USE_WEBSERVER
|
|
|
|
#ifdef USE_KNX_WEB_MENU
|
|
|
|
case FUNC_WEB_ADD_BUTTON:
|
2019-03-10 14:36:34 +00:00
|
|
|
WSContentSend_P(HTTP_BTN_MENU_KNX);
|
2018-10-10 21:21:44 +01:00
|
|
|
break;
|
|
|
|
case FUNC_WEB_ADD_HANDLER:
|
2020-10-20 17:56:18 +01:00
|
|
|
WebServer_on(PSTR("/kn"), HandleKNXConfiguration);
|
2018-10-10 21:21:44 +01:00
|
|
|
break;
|
|
|
|
#endif // USE_KNX_WEB_MENU
|
|
|
|
#endif // USE_WEBSERVER
|
2018-05-31 06:58:54 +01:00
|
|
|
case FUNC_COMMAND:
|
2019-08-02 17:33:38 +01:00
|
|
|
result = DecodeCommand(kKnxCommands, KnxCommand);
|
2018-05-31 06:58:54 +01:00
|
|
|
break;
|
2019-10-24 08:47:28 +01:00
|
|
|
case FUNC_PRE_INIT:
|
|
|
|
KNX_INIT();
|
|
|
|
break;
|
2018-04-18 16:28:45 +01:00
|
|
|
// case FUNC_SET_POWER:
|
|
|
|
// break;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-05-18 23:57:16 +01:00
|
|
|
#endif // USE_KNX
|