1.5.0: brightness + mode props in the power example (as published to npm)
This commit is contained in:
parent
f09d03636d
commit
7f1cfdbe9c
2 changed files with 9 additions and 3 deletions
|
|
@ -23,7 +23,7 @@ alex2NodeClient.connect(); // Connect to the MQTT broker
|
|||
const deviceName = "Bedroom Light";
|
||||
|
||||
// Register the device with a unique endpoint ID (you can use something like "endpoint1")
|
||||
const bedroomLight = alex2NodeClient.registerDevice(deviceName, "endpoint2");
|
||||
const bedroomLight = alex2NodeClient.registerDevice(deviceName, "2E3AE9");
|
||||
|
||||
// Add the PowerController capability (for turning on/off the device)
|
||||
bedroomLight.addCapability(AlexaInterfaceType.POWER_CONTROLLER);
|
||||
|
|
@ -31,6 +31,9 @@ bedroomLight.addCapability(AlexaInterfaceType.POWER_CONTROLLER);
|
|||
// Log the device name to verify registration
|
||||
console.log(bedroomLight.getName());
|
||||
|
||||
const momentaryModeInstance = "mode.signal.beep";
|
||||
const defaultMomentaryMode = "mode.signal.beep.Normal";
|
||||
|
||||
/**
|
||||
* Handle Alexa's ReportState directive.
|
||||
* This occurs when Alexa queries the current state of the device (e.g., during routines or device status checks).
|
||||
|
|
@ -44,7 +47,9 @@ bedroomLight.on("ReportState", (payload) => {
|
|||
|
||||
status
|
||||
.addHealthProp("OK") // Device is healthy
|
||||
.addPowerControllerProp(outputState); // Report the current power state (ON/OFF)
|
||||
.addPowerControllerProp(outputState) // Report the current power state (ON/OFF)
|
||||
.addBrightnessControllerProp(100)
|
||||
.addModeControllerProp(momentaryModeInstance, defaultMomentaryMode);
|
||||
|
||||
status.send(); // Send the state report back to Alexa
|
||||
});
|
||||
|
|
@ -75,6 +80,7 @@ bedroomLight.on("Event", (directive, interfaceType) => {
|
|||
status
|
||||
.addHealthProp("OK")
|
||||
.addPowerControllerProp(outputState)
|
||||
.addBrightnessControllerProp(100)
|
||||
.send();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue