PercentageController.
More...
template<typename T>
class PercentageController< T >
PercentageController.
◆ AdjustPercentageCallback
Callback definition for onAdjustPercentage function.
Gets called when device receive a adjustPercentage
request
- Parameters
-
[in] | deviceId | String which contains the ID of device |
[in] | percentageDelta | Integer with relative percentage the device should change about (-100..100) |
[out] | percentageDelta | Integer with absolute percentage device has been set to |
- Returns
- the success of the request
- Return values
-
true | request handled properly |
false | request was not handled properly because of some error |
Example-Code
int absolutePercentage;
absolutePercentage += percentageDelta;
Serial.printf("Device %s percentage changed about %i to %d\r\n", deviceId.c_str(), percentageDelta, absolutePercentage);
percentageDelta = absolutePercentage;
return true;
}
void onAdjustPercentage(AdjustPercentageCallback cb)
Set callback function for adjustPercentage request.
Definition: PercentageController.h:77
◆ SetPercentageCallback
Callback definition for onSetPercentage function.
Gets called when device receive a setPercentage
request
- Parameters
-
[in] | deviceId | String which contains the ID of device |
[in] | percentage | Integer with percentage device should set to |
[out] | percentage | Integer with percentage device has been set to |
- Returns
- the success of the request
- Return values
-
true | request handled properly |
false | request was not handled properly because of some error |
Example-Code
Serial.printf("Device %s percentage %d\r\n", deviceId.c_str(), percentage);
return true;
}
void onSetPercentage(SetPercentageCallback cb)
Set callback function for setPercentage request.
Definition: PercentageController.h:67
◆ onAdjustPercentage()
Set callback function for adjustPercentage
request.
- Parameters
-
cb | Function pointer to a AdjustPercentageCallback function |
- Returns
- void
- See also
- AdjustPercentageCallback
◆ onSetPercentage()
Set callback function for setPercentage
request.
- Parameters
-
cb | Function pointer to a SetPercentageCallback function |
- Returns
- void
- See also
- SetPercentageCallback
◆ sendSetPercentageEvent()
bool sendSetPercentageEvent |
( |
int |
percentage, |
|
|
String |
cause = "PHYSICAL_INTERACTION" |
|
) |
| |
Send setPercentage
event to SinricPro Server indicating actual percentage has changed.
- Parameters
-
percentage | Integer reporting the percentage that the device have been set to |
cause | (optional) Reason why event is sent (default = "PHYSICAL_INTERACTION" ) |
- Returns
- the success of sending the event
- Return values
-
true | event has been sent successfully |
false | event has not been sent, maybe you sent to much events in a short distance of time |