SinricPro Library
Loading...
Searching...
No Matches
SINRICPRO_3_0_0 Namespace Reference

SinricPro namespace. More...

Classes

class  AirQualitySensor
 AirQuality. More...
 
class  BrightnessController
 BrightnessController. More...
 
class  ChannelController
 ChannelController. More...
 
class  ColorController
 ColorController. More...
 
class  ColorTemperatureController
 ColorTemperatureController. More...
 
class  ContactSensor
 ContactSensor. More...
 
class  Doorbell
 Dorbell. More...
 
class  DoorController
 DoorController - only used for GarageDoor device and cannot used as capability for a custom device! More...
 
class  EqualizerController
 EqualizerController. More...
 
class  InputController
 InputController. More...
 
class  KeypadController
 KeypadController. More...
 
class  LockController
 LockController. More...
 
class  MediaController
 MediaController. More...
 
class  ModeController
 ModeController. More...
 
class  MotionSensor
 MotionSensor. More...
 
class  MuteController
 MuteController. More...
 
class  PercentageController
 PercentageController. More...
 
class  PowerLevelController
 PowerLevelController. More...
 
class  PowerSensor
 PowerSensor. More...
 
class  PowerStateController
 PowerStateController. More...
 
class  PushNotification
 PushNotification. More...
 
class  RangeController
 RangeControllerFloatInt. More...
 
class  SinricProAirQualitySensor
 Device to report air quality events. More...
 
class  SinricProBlinds
 Device to control interior blinds. More...
 
class  SinricProCamera
 Camera suporting basic on / off command. More...
 
class  SinricProClass
 The main class of this library, handling communication between SinricPro Server and your devices. More...
 
class  SinricProContactsensor
 Device to report contact sensor events. More...
 
class  SinricProDevice
 Base class for all device types. More...
 
class  SinricProDimSwitch
 Device which supports on / off and dimming commands. More...
 
class  SinricProDoorbell
 Device to report doorbell events. More...
 
class  SinricProFan
 Device to turn on / off a fan and change it's speed by using powerlevel. More...
 
class  SinricProFanUS
 Device to control a fan with on / off commands and its speed by a range value. More...
 
class  SinricProGarageDoor
 Device to control a garage door. More...
 
class  SinricProLight
 Device to control a light. More...
 
class  SinricProLock
 Device to control a smart lock. More...
 
class  SinricProMotionsensor
 Device to report motion detection events. More...
 
class  SinricProPowerSensor
 Device to report power usage. More...
 
class  SinricProSpeaker
 Device to control a smart speaker. More...
 
class  SinricProSwitch
 Device suporting basic on / off command. More...
 
class  SinricProTemperaturesensor
 Device to report actual temperature and humidity. More...
 
class  SinricProThermostat
 Device to control Thermostat. More...
 
class  SinricProTV
 Device to control a TV. More...
 
class  SinricProWindowAC
 Device to control Window Air Conditioner. More...
 
class  TemperatureSensor
 TemperatureSensor. More...
 
class  ThermostatController
 ThermostatController. More...
 
class  ToggleController
 ToggleController. More...
 
class  VolumeController
 VolumeController. More...
 

Typedefs

using ConnectedCallbackHandler = std::function< void(void)>
 Callback definition for onConnected function.
 
using DisconnectedCallbackHandler = std::function< void(void)>
 Callback definition for onDisconnected function.
 
using BrightnessCallback = std::function< bool(const String &, int &)>
 Callback definition for onBrightness function.
 
using AdjustBrightnessCallback = std::function< bool(const String &, int &)>
 Callback definition for onAdjustBrightness function.
 
using ChangeChannelCallback = std::function< bool(const String &, String &)>
 Callback definition for onChangeChannel function.
 
using ChangeChannelNumberCallback = std::function< bool(const String &, int, String &)>
 Callback definition for onChangeChannelNumber function.
 
using SkipChannelsCallback = std::function< bool(const String &, int, String &)>
 Callback definition for onSkipChannels function.
 
using ColorCallback = std::function< bool(const String &, byte &, byte &, byte &)>
 Callback definition for onColor function.
 
using ColorTemperatureCallback = std::function< bool(const String &, int &)>
 Callback definition for onColorTemperature function.
 
