From 2e06647ea45baf76ddc022f11bba900dfbc32444 Mon Sep 17 00:00:00 2001 From: Adrian Scillato <35405447+ascillato@users.noreply.github.com> Date: Mon, 16 Nov 2020 17:55:16 -0300 Subject: [PATCH] KNX: Added Read reply for Power --- tasmota/xdrv_11_knx.ino | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tasmota/xdrv_11_knx.ino b/tasmota/xdrv_11_knx.ino index 774697d92..cfe47e6b0 100644 --- a/tasmota/xdrv_11_knx.ino +++ b/tasmota/xdrv_11_knx.ino @@ -644,6 +644,76 @@ void KNX_CB_Action(message_t const &msg, void *arg) knx.answer_4byte_float(msg.received_on, last_hum); } } + 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); + } + } + } #ifdef USE_RULES else if ((chan->type >= KNX_SLOT1) && (chan->type <= KNX_SLOT5)) // KNX RX SLOTs (read command) {