ToggleController.
More...
template<typename T>
class ToggleController< T >
ToggleController.
◆ GenericToggleStateCallback
Callback definition for onToggleState function.
Gets called when device receive a setPowerState
reuqest
- Parameters
-
[in] | deviceId | String which contains the ID of device |
[in] | instance | String which instance is requested |
[in] | state | true = device is requested to turn on
false = device is requested to turn off |
[out] | state | true = device has been turned on
false = device has been turned off |
- Returns
- the success of the request
- Return values
-
true | request handled properly |
false | request was not handled properly because of some error |
Example-Code
bool onToggleState(
const String &deviceId,
const String &instance,
bool &state) {
Serial.printf("Device %s state \"%s\" turned %s\r\n", deviceId.c_str(), instance.c_str(), state ? "on" : "off");
return true;
}
void onToggleState(const String &instance, GenericToggleStateCallback cb)
Set callback function for toggleState request.
Definition: ToggleController.h:50
◆ onToggleState()
Set callback function for toggleState
request.
- Parameters
-
instance | String instance name (custom device) |
cb | Function pointer to a ToggleStateCallback function |
- Returns
- void
- See also
- ToggleStateCallback
◆ sendToggleStateEvent()
bool sendToggleStateEvent |
( |
const String & |
instance, |
|
|
bool |
state, |
|
|
String |
cause = "PHYSICAL_INTERACTION" |
|
) |
| |
Send setToggleState
event to SinricPro Server indicating actual toggle state.
- Parameters
-
instance | String instance name (custom device) |
state | true = state turned on
false = tate turned off |
cause | (optional) String reason why event is sent (default = "PHYSICAL_INTERACTION" ) |
- Returns
- the success of sending the even
- 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 |