Hello, I want to further develop my rollershutter control in a way that all rollershutters of the living room (4 rollershutters in total) can be closed or opened simultaneously to the same degree by a single Group(Voice)Command, e.g., lets say, all rollershutters shall be closed simultaneously to 50%. At the moment that „only“ works by individual commands to every single rollershutter. The respective rule is shown below and works timer-based, because a direct positioning of our rollershutters doesn’t work unfortunately:
val Number WZ_Rollo_01_100 = 20 // measured time in seconds for the rollershutter to move from fully open to fully closed position (here 20sec)
var Number RolloTime_01 = -1 // that will be the time length for the movement from current position towards the desired position
var Number RolloDifference = NULL // delta of rollershutter move
var String RolloDirection = NULL // rollershutter movement up oder down
rule "WZ_Rollo_01_Alexa"
when
Item WZ_Rollo_01_Alexa received command
then
logInfo("Rollo 1 Alexa", "Actual Rollo Position: " + WZ_Rollo_01_Pos.state)
logInfo("Rollo 1 Alexa", "receivedCommand: " + receivedCommand)
var Timer timer = null
if ((receivedCommand as DecimalType).intValue == 100) {
// when command 100%, then rollershutter shall close completely, without Timer (for Reset)
RolloDirection = "DOWN"
RolloTime_01 = NULL
}
if ((receivedCommand as DecimalType).intValue == 0) {
// when command 0%, then rollershutter shall open completely, without Timer (for Reset)
RolloDirection = "UP"
RolloTime_01 = NULL
}
if (receivedCommand > WZ_Rollo_01_Pos.state) {
// we compare the desired new position with the current position: if „New“ is bigger than „Current“, the rollershutter has to move down
RolloDifference = ((receivedCommand as DecimalType).intValue - (WZ_Rollo_01_Pos.state as DecimalType).intValue) // we calculate the difference or distance between the current position and the desired new position (as Percentage Value)
logInfo("Rollo 1 Alexa", "Rollo Difference: " + RolloDifference)
RolloDirection = "DOWN"
}
if (receivedCommand < WZ_Rollo_01_Pos.state) {
// we compare the desired new position with the current position: if „New“ is smaller than „Current“, the rollershutter has to move up
RolloDifference = ((WZ_Rollo_01_Pos.state as DecimalType).intValue-(receivedCommand as DecimalType).intValue) // we calculate the difference or distance between the current position and the desired new position (as Percentage Value)
logInfo("Rollo 1 Alexa", "Rollo Difference: " + RolloDifference)
RolloDirection = "UP"
}
if (RolloTime_01 === NULL) {
logInfo("Rollo 1 Alexa", "Rollo received command: " + RolloDirection)
WZ_Rollo_01.sendCommand(RolloDirection)
WZ_Rollo_01_Pos.sendCommand(receivedCommand) // we give the actual position to the Item
RolloTime_01 = -1
logInfo("Rollo 1 Alexa", "Rollo Time: " + RolloTime_01)
} else {
RolloTime_01 = (RolloDifference/100) * WZ_Rollo_01_100 // we calculate the driving-time in seconds
logInfo("Rollo 1 Alexa", "Rollo received command: " + RolloDirection)
WZ_Rollo_01.sendCommand(RolloDirection)
logInfo("Rollo 1 Alexa", "Rollo Time: " + RolloTime_01)
timer = createTimer(now.plusSeconds(RolloTime_01.intValue), [|
logInfo("Rollo 1 Alexa", "Timer expired and Rollo set to STOP") // if Timer has expired, the rollershutter stops at the desired new position
WZ_Rollo_01.sendCommand(STOP)
])
WZ_Rollo_01_Pos.sendCommand(receivedCommand) // we give the actual position to the Item
}
end
The above rule I have programmed for all 4 rollershutters in an analogue way. Because all rollershutters have a different size and thus also different driving-times, I have measured and assigned the individual times for each rollershutter. Now the wish arises, to have the possibility, to position all 4 rollershutters simultaneously to a dedicated position, e.g. all rollershutters simultaneously to 50%. How can I solve that in an elegant way based on the above rule(s)? I thought about a Lambda approach, would that be a suitable way forward? Unfortunately my programming skills are exhausted here, so I would be very happy for any kind of coding support.