SinricPro Library
SinricProWindowAC

Device to control Window Air Conditioner. More...

Inheritance diagram for SinricProWindowAC:

Public Types

using PowerStateCallback = std::function< bool(const String &, bool &)>
 Callback definition for onPowerState function. More...
 
using SetRangeValueCallback = std::function< bool(const String &, int &)>
 Callback definition for onRangeValue function. More...
 
using GenericSetRangeValueCallback = std::function< bool(const String &, const String &, int &)>
 Callback definition for onRangeValue function on a specific instance. More...
 
using AdjustRangeValueCallback = std::function< bool(const String &, int &)>
 Callback definition for onAdjustRangeValue function. More...
 
using GenericAdjustRangeValueCallback = std::function< bool(const String &, const String &, int &)>
 Callback definition for onAdjustRangeValue function on a specific instance for custom devices. More...
 
using ThermostatModeCallback = std::function< bool(const String &, String &)>
 Callback definition for onThermostatMode function. More...
 
using SetTargetTemperatureCallback = std::function< bool(const String &, float &)>
 Callback definition for onTargetTemperature function. More...
 
using AdjustTargetTemperatureCallback = std::function< bool(const String &, float &)>
 Callback definition for onAdjustTargetTemperature 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...
 
void onRangeValue (SetRangeValueCallback cb)
 Set callback function for setRangeValue request. More...
 
void onRangeValue (const String &instance, GenericSetRangeValueCallback cb)
 Set callback function for setRangeValue request on a specific instance (custom device) More...
 
void onAdjustRangeValue (AdjustRangeValueCallback cb)
 Set callback function for adjustRangeValue request. More...
 
bool sendRangeValueEvent (int rangeValue, String cause="PHYSICAL_INTERACTION")
 Send rangeValue event to report curent rangeValue to SinricPro server. More...
 
bool sendRangeValueEvent (const String &instance, int rangeValue, String cause="PHYSICAL_INTERACTION")
 Send rangeValue event to report curent rangeValue to SinricPro server for a specific instance (custom device) More...
 
void onThermostatMode (ThermostatModeCallback cb)
 Set callback function for setThermostatMode request. More...
 
void onTargetTemperature (SetTargetTemperatureCallback cb)
 Set callback function for targetTemperature request. More...
 
void onAdjustTargetTemperature (AdjustTargetTemperatureCallback cb)
 Set callback function for adjustTargetTemperature request. More...
 
bool sendThermostatModeEvent (String thermostatMode, String cause="PHYSICAL_INTERACTION")
 Send thermostatMode event to report a the new mode the device has been set to. More...
 
bool sendTargetTemperatureEvent (float temperature, String cause="PHYSICAL_INTERACTION")
 Send targetTemperature event to report target temperature change. More...
 

Detailed Description

Device to control Window Air Conditioner.

Support

  • Set / adjust target temperature
  • Set mode AUTO, COOL, HEAT
  • Set range value
  • Report target temperature
  • Report actual temperature

Member Typedef Documentation

◆ AdjustRangeValueCallback

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

Callback definition for onAdjustRangeValue function.

Gets called when device receive a adjustRangeValue reuqest

Parameters
[in]deviceIdString which contains the ID of device
[in]rangeValueInteger -3..3 delta value for range value have to change
[out]rangeValueInteger 3..3 returning the absolute range value
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

int globalRangeValue;
bool onAdjustRangeValue(const String &deviceId, int &rangeValueDelta) {
globalRangeValue += rangeValue; // calculate absolute rangeValue
Serial.printf("Device %s range value has been changed about %i to %d\r\n", deviceId.c_str(), rangeValueDelta, globalRangeValue);
rangeValueDelta = globalRangeValue; // return absolute rangeValue
return true; // request handled properly
}
void onAdjustRangeValue(AdjustRangeValueCallback cb)
Set callback function for adjustRangeValue request.
Definition: RangeController.h:129

◆ AdjustTargetTemperatureCallback

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

Callback definition for onAdjustTargetTemperature function.

Gets called when device receive a adjustTargetTemperature reuqest

Parameters
[in]deviceIdString which contains the ID of device
[in]temperatureFloat relative temperature device should change about
[out]temperatureFloat absolute temperature device is set to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

float globalTargetTemp;
bool onAdjustTargetTemperature(const String &deviceId, float &tempDelta) {
globalTargetTemp += tempDelta; // change global target temperature about tempDelta
Serial.printf("Device %s target temperature changed about %f to %f\r\n", deviceId.c_str(), tempDelta, globalTargetTemp);
tempDelta = globalTargetTemp; // return absolute target temperature
return true; // request handled properly
}
void onAdjustTargetTemperature(AdjustTargetTemperatureCallback cb)
Set callback function for adjustTargetTemperature request.
Definition: ThermostatController.h:110

◆ GenericAdjustRangeValueCallback

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

Callback definition for onAdjustRangeValue function on a specific instance for custom devices.

Gets called when device receive a adjustRangeValue reuqest

Parameters
[in]deviceIdString which contains the ID of device
[in]instanceString instance name
[in]rangeValueInteger -3..3 delta value for range value have to change
[out]rangeValueInteger 3..3 returning the absolute range value
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

int globalRangeValue;
bool onAdjustRangeValue(const String &deviceId, const String& instance, int &rangeValueDelta) {
globalRangeValue += rangeValueDelta; // calculate absolute rangeValue
Serial.printf("Device %s range value for %s has been changed about %i to %d\r\n", deviceId.c_str(), instance.c_str(), rangeValueDelta, globalRangeValue);
rangeValueDelta = globalRangeValue; // return absolute rangeValue
return true; // request handled properly
}

