I’m unsure why this is happening, but maybe i need a different service. If all 3 garage doors are closed, it does what i expect, opens each one to the percentage in the variable position
.
If one door is already open, it closes that one completely, and the other 2 to the percentage. I was more hoping for it would close it to that percentage so they would all be in sync.
let position = flow.get("garagedoors")
//Function to create msg for call service
function Doors(door) {
// Craft Service Call message
msg.payload = {
domain: "cover",
service: "set_cover_position", // Integer from slider
target: {
entity_id: [`cover.garage_door_${door}_door`],
},
data: {
position: position
}
};
node.send(msg); //Send the data
}
// Loop through all 3 doors
for (let i = 1; i < 4; i++) {
// Check if it's the first door
if (i === 1) {
// Call the function for the first time with no delay
Doors(i);
} else {
let delay = i * 5000; // 5s delay for each subsequent event (i would be >= 1)
setTimeout(function() {Doors(i);}, delay);
}
}