using IncreaseColorTemperatureCallback = std::function< bool(const String &, int &)>
 Callback definition for onIncreaseColorTemperature function.
 
using DecreaseColorTemperatureCallback = std::function< bool(const String &, int &)>
 Callback definition for onDecreaseColorTemperature function.
 
using DoorCallback = std::function< bool(const String &, bool &)>
 Callback definition for onDoorState function.
 
using SetBandsCallback = std::function< bool(const String &, const String &, int &)>
 Callback definition for onSetBands function.
 
using AdjustBandsCallback = std::function< bool(const String &, const String &, int &)>
 Callback definition for onAdjustBands function.
 
using ResetBandsCallback = std::function< bool(const String &, const String &, int &)>
 Callback definition for onResetBands function.
 
using SelectInputCallback = std::function< bool(const String &, String &)>
 Callback definition for onSelectInput function.
 
using KeystrokeCallback = std::function< bool(const String &, String &)>
 Callback definition for onKeystroke function.
 
using LockStateCallback = std::function< bool(const String &, bool &)>
 Callback definition for onLockState function.
 
using MediaControlCallback = std::function< bool(const String &, String &)>
 Callback definition for onMediaControl function.
 
using ModeCallback = std::function< bool(const String &, String &)>
 Callback definition for onSetMode function.
 
using GenericModeCallback = std::function< bool(const String &, const String &, String &)>
 Callback definition for onSetMode function for a specific instance.
 
using MuteCallback = std::function< bool(const String &, bool &)>
 Callback definition for onMute function.
 
using SetPercentageCallback = std::function< bool(const String &, int &)>
 Callback definition for onSetPercentage function.
 
using AdjustPercentageCallback = std::function< bool(const String &, int &)>
 Callback definition for onAdjustPercentage function.
 
using SetPowerLevelCallback = std::function< bool(const String &, int &)>
 Definition for setPowerLevel callback.
 
using AdjustPowerLevelCallback = std::function< bool(const String &, int &)>
 Definition for onAdjustPowerLevel callback.
 
using PowerStateCallback = std::function< bool(const String &, bool &)>
 Callback definition for onPowerState function.
 
using GenericRangeValueCallback_int = bool(*)(const String &, const String &, int &)
 Callback definition for onRangeValue function.
 
using GenericSetRangeValueCallback_int = GenericRangeValueCallback_int
 Callback definition for onRangeValue function on a specific instance.
 
using AdjustRangeValueCallback = bool(*)(const String &, int &)
 Callback definition for onAdjustRangeValue function.
 
using GenericAdjustRangeValueCallback_int = GenericRangeValueCallback_int
 Callback definition for onAdjustRangeValue function on a specific instance for custom devices.
 
using ThermostatModeCallback = std::function< bool(const String &, String &)>
 Callback definition for onThermostatMode function.
 
using SetTargetTemperatureCallback = std::function< bool(const String &, float &)>
 Callback definition for onTargetTemperature function.
 
using AdjustTargetTemperatureCallback = std::function< bool(const String &, float &)>
 Callback definition for onAdjustTargetTemperature function.
 
using GenericToggleStateCallback = std::function< bool(const String &, const String &, bool &)>
 Callback definition for onToggleState function.
 
using SetVolumeCallback = std::function< bool(const String &, int &)>
 Callback definition for onSetVolume function.
 
using AdjustVolumeCallback = std::function< bool(const String &, int &, bool)>
 Callback definition for onAdjustVolume function.
 

Detailed Description

SinricPro namespace.

Typedef Documentation

◆ AdjustBandsCallback

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

Callback definition for onAdjustBands function.

Gets called when device receive a adjustBands request

Parameters
[in]deviceIdString which contains the ID of device
[in]bandsString with requested bands to change
BASS, MIDRANGE, TREBBLE
[in]levelDeltaInteger with relative level value device should change bands about
[out]bandsString with changed bands
BASS, MIDRANGE, TREBBLE
[out]levelDeltaInteger value with level bands changed to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

std::map<String, int> equalizerBands;
bool onAdjustBands(const String &deviceId, String &bands, int &levelDelta) {
equalizerBands[bands] += levelDelta; // calculate absolute bands level
Serial.printf("Device %s bands %s changed about %d to %d\r\n", deviceId.c_str(), bands.c_str(), levelDelta, equalizerBands[bands]);
levelDelta = equalizerBands[bands]; // return absolute bands level
return true; // request handled properly
}
AirQuality.
Definition AirQualitySensor.h:19

