From 32a15182bed658ea940b2d7b69ea3a01eba963f2 Mon Sep 17 00:00:00 2001 From: Adrian Scillato <35405447+ascillato@users.noreply.github.com> Date: Wed, 14 Apr 2021 15:05:13 -0300 Subject: [PATCH] KNX: Fix Power and Energy missing replies --- tasmota/xdrv_11_knx.ino | 60 ++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/tasmota/xdrv_11_knx.ino b/tasmota/xdrv_11_knx.ino index 037f22b73..8ad133474 100644 --- a/tasmota/xdrv_11_knx.ino +++ b/tasmota/xdrv_11_knx.ino @@ -645,74 +645,60 @@ void KNX_CB_Action(message_t const &msg, void *arg) } } 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]); - 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]); - 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]); - 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]); - 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_YESTERDAY) // Reply KNX_ENERGY_YESTERDAY { - if (Energy.data_valid[0]) { - float energy_kWhyesterday = (float)Settings.energy_kWhyesterday / 100000; + float energy_kWhyesterday = (float)Settings.energy_kWhyesterday / 100000; + knx.answer_4byte_float(msg.received_on, energy_kWhyesterday); + if (Settings.flag.knx_enable_enhancement) { + knx.answer_4byte_float(msg.received_on, energy_kWhyesterday); knx.answer_4byte_float(msg.received_on, energy_kWhyesterday); - if (Settings.flag.knx_enable_enhancement) { - knx.answer_4byte_float(msg.received_on, energy_kWhyesterday); - knx.answer_4byte_float(msg.received_on, energy_kWhyesterday); - } } } 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); - 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); - 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