PowerStateController.
More...
|
using | PowerStateCallback = std::function< bool(const String &, bool &)> |
| Callback definition for onPowerState function. More...
|
|
template<typename T>
class PowerStateController< T >
PowerStateController.
◆ PowerStateCallback
Callback definition for onPowerState function.
Gets called when device receive a setPowerState
reuqest
- Parameters
-
[in] | deviceId | String which contains the ID of device |
[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
Serial.printf("Device %s turned %s\r\n", deviceId.c_str(), state?"on":"off");
return true;
}
void onPowerState(PowerStateCallback cb)
Set callback function for powerState request.
Definition: PowerStateController.h:47
◆ onPowerState()
Set callback function for powerState
request.
- Parameters
-
cb | Function pointer to a PowerStateCallback function |
- Returns
- void
- See also
- PowerStateCallback
◆ sendPowerStateEvent()
bool sendPowerStateEvent |
( |
bool |
state, |
|
|
String |
cause = "PHYSICAL_INTERACTION" |
|
) |
| |
Send setPowerState
event to SinricPro Server indicating actual power state.
- Parameters
-
state | true = device turned on
false = device 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 |