◆ AdjustBrightnessCallback

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

Callback definition for onAdjustBrightness function.

Gets called when device receive a adjustBrightness request

Parameters
[in]deviceIdString which contains the ID of device
[in]brightnessRelative integer value the device should change the brightness about
[out]brightnessAbsolute integer value with new brightness the 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 onAdjustBrightness(const String &deviceId, int &brightnessDelta) {
absoluteBrightness += brightnessDelta; // calculate absolute brigthness
Serial.printf("Device %s brightness changed about %i to %d\r\n", deviceId.c_str(), brightnessDelta, absoluteBrightness);
brightnessDelta = absoluteBrightness; // return absolute brightness
return true; // request handled properly
}

◆ AdjustPercentageCallback

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

Callback definition for onAdjustPercentage function.

Gets called when device receive a adjustPercentage request

Parameters
[in]deviceIdString which contains the ID of device
[in]percentageDeltaInteger with relative percentage the device should change about (-100..100)
[out]percentageDeltaInteger with absolute percentage device has been 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 onAdjustPercentage(const String &deviceId, int &percentageDelta) {
absolutePercentage += percentageDelta; // calculate absolute percentage
Serial.printf("Device %s percentage changed about %i to %d\r\n", deviceId.c_str(), percentageDelta, absolutePercentage);
percentageDelta = absolutePercentage; // return absolute percentage
return true; // request handled properly
}

◆ AdjustPowerLevelCallback

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

Definition for onAdjustPowerLevel callback.

Gets called when device receive a adjustPowerLevel reuqest

