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;
39 uint8_t weeklySchedule : 1;
47 "Flags size must be 1 byte");
64 void setRelatedChannel(
Element *);
65 void setRelatedChannel(
Channel *);
66 void setRelatedChannel(
Element &);
67 void setRelatedChannel(
Channel &);
69 void handleAction(
int event,
int action)
override;
70 void activateAction(
int action)
override;
81 bool isEffectivelyLocked()
const;
82 bool isTemporaryUnlockActive()
const;
85 void fillChannelConfig(
void *channelConfig,
87 uint8_t configType)
override;
90 void rebuildForAttachedButton();
91 void disableATCapability(uint32_t capToDisable);
92 void enableStateStorage();
94 static int actionTriggerCapToButtonEvent(uint32_t actionCap);
95 static int actionTriggerCapToActionId(uint32_t actionCap);
96 static int getActionTriggerCap(
int action);
98 bool isAnyActionEnabledOnServer()
const;
100 void setAlwaysUseOnClick1();
105 bool isLocalUnlockAllowed()
const;
112 bool keepsConfigButtonTriggerAlwaysAvailable()
const;
124 ActionTrigger &setButtonModeSupported(
bool supported =
true);
125 bool isButtonModeSupported()
const;
130 ActionTrigger &setTemporaryUnlockSupported(
bool supported =
true);
131 bool isTemporaryUnlockSupported()
const;
133 bool isWeeklyScheduleSupported()
const;
134 ActionTrigger &setWeeklyScheduleAvailable(
bool available =
true);
135 bool setWeeklyScheduleController(
142 bool local)
override;
143 bool shouldProcessChannelFunctionFromConfig()
const override;
144 virtual void fillDefaultWeeklySchedule(
146 virtual bool isWeeklyScheduleProgramModeSupported(uint8_t mode)
const;
147 bool ensureNativeWeeklyScheduleController();
148 void updateWeeklyScheduleCapabilities();
149 void updateButtonModeCapabilities();
150 void scheduleStateSave(uint32_t delayMsMax = 5000,
151 uint32_t delayMsMin = 2000);
152 void applyButtonMode(uint8_t mode);
153 void applyManualButtonMode(uint8_t mode);
154 void addActionToButtonAndDisableIt(
int event,
int action);
155 void parseActiveActionsFromServer();
156 bool hasDirectionalPair()
const;
157 bool requiresClickMode()
const;
158 static void synchronizeDirectionalButtonModes();
160 bool startTemporaryUnlock(uint32_t seconds, int32_t senderId = 0);
161 void updateTemporaryUnlock();
162 void updateUnlockSensor();
163 void syncEffectiveButtonLock();
168 uint32_t function = SUPLA_CHANNELFNC_ACTIONTRIGGER;
169 uint32_t duration = 0;
170 uint8_t edge = SUPLA_AT_SENSOR_EDGE_NONE;
171 uint8_t sensor = 255;
173 uint32_t escapedActions = 0;
178 uint32_t startMs = 0;
179 uint32_t durationMs = 0;
180 uint16_t weeklyDurationS = 0;
181 bool baselineKnown =
false;
182 bool baseline =
false;
183 bool persistenceUncertain =
false;
184 bool manualModeTransition =
false;
186 bool keepTimerOnModeChange =
false;
187 bool hasStoredActiveActions =
false;
189 int32_t senderId = 0;
191 bool ensureTemporaryUnlockState();
193 bool localChange =
false,
194 const uint32_t *activeActions =
nullptr);
195 bool prepareTemporaryUnlockState();
201 bool getTemporaryUnlockRemainingMs(uint32_t *remainingMs)
const;
202 void sendTimerValue(uint32_t remainingMs,
203 uint8_t *targetValue,
210 uint32_t activeActionsFromServer = 0;
213 uint32_t lastReceivedActiveActions = 0;
214 uint32_t disablesLocalOperation = 0;
215 uint32_t disabledCapabilities = 0;
219 uint16_t localHandlerAction = 0;
220 ActionHandlingType actionHandlingType = ActionHandlingType_RelayOnSuplaServer;
224 : storageEnabled(
false),
225 alwaysUseOnClick1(
false),
227 localHandlerSwitchConfigured(
false),
228 channelConfigReceived(
false),
229 weeklyScheduleAvailable(
false),
230 localUnlockAllowed(
false),
231 keepConfigButtonTriggerAlwaysAvailable(
false),
232 buttonModeExplicit(
false),
233 buttonModeEnabled(
false),
234 temporaryUnlockDisabled(
false),
235 timerReportForced(
false),
236 timerReportPending(
false),
237 timerReportedActive(
false) {}
239 uint16_t storageEnabled : 1;
240 uint16_t alwaysUseOnClick1 : 1;
241 uint16_t enabled : 1;
242 uint16_t localHandlerSwitchConfigured : 1;
243 uint16_t channelConfigReceived : 1;
245 uint16_t weeklyScheduleAvailable : 1;
246 uint16_t localUnlockAllowed : 1;
247 uint16_t keepConfigButtonTriggerAlwaysAvailable : 1;
250 uint16_t buttonModeExplicit : 1;
251 uint16_t buttonModeEnabled : 1;
252 uint16_t temporaryUnlockDisabled : 1;
255 uint16_t timerReportForced : 1;
258 uint16_t timerReportPending : 1;
262 uint16_t timerReportedActive : 1;
266 "ActionTrigger runtime flags must fit in uint16_t");
Definition SuplaDevice.h:167
Definition local_action.h:59
Definition action_handler.h:8
Definition at_channel.h:12
Definition action_trigger.cpp:66
Definition action_trigger.h:33
void onSaveState() override
Method called periodically during SuplaDevice iteration.
Definition action_trigger.cpp:1149
int32_t handleNewValueFromServer(TSD_SuplaChannelNewValue *newValue) override
Handles "new value" request from server.
Definition action_trigger.cpp:1559
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition action_trigger.cpp:1547
bool iterateConnected() override
Method called on each SuplaDevice iteration when device is connected and registered to Supla server o...
Definition action_trigger.cpp:514
void purgeConfig() override
Removes all configration data related to the element from Storage::Config.
Definition action_trigger.cpp:1687
void onRegistered(Supla::Protocol::SuplaSrpc *suplaSrpc=nullptr) override
Method called each time when device successfully registers to Supla server.
Definition action_trigger.cpp:499
void onInit() override
Third method called on element in SuplaDevice.begin()
Definition action_trigger.cpp:891
void onLoadState() override
Second method called on element in SuplaDevice.begin().
Definition action_trigger.cpp:1274
void onLoadConfig(SuplaDeviceClass *) override
First method called on element in SuplaDevice.begin().
Definition action_trigger.cpp:1188
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
bool iterateConnected() override
Method called on each SuplaDevice iteration when device is connected and registered to Supla server o...
Definition element_with_channel_actions.cpp:511
Base class for all elements of SuplaDevice.
Definition element.h:30
Definition supla_srpc.h:47
Definition action_trigger.h:222
Definition action_trigger.h:166
Definition action_trigger.h:176
Definition action_trigger.h:37