4#ifndef SRC_SUPLA_CONTROL_ACTION_TRIGGER_H_
5#define SRC_SUPLA_CONTROL_ACTION_TRIGGER_H_
9#include <supla/action_handler.h>
10#include <supla/actions.h>
11#include <supla/at_channel.h>
12#include <supla/control/weekly_schedule_component.h>
13#include <supla/element_with_channel_actions.h>
21enum ActionHandlingType : uint8_t {
22 ActionHandlingType_RelayOnSuplaServer = 0,
23 ActionHandlingType_PublishAllDisableNone = 1,
24 ActionHandlingType_PublishAllDisableAll = 2
30class ActionTriggerWeeklySchedule;
38 uint8_t weeklySchedule : 1;
46 "Flags size must be 1 byte");
61 void setRelatedChannel(
Element *);
62 void setRelatedChannel(
Channel *);
63 void setRelatedChannel(
Element &);
64 void setRelatedChannel(
Channel &);
66 void handleAction(
int event,
int action)
override;
67 void activateAction(
int action)
override;
78 void fillChannelConfig(
void *channelConfig,
80 uint8_t configType)
override;
83 void rebuildForAttachedButton();
84 void disableATCapability(uint32_t capToDisable);
85 void enableStateStorage();
87 static int actionTriggerCapToButtonEvent(uint32_t actionCap);
88 static int actionTriggerCapToActionId(uint32_t actionCap);
89 static int getActionTriggerCap(
int action);
91 bool isAnyActionEnabledOnServer()
const;
93 void setAlwaysUseOnClick1();
98 bool isLocalUnlockAllowed()
const;
105 bool keepsConfigButtonTriggerAlwaysAvailable()
const;
110 bool isWeeklyScheduleSupported()
const;
111 ActionTrigger &setWeeklyScheduleAvailable(
bool available =
true);
112 bool setWeeklyScheduleController(
119 bool local)
override;
120 bool shouldProcessChannelFunctionFromConfig()
const override;
121 virtual void fillDefaultWeeklySchedule(
123 virtual bool isWeeklyScheduleProgramModeSupported(uint8_t mode)
const;
124 bool ensureNativeWeeklyScheduleController();
125 void updateWeeklyScheduleCapabilities();
126 void scheduleStateSave(uint32_t delayMsMax = 5000,
127 uint32_t delayMsMin = 2000);
128 void applyButtonMode(uint8_t mode);
129 void applyManualButtonMode(uint8_t mode);
130 void addActionToButtonAndDisableIt(
int event,
int action);
131 void parseActiveActionsFromServer();
132 bool hasDirectionalPair()
const;
133 bool requiresClickMode()
const;
134 static void synchronizeDirectionalButtonModes();
140 uint32_t activeActionsFromServer = 0;
143 uint32_t lastReceivedActiveActions = 0;
144 uint32_t disablesLocalOperation = 0;
145 uint32_t disabledCapabilities = 0;
149 uint16_t localHandlerAction = 0;
150 ActionHandlingType actionHandlingType = ActionHandlingType_RelayOnSuplaServer;
154 : storageEnabled(
false),
155 alwaysUseOnClick1(
false),
157 localHandlerSwitchConfigured(
false),
158 channelConfigReceived(
false),
159 weeklyScheduleAvailable(
false),
160 localUnlockAllowed(
false),
161 keepConfigButtonTriggerAlwaysAvailable(
false) {}
163 uint8_t storageEnabled : 1;
164 uint8_t alwaysUseOnClick1 : 1;
166 uint8_t localHandlerSwitchConfigured : 1;
167 uint8_t channelConfigReceived : 1;
169 uint8_t weeklyScheduleAvailable : 1;
170 uint8_t localUnlockAllowed : 1;
171 uint8_t keepConfigButtonTriggerAlwaysAvailable : 1;
175 "ActionTrigger runtime flags must fit in uint8_t");
Definition SuplaDevice.h:167
Definition local_action.h:59
Definition action_handler.h:8
Definition at_channel.h:12
Definition action_trigger.cpp:37
Definition action_trigger.h:32
void onSaveState() override
Method called periodically during SuplaDevice iteration.
Definition action_trigger.cpp:894
int32_t handleNewValueFromServer(TSD_SuplaChannelNewValue *newValue) override
Handles "new value" request from server.
Definition action_trigger.cpp:1183
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition action_trigger.cpp:1176
void purgeConfig() override
Removes all configration data related to the element from Storage::Config.
Definition action_trigger.cpp:1237
void onRegistered(Supla::Protocol::SuplaSrpc *suplaSrpc=nullptr) override
Method called each time when device successfully registers to Supla server.
Definition action_trigger.cpp:372
void onInit() override
Third method called on element in SuplaDevice.begin()
Definition action_trigger.cpp:639
void onLoadState() override
Second method called on element in SuplaDevice.begin().
Definition action_trigger.cpp:983
void onLoadConfig(SuplaDeviceClass *) override
First method called on element in SuplaDevice.begin().
Definition action_trigger.cpp:923
Definition weekly_schedule_component.h:130
Definition weekly_schedule_component.h:114
Definition weekly_schedule_component.h:55
Definition weekly_schedule_component.h:34
Definition element_with_channel_actions.h:56
Base class for all elements of SuplaDevice.
Definition element.h:30
Definition supla_srpc.h:47
Definition action_trigger.h:152
Definition action_trigger.h:36