Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/GardenControl.share.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
Offset="0" BitOffset="3" />
<Parameter Id="%AID%_UP-%TT%00004" Name="KOsStateSendStartup"
ParameterType="%AID%_PT-OnOFF" Text="Status KOs senden nach Startup" Value="1"
Offset="0" BitOffset="3" />
Offset="0" BitOffset="4" />
</Union>
</Parameters>
<ParameterRefs>
Expand Down
11 changes: 11 additions & 0 deletions src/GardenControlDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ GardenControlDevice::~GardenControlDevice()
{
}

void GardenControlDevice::processAfterStartupDelay()
{
// Logic is registered before GardenControl, so its external-KO lookup
// is already prepared when the startup status KOs are queued here.
sendStartupOutputStates();
}

// TODO *****************************************************************************************************************************
void GardenControlDevice::waitStartupLoop()
{
Expand Down Expand Up @@ -224,6 +231,10 @@ void GardenControlDevice::setup()

delay(100);

// Initialize the 5 V relay status without sending. The status is re-sent
// after the OpenKNX startup delay, when Logic is ready for local callbacks.
knx.getGroupObject(BEM_Ko_Status_5V_relais).valueNoSend(get_5V_Relais_State(false), getDPT(VAL_DPT_1));

// set KOs initial Ventil
for (int i = 0; i < BEM_ChannelCount; i++)
{
Expand Down
1 change: 1 addition & 0 deletions src/GardenControlDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class GardenControlDevice : public OpenKNX::Module

// void processReadRequests();
void processInputKo(GroupObject &iKo);
void processAfterStartupDelay() override;
// void showHelp() override;
// bool processCommand(const std::string cmd, bool debugKo) override;
void setup();
Expand Down
65 changes: 28 additions & 37 deletions src/handleVentilRelais.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
#include "ErrorHandling.h"
#include "LED_Statusanzeige.h"

bool initVentil = false;
bool initRelay = false;

bool ventil_State[BEM_ChannelCount] = {0};
bool ventil_State_old[BEM_ChannelCount] = {0};
bool ventil_Sperrobjekt[BEM_ChannelCount] = {0};
Expand All @@ -22,7 +19,6 @@ bool relais_Sperrobjekt[REL_ChannelCount] = {0};

bool relais_5V_State = false;
bool relais_5V_State_old = false;
bool relais_5V_startup_flag = true;

bool displayCleared_Ventil = false;
bool displayCleared_Relais = false;
Expand All @@ -32,18 +28,6 @@ bool displayCleared_Relais = false;
****************************************************************************/
void processVentil()
{
if (!initVentil)
{
SERIAL_PORT.println("Senden Status Objekte Ventil");
if ((knx.paramByte(BEM_KOsStateSendStartup) >> BEM_KOsStateSendStartupShift) & 1) // Senden bei Startup "AN"
{
for (int i = 0; i < BEM_ChannelCount; i++)
{
knx.getGroupObject(BEM_KoOffset + (i * BEM_KoBlockSize + BEM_Ko_Status_ventil)).objectWritten();
}
}
initVentil = true;
}
if (!get_24V_AC_Error())
{
// check of state chnage and Send new Status
Expand Down Expand Up @@ -156,18 +140,6 @@ void clear_ALL_Ventil_states()
****************************************************************************/
void processRelais()
{
if (!initRelay)
{
SERIAL_PORT.println("Senden Status Objekte Relays");
if ((knx.paramByte(BEM_KOsStateSendStartup) >> BEM_KOsStateSendStartupShift) & 1) // Senden bei Startup "AN"
{
for (int i = 0; i < REL_ChannelCount; i++)
{
knx.getGroupObject(REL_KoOffset + (i * REL_KoBlockSize + REL_Ko_Status_relais)).objectWritten();
}
}
initRelay = true;
}
if (!get_24V_AC_Error())
{
// check of state chnage and Send new Status
Expand Down Expand Up @@ -265,6 +237,34 @@ void clear_ALL_Relais_states()
}
}

void sendStartupOutputStates()
{
// Queue startup status telegrams only after the OpenKNX startup delay.
// Logic prepares its external-KO lookup in processAfterStartupDelay(), so
// earlier writes can be missed by local logic inputs.
if ((knx.paramByte(BEM_KOsStateSendStartup) >> BEM_KOsStateSendStartupShift) & 1)
{
SERIAL_PORT.println("Senden Status Objekte Ventil");
for (int i = 0; i < BEM_ChannelCount; i++)
{
knx.getGroupObject(BEM_KoOffset + (i * BEM_KoBlockSize + BEM_Ko_Status_ventil)).objectWritten();
}

SERIAL_PORT.println("Senden Status Objekte Relays");
for (int i = 0; i < REL_ChannelCount; i++)
{
knx.getGroupObject(REL_KoOffset + (i * REL_KoBlockSize + REL_Ko_Status_relais)).objectWritten();
}
}

// The external 5 V relay has its own startup-send parameter.
if ((knx.paramByte(BEM_ext5VRelaisStartState) >> BEM_ext5VRelaisStartStateShift) & 1)
{
SERIAL_PORT.println("Senden Status Objekt 5V Relais");
knx.getGroupObject(BEM_Ko_Status_5V_relais).objectWritten();
}
}

/*****************************************************************************
* externes 5V Relais
****************************************************************************/
Expand All @@ -276,15 +276,6 @@ void control_5V_Relais(bool state)

void process_5V_Relais()
{
if (relais_5V_startup_flag)
{
if ((knx.paramByte(BEM_ext5VRelaisStartState) >> BEM_ext5VRelaisStartStateShift) & 1) // Senden bei Startup "AN"
{
knx.getGroupObject(BEM_Ko_Status_5V_relais).value(relais_5V_State, getDPT(VAL_DPT_1));
}
relais_5V_startup_flag = false;
}

if (relais_5V_State_old != relais_5V_State)
{
control_5V_Relais(relais_5V_State);
Expand Down
1 change: 1 addition & 0 deletions src/handleVentilRelais.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ void processRelais();
void process_ventil_states();
void process_relais_states();
void process_5V_Relais();
void sendStartupOutputStates();
void set_Ventil_State(uint8_t ch, bool state);
void set_Ventil_State_single(uint8_t ch);
void set_Ventil_Sperrobjekt(uint8_t ch, bool state);
Expand Down