Refactor code to use plejd outputs rather than devices as main entity
This commit is contained in:
parent
ef718cf1db
commit
9a76a3ba50
10 changed files with 185 additions and 158 deletions
|
|
@ -1,18 +1,20 @@
|
|||
const SceneStep = require('./SceneStep');
|
||||
|
||||
class Scene {
|
||||
constructor(idx, scene, steps) {
|
||||
/**
|
||||
* @param {import('./DeviceRegistry')} deviceRegistry
|
||||
* @param {number} idx
|
||||
* @param {import("./types/ApiSite").Scene} scene
|
||||
*/
|
||||
constructor(deviceRegistry, idx, scene) {
|
||||
this.id = idx;
|
||||
this.title = scene.title;
|
||||
this.sceneId = scene.sceneId;
|
||||
|
||||
const sceneSteps = steps.filter((x) => x.sceneId === scene.sceneId);
|
||||
this.steps = [];
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const step of sceneSteps) {
|
||||
this.steps.push(new SceneStep(step));
|
||||
}
|
||||
this.steps = deviceRegistry
|
||||
.getApiSite()
|
||||
.sceneSteps.filter((step) => step.sceneId === scene.sceneId)
|
||||
.map((step) => new SceneStep(step));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue