SinricPro Library
SinricProBlinds

Device to control interior blinds. More...

Inheritance diagram for SinricProBlinds:
SinricProDevice

Public Types

typedef std::function< bool(const String &, int &)> SetPositionCallback
 Callback definition for onSetPosition function. More...
 
typedef std::function< bool(const String &, int &)> AdjustPositionCallback
 Callback definition for onAdjustPosition function. More...
 
typedef std::function< bool(const String &, bool &)> PowerStateCallback
 Callback definition for onPowerState function. More...
 

Public Member Functions

void onSetPosition (SetPositionCallback cb)
 Set callback function for setPosition request. More...
 
void onAdjustPosition (AdjustPositionCallback cb)
 Set callback function for adjustPosition request. More...
 
bool sendPositionEvent (int position, String cause="PHYSICAL_INTERACTION")
 Send setPosition event to update actual position on SinricPro Server. More...
 
virtual 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...
 

Detailed Description

Device to control interior blinds.

Supporting

  • On / Off
  • Position (0..100)
  • open / close

Member Typedef Documentation

◆ AdjustPositionCallback

typedef std::function<bool(const String&, int&)> AdjustPositionCallback

Callback definition for onAdjustPosition function.

Gets called when device receive a setPowerState request

Parameters
[in]deviceIdString which contains the ID of device
[in]positionDeltaRelative integer value the device should change the position of the blinds about (-100..+100)
[out]positionDeltaAbsolute integer value with the new blinds position (0..100)
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

int blindsPosition;
bool onAdjustPosition(const String &deviceId, int &positionDelta) {
blindsPosition += positionDelta;
Serial.printf("Device %s position changed about %i to %d\r\n", deviceId.c_str(), positionDelta, blindsPosition);
positionDelta = blindsPosition;
return true;
}

◆ PowerStateCallback

typedef std::function<bool(const String&, bool&)> PowerStateCallback
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
}

◆ SetPositionCallback

typedef std::function<bool(const String&, int&)> SetPositionCallback

Callback definition for onSetPosition function.

Gets called when device receive a setPosition request

Parameters
[in]deviceIdString which contains the ID of device
[in]positionAbsolute integer value with desired blinds position
[out]positionAbsolute integer value with actual blinds position
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onSetPosition(const String &deviceId, int &position) {
Serial.printf("Device %s set position to %d\r\n", deviceId.c_str(), position);
return true;
}

Member Function Documentation

◆ onAdjustPosition()

void onAdjustPosition ( AdjustPositionCallback  cb)

Set callback function for adjustPosition request.

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

◆ onPowerState()

void onPowerState ( PowerStateCallback  cb)
virtualinherited

Set callback function for powerState request.

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

◆ onSetPosition()

void onSetPosition ( SetPositionCallback  cb)

Set callback function for setPosition request.

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

◆ sendPositionEvent()

bool sendPositionEvent ( int  position,
String  cause = "PHYSICAL_INTERACTION" 
)

Send setPosition event to update actual position on SinricPro Server.

Parameters
position0 = blinds are closed
100 = blinds are open
cause(optional) String reason why event is sent (default = "PHYSICAL_INTERACTION")
Returns
the success of sending the even
Return values
0..100actual blinds position

◆ 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
SinricProBlinds::onSetPosition
void onSetPosition(SetPositionCallback cb)
Set callback function for setPosition request.
Definition: SinricProBlinds.h:105
SinricProBlinds::onAdjustPosition
void onAdjustPosition(AdjustPositionCallback cb)
Set callback function for adjustPosition request.
Definition: SinricProBlinds.h:116
SinricProDevice::onPowerState
virtual void onPowerState(PowerStateCallback cb)
Set callback function for powerState request.
Definition: SinricProDevice.h:157