3#include "../SinricProRequest.h"
4#include "../EventLimiter.h"
5#include "../SinricProStrings.h"
7#include "../SinricProNamespace.h"
8namespace SINRICPRO_NAMESPACE {
10FSTR(POWERLEVEL, setPowerLevel);
11FSTR(POWERLEVEL, powerLevel);
12FSTR(POWERLEVEL, adjustPowerLevel);
13FSTR(POWERLEVEL, powerLevelDelta);
62 bool handlePowerLevelController(SinricProRequest &
request);
65 EventLimiter event_limiter;
72: event_limiter(EVENT_LIMIT_STATE) {
73 T*
device =
static_cast<T*
>(
this);
85 setPowerLevelCallback =
cb;
97 adjustPowerLevelCallback =
cb;
111 if (event_limiter)
return false;
112 T*
device =
static_cast<T*
>(
this);
122 T*
device =
static_cast<T*
>(
this);
132 if (adjustPowerLevelCallback && request.action == FSTR_POWERLEVEL_adjustPowerLevel) {
133 int powerLevelDelta = request.request_value[FSTR_POWERLEVEL_powerLevelDelta];
134 success = adjustPowerLevelCallback(device->deviceId, powerLevelDelta);
135 request.response_value[FSTR_POWERLEVEL_powerLevel] = powerLevelDelta;
143using PowerLevelController = SINRICPRO_NAMESPACE::PowerLevelController<T>;
AirQuality.
Definition AirQualitySensor.h:19
PowerLevelController.
Definition PowerLevelController.h:53
void onPowerLevel(SetPowerLevelCallback cb)
Set callback function for setPowerLevel request.
Definition PowerLevelController.h:84
void onAdjustPowerLevel(AdjustPowerLevelCallback cb)
Set callback function for adjustPowerLevel request.
Definition PowerLevelController.h:95
bool sendPowerLevelEvent(int powerLevel, String cause=FSTR_SINRICPRO_PHYSICAL_INTERACTION)
Send setPowerLevel event to SinricPro Server indicating actual power level.
Definition PowerLevelController.h:110
std::function< bool(const String &, int &)> AdjustPowerLevelCallback
Definition for onAdjustPowerLevel callback.
Definition PowerLevelController.h:45
std::function< bool(const String &, int &)> SetPowerLevelCallback
Definition for setPowerLevel callback.
Definition PowerLevelController.h:30