◆ GenericSetRangeValueCallback

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

Callback definition for onRangeValue function on a specific instance.

Gets called when device receive a setRangeValue reuqest

Parameters
[in]deviceIdString which contains the ID of device
[in]instanceString instance name
[in]rangeValueInteger 0..3 for range value device has to be set
[out]rangeValueInteger 0..3 returning the current range value
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onRangeValue(const String &deviceId, const String &instance, int &rangeValue) {
Serial.printf("Device %s range value for %s has been set to %d\r\n", deviceId.c_str(), instance.c_str(), rangeValue);
return true; // request handled properly
}
void onRangeValue(SetRangeValueCallback cb)
Set callback function for setRangeValue request.
Definition: RangeController.h:106

◆ 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

◆ SetRangeValueCallback

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

Callback definition for onRangeValue function.

Gets called when device receive a setRangeValue reuqest

Parameters
[in]deviceIdString which contains the ID of device
[in]rangeValueInteger 0..3 for range value device has to be set
[out]rangeValueInteger 0..3 returning the current range value
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onRangeValue(const String &deviceId, int &rangeValue) {
Serial.printf("Device %s range value has been set to %d\r\n", deviceId.c_str(), rangeValue);
return true; // request handled properly
}

◆ SetTargetTemperatureCallback

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

Callback definition for onTargetTemperature function.

Gets called when device receive a targetTemperature request

Parameters
[in]deviceIdString which contains the ID of device
[in]temperatureFloat device is requested to set the target temperature to
[out]temperatureFloat target temperature temperature device is set to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onTargetTemperature(const String &deviceId, float &targetTemp) {
Serial.printf("Device %s target temperature set to %f\r\n", deviceId.c_str(), targetTemp);
return true; // request handled properly
}
void onTargetTemperature(SetTargetTemperatureCallback cb)
Set callback function for targetTemperature request.
Definition: ThermostatController.h:98

◆ ThermostatModeCallback

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

Callback definition for onThermostatMode function.

Gets called when device receive a setThermostatMode request

Parameters
[in]deviceIdString which contains the ID of device
[in]modeString with mode device should set to
[out]modeString device mode is set to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onThermostatMode(const String& deviceId, String& mode) {
Serial.printf("Deivce %s thermostat mode set to %s\r\n", deviceId.c_str(), mode);
return true; // request handled properly
}
void onThermostatMode(ThermostatModeCallback cb)
Set callback function for setThermostatMode request.
Definition: ThermostatController.h:86

Member Function Documentation

◆ onAdjustRangeValue()

void onAdjustRangeValue ( AdjustRangeValueCallback  cb)
inherited

Set callback function for adjustRangeValue request.

Parameters
cbFunction pointer to a AdjustRangeValueCallback function
See also
AdjustRangeValueCallback

◆ onAdjustTargetTemperature()

void onAdjustTargetTemperature ( AdjustTargetTemperatureCallback  cb)
inherited

Set callback function for adjustTargetTemperature request.

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

◆ onPowerState()

void onPowerState ( PowerStateCallback  cb)
inherited

Set callback function for powerState request.

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

◆ onRangeValue() [1/2]

void onRangeValue ( const String &  instance,
GenericSetRangeValueCallback  cb 
)
inherited

Set callback function for setRangeValue request on a specific instance (custom device)

Parameters
instanceString instance name (custom device)
cbFunction pointer to a GenericSetRangeValueCallback function
See also
GenericSetRangeValueCallback

◆ onRangeValue() [2/2]

void onRangeValue ( SetRangeValueCallback  cb)
inherited

Set callback function for setRangeValue request.

Parameters
cbFunction pointer to a SetRangeValueCallback function
See also
SetRangeValueCallback

◆ onTargetTemperature()

void onTargetTemperature ( SetTargetTemperatureCallback  cb)
inherited

Set callback function for targetTemperature request.

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

◆ onThermostatMode()

void onThermostatMode ( ThermostatModeCallback  cb)
inherited

Set callback function for setThermostatMode request.

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

◆ 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

◆ sendRangeValueEvent() [1/2]

bool sendRangeValueEvent ( const String &  instance,
int  rangeValue,
String  cause = "PHYSICAL_INTERACTION" 
)
inherited

Send rangeValue event to report curent rangeValue to SinricPro server for a specific instance (custom device)

Parameters
instanceString instance name
rangeValueValue between 0..3
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

◆ sendRangeValueEvent() [2/2]

bool sendRangeValueEvent ( int  rangeValue,
String  cause = "PHYSICAL_INTERACTION" 
)
inherited

Send rangeValue event to report curent rangeValue to SinricPro server.

Parameters
rangeValueValue between 0..3
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

◆ sendTargetTemperatureEvent()

bool sendTargetTemperatureEvent ( float  temperature,
String  cause = "PHYSICAL_INTERACTION" 
)
inherited

Send targetTemperature event to report target temperature change.

Parameters
temperatureFloat with actual target temperature the device is set to
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

◆ sendThermostatModeEvent()

bool sendThermostatModeEvent ( String  thermostatMode,
String  cause = "PHYSICAL_INTERACTION" 
)
inherited

Send thermostatMode event to report a the new mode the device has been set to.

Parameters
thermostatModeString with actual mode (AUTO, COOL, HEAT) the device is set to
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