Add full support for mode controller
This commit is contained in:
parent
e7a2079ff7
commit
3bcd767127
8 changed files with 198 additions and 6 deletions
|
|
@ -29,12 +29,48 @@ const deviceName = "Thermostat Test";
|
|||
const thermostat = alex2NodeClient.registerDevice(
|
||||
deviceName,
|
||||
"thermostatEndpoint1",
|
||||
[DisplayCategory.TEMPERATURE_SENSOR, DisplayCategory.THERMOSTAT]
|
||||
[DisplayCategory.TEMPERATURE_SENSOR, DisplayCategory.THERMOSTAT,DisplayCategory.OTHER]
|
||||
);
|
||||
|
||||
// Add thermostat-related capabilities
|
||||
thermostat.addCapability(AlexaInterfaceType.THERMOSTAT_CONTROLLER); // Allows Alexa to control thermostat modes and setpoints
|
||||
thermostat.addCapability(AlexaInterfaceType.TEMPERATURE_SENSOR); // Allows Alexa to read current temperature from the sensor
|
||||
const modeController = thermostat.addCapability(
|
||||
AlexaInterfaceType.MODE_CONTROLLER
|
||||
);
|
||||
|
||||
modeController.setInstance("mode.fanmode");
|
||||
modeController.addFriendlyName("Fan", "en-US");
|
||||
modeController.addSupportedModes([
|
||||
{
|
||||
value: "mode.fanmode.Auto",
|
||||
modeResources: {
|
||||
friendlyNames: [
|
||||
{
|
||||
"@type": "text",
|
||||
value: {
|
||||
text: "Bannana",
|
||||
locale: "en-US",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
value: "mode.fanmode.On",
|
||||
modeResources: {
|
||||
friendlyNames: [
|
||||
{
|
||||
"@type": "text",
|
||||
value: {
|
||||
text: "Apple",
|
||||
locale: "en-US",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
// Log the device name to verify registration
|
||||
console.log(thermostat.getName());
|
||||
|
|
@ -50,6 +86,7 @@ const deviceData = {
|
|||
targetSetpoint: 60,
|
||||
current: 69,
|
||||
thermostatMode: ThermostatMode.HEAT,
|
||||
fanMode:"mode.fanmode.Auto"
|
||||
};
|
||||
thermostat.on("ReportState", (payload) => {
|
||||
// console.log("ReportState received!", payload);
|
||||
|
|
@ -60,6 +97,7 @@ thermostat.on("ReportState", (payload) => {
|
|||
|
||||
status
|
||||
.addHealthProp("OK") // Device is healthy and reachable
|
||||
.addModeControllerProp("mode.fanmode", deviceData.fanMode)
|
||||
.addTemperatureSensorProp(
|
||||
TemperatureSensorScale.CELSIUS,
|
||||
deviceData.current
|
||||
|
|
@ -127,6 +165,7 @@ thermostat.on("Event", (directive, interfaceType) => {
|
|||
|
||||
status
|
||||
.addHealthProp("OK") // Device is healthy and reachable
|
||||
.addModeControllerProp("mode.fanmode", deviceData.fanMode)
|
||||
.addTemperatureSensorProp(
|
||||
TemperatureSensorScale.FAHRENHEIT,
|
||||
deviceData.current
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue