Add support for TEMPERATURE_SENSOR
This commit is contained in:
parent
7f5357dadf
commit
8a1d862d56
5 changed files with 108 additions and 13 deletions
|
|
@ -481,6 +481,9 @@ case AlexaInterfaceType::ENDPOINT_HEALTH:
|
|||
return {"connectivity"};
|
||||
case AlexaInterfaceType::TOGGLE_CONTROLLER:
|
||||
return {"toggleState"};
|
||||
case AlexaInterfaceType::TEMPERATURE_SENSOR:
|
||||
return {"temperature"};
|
||||
|
||||
case AlexaInterfaceType::APPLICATION_STATE_REPORTER:
|
||||
case AlexaInterfaceType::AUDIO_PLAY_QUEUE:
|
||||
case AlexaInterfaceType::AUTHORIZATION_CONTROLLER:
|
||||
|
|
@ -522,7 +525,6 @@ case AlexaInterfaceType::SMART_VISION_OBJECT_DETECTION_SENSOR:
|
|||
case AlexaInterfaceType::SMART_VISION_SNAPSHOT_PROVIDER:
|
||||
case AlexaInterfaceType::SPEAKER:
|
||||
case AlexaInterfaceType::STEP_SPEAKER:
|
||||
case AlexaInterfaceType::TEMPERATURE_SENSOR:
|
||||
case AlexaInterfaceType::THERMOSTAT_CONTROLLER:
|
||||
case AlexaInterfaceType::THERMOSTAT_CONTROLLER_CONFIGURATION:
|
||||
case AlexaInterfaceType::THERMOSTAT_CONTROLLER_HVAC_COMPONENTS:
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ enum class PowerController
|
|||
ON,
|
||||
OFF
|
||||
};
|
||||
enum class TemperatureSensorScale
|
||||
{
|
||||
CELSIUS,
|
||||
FAHRENHEIT
|
||||
};
|
||||
|
||||
class AlexaStatusMessage
|
||||
{
|
||||
|
|
@ -65,6 +70,18 @@ public:
|
|||
String value = (powerController == PowerController::ON) ? "ON" : "OFF";
|
||||
return AddProperty(AlexaInterfaceType::POWER_CONTROLLER, "powerState", value, uncertaintyInMs);
|
||||
}
|
||||
|
||||
AlexaStatusMessage &AddTemperatureSensorProp(TemperatureSensorScale tempSensor,float value, unsigned int uncertaintyInMs = 0)
|
||||
{
|
||||
JsonDocument tempValue;
|
||||
tempValue["scale"] = "CELSIUS";
|
||||
tempValue["value"] = value;
|
||||
if((tempSensor == TemperatureSensorScale::FAHRENHEIT)){
|
||||
tempValue["value"] = (value - 32) * 5.0 / 9.0;
|
||||
}
|
||||
return AddProperty(AlexaInterfaceType::TEMPERATURE_SENSOR, "temperature", tempValue.as<JsonObject>(), uncertaintyInMs);
|
||||
}
|
||||
|
||||
AlexaStatusMessage &AddBrightnessControllerProp(unsigned int brightness, unsigned int uncertaintyInMs = 0)
|
||||
{
|
||||
return AddProperty(AlexaInterfaceType::BRIGHTNESS_CONTROLLER, "brightness", brightness, uncertaintyInMs);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "AlexaUtils.h"
|
||||
|
||||
#define Alex2ESP_DEBUG
|
||||
// #define Alex2ESP_DEBUG
|
||||
|
||||
uint8_t AlexaUtils::nextMessageId = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue