Fixes to scene handling and device unique id

This commit is contained in:
Victor Hagelbäck 2021-04-01 13:19:02 +02:00
parent 754fe00c9a
commit 464c17d920
5 changed files with 57 additions and 31 deletions

View file

@ -7,7 +7,7 @@ class SceneManager {
deviceRegistry;
/** @private @type {import('./PlejdDeviceCommunication')} */
plejdDeviceCommunication;
/** @private @type {Object.<number,Scene>} */
/** @private @type {Object.<string,Scene>} */
scenes;
constructor(deviceRegistry, plejdDeviceCommunication) {
@ -23,15 +23,18 @@ class SceneManager {
this.scenes = {};
scenes.forEach((scene) => {
const idx = this.deviceRegistry.getApiSite().sceneIndex[scene.sceneId];
this.scenes[idx] = new Scene(this.deviceRegistry, idx, scene);
const sceneBleAddress = this.deviceRegistry.getApiSite().sceneIndex[scene.sceneId];
this.scenes[scene.sceneId] = new Scene(this.deviceRegistry, sceneBleAddress, scene);
});
}
executeScene(sceneId) {
const scene = this.scenes[sceneId];
/**
* @param {string} sceneUniqueId
*/
executeScene(sceneUniqueId) {
const scene = this.scenes[sceneUniqueId];
if (!scene) {
logger.info(`Scene with id ${sceneId} not found`);
logger.info(`Scene with id ${sceneUniqueId} not found`);
logger.verbose(`Scenes: ${JSON.stringify(this.scenes, null, 2)}`);
return;
}