Parameters
[in]deviceIdString which contains the ID of device
[in]powerLevelinteger -100..100 delta value which power level have to be changed
[out]powerLevelinteger 0..100 report the absolute powerlevel that the device have been set to
Returns
the success of the request
Return values
truerequest handled properly
falserequest can`t be handled properly because of some error

Example-Code

bool onAdjustPowerLevel(const String &deviceId, int &powerDelta) {
absolutePowerLevel += powerDelta; // calculate absolute power level
Serial.printf("Device %s brightness changed about %i to %d\r\n", deviceId.c_str(), powerDelta, absolutePowerLevel);
powerDelta = absolutePowerLevel; // return absolute power level
return true; // request handled properly
}

◆ AdjustRangeValueCallback

using AdjustRangeValueCallback = bool (*)(const String &, int &)

Callback definition for onAdjustRangeValue function.

Gets called when device receive a adjustRangeValue reuqest

Parameters
[in]deviceIdString which contains the ID of device
[in]rangeValuedelta value for range value have to change
[out]rangeValuereturning 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

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
}

◆ AdjustTargetTemperatureCallback

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

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

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
}

◆ AdjustVolumeCallback

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

Callback definition for onAdjustVolume function.

Gets called when device receive a adjustVolume request

Parameters
[in]deviceIdString which contains the ID of device
[in]volumeDeltaInteger with relative volume the device should change about (-100..100)
[out]volumeDeltaInteger with absolute volume device has been set to
[in]volumeDefaultBool false if the user specified the amount by which to change the volume; otherwise true
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onAdjustVolume(const String &deviceId, int &volumeDelta, bool volumeDefault) {
absoluteVolume += volumeDelta; // calculate absolute volume
Serial.printf("Device %s volume changed about %i to %d (default: %s)\r\n", deviceId.c_str(), volumeDelta, absoluteVolume, volumeDefault);
volumeDelta = absoluteVolume; // return absolute volume
return true; // request handled properly
}

◆ BrightnessCallback

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

Callback definition for onBrightness function.

Gets called when device receive a setBrightness request

Parameters
[in]deviceIdString which contains the ID of device
[in]brightnessAbsolute integer value the device should set its brightness to
[out]brightnessAbsolute integer value with new brightness the 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 onBrightness(const String &deviceId, int &brightness) {
Serial.printf("Device %s brightness %d\r\n", deviceId.c_str(), brightness);
return true; // request handled properly
}

◆ ChangeChannelCallback

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

Callback definition for onChangeChannel function.

Gets called when device receive a changeChannel request by using channel name

Parameters
[in]deviceIdString which contains the ID of device
[in]channelString with channel name device is requested to switch to
[out]channelString with channel name device has switchted to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

// channelNames used to convert channelNumber into channelName
// please put in your TV channel names
// channel numbers starts counting from 0!
// so "ZDF" is channel 2
const char* channelNames[] = {
"A/V",
"ard",
"ZDF",
"n. d. r.",
"kabel eins",
"VOX",
"Sat.1",
"ProSieben",
"rtl",
"RTL II",
"SUPER RTL",
"KiKA"
};
int tvChannel; // current channel selected
#define MAX_CHANNELS sizeof(channelNames) / sizeof(channelNames[0]) // just to determine how many channels are in channelNames array
// map channelNumbers used to convert channelName into channelNumber
// This map is initialized in "setupChannelNumbers()" function by using the "channelNames" array
std::map<String, unsigned int> channelNumbers;
void setupChannelNumbers() {
for (unsigned int i=0; i < MAX_CHANNELS; i++) {
channelNumbers[channelNames[i]] = i;
}
}
bool onChangeChannel(const String &deviceId, String &channel) {
tvChannel = channelNumbers[channel]; // save new channelNumber in tvChannel variable
Serial.printf("Change channel to \"%s\" (channel number %d)\r\n", channel.c_str(), tvChannel);
return true;
}

◆ ChangeChannelNumberCallback

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

Callback definition for onChangeChannelNumber function.

Gets called when device receive a changeChannel request by using channel number

Parameters
[in]deviceIdString which contains the ID of device
[in]channelNumberInteger with channel number device is requested to switch to
[out]channelNameString with channel name device has switchted to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

// channelNames used to convert channelNumber into channelName
// please put in your TV channel names
// channel numbers starts counting from 0!
// so "ZDF" is channel 2
const char* channelNames[] = {
"A/V",
"ard",
"ZDF",
"n. d. r.",
"kabel eins",
"VOX",
"Sat.1",
"ProSieben",
"rtl",
"RTL II",
"SUPER RTL",
"KiKA"
};
int tvChannel; // current channel selected
#define MAX_CHANNELS sizeof(channelNames) / sizeof(channelNames[0]) // just to determine how many channels are in channelNames array
// map channelNumbers used to convert channelName into channelNumber
// This map is initialized in "setupChannelNumbers()" function by using the "channelNames" array
std::map<String, unsigned int> channelNumbers;
void setupChannelNumbers() {
for (unsigned int i=0; i < MAX_CHANNELS; i++) {
channelNumbers[channelNames[i]] = i;
}
}
bool onChangeChannelNumber(const String& deviceId, int channelNumber, String& channelName) {
tvChannel = channelNumber; // update tvChannel to new channel number
if (tvChannel < 0) tvChannel = 0;
if (tvChannel > MAX_CHANNELS-1) tvChannel = MAX_CHANNELS-1;
channelName = channelNames[tvChannel]; // return the channelName
Serial.printf("Change to channel to %d (channel name \"%s\")\r\n", tvChannel, channelName.c_str());
return true;
}

◆ ColorCallback

using ColorCallback = std::function<bool(const String &, byte &, byte &, byte &)>

Callback definition for onColor function.

Gets called when device receive a setColor request

Parameters
[in]deviceIdString which contains the ID of device
[in]rByte value for red
[in]gByte value for green
[in]bByte value for blue
[out]rByte value for red
[out]gByte value for green
[out]bByte value for blue
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onColor(const String &deviceId, byte &r, byte &g, byte &b) {
Serial.printf("Device %s color is set to red=%d, green=%d, blue=%d\r\n", deviceId.c_str(), r, g, b);
return true; // request handled properly
}

◆ ColorTemperatureCallback

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

Callback definition for onColorTemperature function.

Gets called when device receive a setColorTemperature request

Parameters
[in]deviceIdString which contains the ID of device
[in]colorTemperatureInteger value with color temperature the device should set to
2200 = warm white
2700 = soft white
4000 = white
5500 = daylight white
7000 = cool white
[out]colorTemperatureInteger value with color temperature the device is set to
2200 = warm white
2700 = soft white
4000 = white
5500 = daylight white
7000 = cool white
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onColorTemperature(const String &deviceId, int &colorTemperature) {
Serial.printf("Device %s colorTemperature is set to %i\r\n", deviceId.c_str(), colorTemperature);
return true; // request handled properly
}

◆ ConnectedCallbackHandler

Callback definition for onConnected function.

Gets called when device is connected to SinricPro server

Parameters
void
Returns
void

◆ DecreaseColorTemperatureCallback

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

Callback definition for onDecreaseColorTemperature function.

Gets called when device receive a decreaseColorTemperature request

Parameters
[in]deviceIdString which contains the ID of device
[in]colorTemperatureInteger value -1 = Device should decrease color temperature
[out]colorTemperatureInteger value return the new color temperarature
2200 = warm white
2700 = soft white
4000 = white
5500 = daylight white
7000 = cool white
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onDecreaseColorTemperature(const String &deviceId, int &colorTemperature) {
globalColorTemperature -= 1000; // decrease globalColorTemperature about 1000;
Serial.printf("Device %s colorTemperature changed %i\r\n", deviceId.c_str(), colorTemperature);
colorTemperature = globalColorTemperature; // return new colorTemperature
return true; // request handled properly
}

◆ DisconnectedCallbackHandler

Callback definition for onDisconnected function.

Gets called when device is disconnected from SinricPro server

Parameters
void
Returns
void

◆ DoorCallback

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

Callback definition for onDoorState function.

Gets called when device receive a open or close request

Parameters
[in]deviceIdString which contains the ID of device
[in]doorStatefalse = open, device is requested to open the garage door
true = close, device is requested to close the garage door
[out]doorStatebool with actual state false = open, true = closed
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onDoorState(const String &deviceId, bool &doorState) {
Serial.printf("Device %s garage door is now %s\r\n", deviceId.c_str(), doorState?"closed":"open");
return true;
}

◆ GenericAdjustRangeValueCallback_int

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]rangeValuedelta value for range value have to change
[out]rangeValuereturning 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

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
}

◆ GenericModeCallback

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

Callback definition for onSetMode function for a specific instance.

Gets called when device receive a setBands request

Parameters
[in]deviceIdString which contains the ID of device
[in]instanceString name of the instance
[in]modeString device mode should set to
[out]modeString devices 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 onSetMode(const String &deviceId, const String &instance, String &mode) {
Serial.printf("Device %s mode %s set to %s\r\n", deviceId.c_str(), instance.c_str(), mode);
return true; // request handled properly
}

◆ GenericRangeValueCallback_int

using GenericRangeValueCallback_int = bool (*)(const String &, const String &, int &)

Callback definition for onRangeValue function.

Gets called when device receive a setRangeValue reuqest

Parameters
[in]deviceIdString which contains the ID of device
[in]rangeValuefor range value device has to be set
[out]rangeValuereturning 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
}

◆ GenericSetRangeValueCallback_int

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]rangeValuefor range value device has to be set
[out]rangeValuereturning 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
}

◆ GenericToggleStateCallback

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

Callback definition for onToggleState function.

Gets called when device receive a setPowerState reuqest

Parameters
[in]deviceIdString which contains the ID of device
[in]instanceString which instance is requested
[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 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; // request handled properly
}

◆ IncreaseColorTemperatureCallback

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

Callback definition for onIncreaseColorTemperature function.

Gets called when device receive a increaseColorTemperature request

Parameters
[in]deviceIdString which contains the ID of device
[in]colorTemperatureInteger value 1 = Device should increase color temperature
[out]colorTemperatureInteger value return the new color temperarature
2200 = warm white
2700 = soft white
4000 = white
5500 = daylight white
7000 = cool white
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onIncreaseColorTemperature(const String &deviceId, int &colorTemperature) {
globalColorTemperature += 1000; // increase globalColorTemperature about 1000;
Serial.printf("Device %s colorTemperature changed to %i\r\n", deviceId.c_str(), colorTemperature);
colorTemperature = globalColorTemperature; // return new colorTemperature
return true; // request handled properly
}

◆ KeystrokeCallback

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

Callback definition for onKeystroke function.

Gets called when device receive a setBands request

Parameters
[in]deviceIdString which contains the ID of device
[in]keystrokeString keystroke
INFO, MORE, SELECT, UP, DOWN, LEFT, RIGHT, PAGE_UP, PAGE_DOWN, PAGE_LEFT, PAGE_RIGHT
[out]keystrokeString keystroke
INFO, MORE, SELECT, UP, DOWN, LEFT, RIGHT, PAGE_UP, PAGE_DOWN, PAGE_LEFT, PAGE_RIGHT
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onKeystroke(const String& deviceId, String &keystroke) {
Serial.printf("Device %s, key %s pressed\r\n", deviceId.c_str(), keystroke.c_str());
return true;
}

◆ LockStateCallback

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

Callback definition for onLockState function.

Gets called when device receive a setLockState request

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

Example-Code

bool onLockState(const String &deviceId, bool &lockState) {
Serial.printf("Device is %s\r\n", lockState?"locked":"unlocked");
return true;
}

◆ MediaControlCallback

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

Callback definition for onMediaControl function.

Gets called when device receive a mediaControl request

Parameters
[in]deviceIdString which contains the ID of device
[in]controlString with requested control
FastForward, Next, Pause, Play, Previous, Rewind, StartOver, Stop
[out]controlString with control
FastForward, Next, Pause, Play, Previous, Rewind, StartOver, Stop
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onMediaControl(const String &deviceId, String &control) {
Serial.printf("Device %s: %s\r\n", deviceId.c_str(), control.c_str());
return true; // request handled properly
}

◆ ModeCallback

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

Callback definition for onSetMode function.

Gets called when device receive a setBands request

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

Example-Code

bool onSetMode(const String &deviceId, String &mode) {
Serial.printf("Device %s is set to mode %s\r\n", deviceId.c_str(), mode);
return true; // request handled properly
}

◆ MuteCallback

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

Callback definition for onMute function.

Gets called when device receive a setMute request

Parameters
[in]deviceIdString which contains the ID of device
[in]mutetrue mute device
false unmute device
[out]mutetrue device is muted
false device is unmuted
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onMute(const String &deviceId, bool &mute) {
Serial.printf("Device %s is %s\r\n", deviceId.c_str(), mute?"muted":"unmuted");
return true; // request handled properly
}

◆ PowerStateCallback

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

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
}

◆ ResetBandsCallback

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

Callback definition for onResetBands function.

Gets called when device receive a onResetBands request

Parameters
[in]deviceIdString which contains the ID of device
[in]bandsString with requested bands to reset
BASS, MIDRANGE, TREBBLE
[out]bandsString with changed bands
BASS, MIDRANGE, TREBBLE
[out]levelInteger value with level bands changed to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

std::map<String, int> equalizerBands;
bool onResetBands(const String &deviceId, String &bands, int &level) {
equalizerBands[bands] = 0; // reset bands level to 0
Serial.printf("Device %s bands %s reset to %d\r\n", deviceId.c_str(), bands.c_str(), equalizerBands[bands]);
return true; // request handled properly
}

◆ SelectInputCallback

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

Callback definition for onSelectInput function.

Gets called when device receive a selectInput request

Parameters
[in]deviceIdString which contains the ID of device
[in]inputString with input name device is requested to switch to
AUX 1..AUX 7, BLURAY, CABLE, CD, COAX 1,COAX 2, COMPOSITE 1, DVD, GAME, HD RADIO, HDMI 1.. HDMI 10, HDMI ARC, INPUT 1..INPUT 10, IPOD, LINE 1..LINE 7, MEDIA PLAYER, OPTICAL 1, OPTICAL 2, PHONO, PLAYSTATION, PLAYSTATION 3, PLAYSTATION 4, SATELLITE, SMARTCAST, TUNER, TV, USB DAC, VIDEO 1..VIDEO 3, XBOX
[out]inputString with input name device has switchted to
AUX 1..AUX 7, BLURAY, CABLE, CD, COAX 1,COAX 2, COMPOSITE 1, DVD, GAME, HD RADIO, HDMI 1.. HDMI 10, HDMI ARC, INPUT 1..INPUT 10, IPOD, LINE 1..LINE 7, MEDIA PLAYER, OPTICAL 1, OPTICAL 2, PHONO, PLAYSTATION, PLAYSTATION 3, PLAYSTATION 4, SATELLITE, SMARTCAST, TUNER, TV, USB DAC, VIDEO 1..VIDEO 3, XBOX
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onSelectInput(const String &deviceId, String &input) {
Serial.printf("Device %s input changed to %s\r\n", deviceId.c_str(), input.c_str());
return true;
}

◆ SetBandsCallback

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

Callback definition for onSetBands function.

Gets called when device receive a setBands request

Parameters
[in]deviceIdString which contains the ID of device
[in]bandsString with requested bands to change
BASS, MIDRANGE, TREBBLE
[in]levelInteger value with level bands should set to
[out]bandsString with changed bands
BASS, MIDRANGE, TREBBLE
[out]levelInteger value with level bands changed to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

std::map<String, int> equalizerBands;
bool onSetBands(const String &deviceId, String &bands, int &level) {
Serial.printf("Device %s bands %s set to %d\r\n", deviceId.c_str(), bands.c_str(), level);
return true; // request handled properly
}

◆ SetPercentageCallback

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

Callback definition for onSetPercentage function.

Gets called when device receive a setPercentage request

Parameters
[in]deviceIdString which contains the ID of device
[in]percentageInteger with percentage device should set to
[out]percentageInteger with percentage device has been 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 onSetPercentage(const String &deviceId, int &percentage) {
Serial.printf("Device %s percentage %d\r\n", deviceId.c_str(), percentage);
return true; // request handled properly
}

◆ SetPowerLevelCallback

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

Definition for setPowerLevel callback.

Gets called when device receive a setPowerLevel reuqest

Parameters
[in]deviceIdString which contains the ID of device
[in]powerLevelinteger 0..100 new powerlevel the device should be set to
[out]powerLevelinteger 0..100 report the powerlevel that the device have been 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 onPowerLevel(const String &deviceId, int &powerLevel) {
Serial.printf("Device %s powerlevel %d\r\n", deviceId.c_str(), powerLevel);
return true; // request handled properly
}

◆ SetTargetTemperatureCallback

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

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
}

◆ SetVolumeCallback

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

Callback definition for onSetVolume function.

Gets called when device receive a setVolume request

Parameters
[in]deviceIdString which contains the ID of device
[in]volumeInteger with volume device should set to
[out]volumeInteger with volume device has been 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 onSetVolume(const String &deviceId, int &volume) {
Serial.printf("Device %s volume set to %d\r\n", deviceId.c_str(), volume);
return true; // request handled properly
}

◆ SkipChannelsCallback

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

Callback definition for onSkipChannels function.

Gets called when device receive a changeChannel request by using channel number

Parameters
[in]deviceIdString which contains the ID of device
[in]channelCountInteger with channels device is requested to skip -n..+n
[out]channelNameString with channel name device has switchted to
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

// channelNames used to convert channelNumber into channelName
// please put in your TV channel names
// channel numbers starts counting from 0!
// so "ZDF" is channel 2
const char* channelNames[] = {
"A/V",
"ard",
"ZDF",
"n. d. r.",
"kabel eins",
"VOX",
"Sat.1",
"ProSieben",
"rtl",
"RTL II",
"SUPER RTL",
"KiKA"
};
int tvChannel; // current channel selected
#define MAX_CHANNELS sizeof(channelNames) / sizeof(channelNames[0]) // just to determine how many channels are in channelNames array
// map channelNumbers used to convert channelName into channelNumber
// This map is initialized in "setupChannelNumbers()" function by using the "channelNames" array
std::map<String, unsigned int> channelNumbers;
void setupChannelNumbers() {
for (unsigned int i=0; i < MAX_CHANNELS; i++) {
channelNumbers[channelNames[i]] = i;
}
}
bool onSkipChannels(const String &deviceId, const int channelCount, String &channelName) {
tvChannel += channelCount; // calculate new channel number
if (tvChannel < 0) tvChannel = 0;
if (tvChannel > MAX_CHANNELS-1) tvChannel = MAX_CHANNELS-1;
channelName = String(channelNames[tvChannel]); // return channel name
Serial.printf("Skip channel: %i (number: %i / name: \"%s\")\r\n", channelCount, tvChannel, channelName.c_str());
return true;
}

◆ ThermostatModeCallback

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

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
}