SinricPro Library
SinricProTemperaturesensor

Device to report actual temperature and humidity. More...

Inheritance diagram for SinricProTemperaturesensor:

Public Types

using PowerStateCallback = std::function< bool(const String &, bool &)>
 Callback definition for onPowerState function. More...
 

Public Member Functions

void onPowerState (PowerStateCallback cb)
 Set callback function for powerState request. More...
 
bool sendPowerStateEvent (bool state, String cause="PHYSICAL_INTERACTION")
 Send setPowerState event to SinricPro Server indicating actual power state. More...
 
bool sendTemperatureEvent (float temperature, float humidity=-1, String cause="PERIODIC_POLL")
 Send currentTemperature event to report actual temperature (measured by a sensor) More...
 

Detailed Description

Device to report actual temperature and humidity.

Member Typedef Documentation

◆ PowerStateCallback

using PowerStateCallback = std::function<bool(const String &, bool &)>
inherited

Callback definition for onPowerState function.

Gets called when device receive a setPowerState reuqest

Parameters
[in]deviceIdString which contains the ID of device
[in]statetrue = device is requested to turn on
false = device is requested to turn off
[out]statetrue = device has been turned on
false = device has been turned off
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onPowerState(const String &deviceId, bool &state) {
Serial.printf("Device %s turned %s\r\n", deviceId.c_str(), state?"on":"off");
return true; // request handled properly
}
void onPowerState(PowerStateCallback cb)
Set callback function for powerState request.
Definition: PowerStateController.h:47

Member Function Documentation

◆ onPowerState()

void onPowerState ( PowerStateCallback  cb)
inherited

Set callback function for powerState request.

Parameters
cbFunction pointer to a PowerStateCallback function
Returns
void
See also
PowerStateCallback

◆ sendPowerStateEvent()

bool sendPowerStateEvent ( bool  state,
String  cause = "PHYSICAL_INTERACTION" 
)
inherited

Send setPowerState event to SinricPro Server indicating actual power state.

Parameters
statetrue = 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
trueevent has been sent successfully
falseevent has not been sent, maybe you sent to much events in a short distance of time

◆ sendTemperatureEvent()

bool sendTemperatureEvent ( float  temperature,
float  humidity = -1,
String  cause = "PERIODIC_POLL" 
)
inherited

Send currentTemperature event to report actual temperature (measured by a sensor)

Parameters
temperaturefloat actual temperature measured by a sensor
humidityfloat (optional) actual humidity measured by a sensor (default=-1.0f means not supported)
cause(optional) String reason why event is sent (default = "PERIODIC_POLL")
Returns
the success of sending the even
Return values
trueevent has been sent successfully
falseevent has not been sent, maybe you sent to much events in a short distance of time