Hi have a lot of rollershutters. It work fine for all single commands.
Now I want one rollershutter to set all rollershutter together.
Alle rollershutters need the command and the Position to refresh the widget.
Virtuel rollershutter -> alle single rollershutter -> commands to Hardware.
item (Virtuel):
Number VirtualAlleRolloPositionen "PositionAlleRollos" <icon> (groups)
rules:
rule "Item AlleRollos"
when
Item AlleRollos received command
then
switch(receivedCommand.toString.toUpperCase){
case "UP": {
rolloKuecheRauf.sendCommand(1)
(alle other commands)
}
case "DOWN": {
rolloKuecheRauf.sendCommand(0)
(alle other commands)
}
}
But i dont refresh my widgets?
And how can i give the position to the other rollershutter Positions?
I cant set a Number to a NumberItem.
What is the right way to use a lot items with one Item?
rule "Item VirtualAlleRolloPositionen"
when
Item VirtualAlleRolloPositionen received command
then
rolloKuechePosition = receivedCommand as Number
end
all items of the rollershutter are numbers.
I dont use groups at the moment.
But what can i do if i have a group of rollershutters? I need a Master so set all other rollershutters?
If the shutters need a number for absolut positioning and can’t react on commands like UP/DOWN/STOP, you will need an additional rule:
rule "control shutter"
when
Member of gShutter received command
then
if(!(receivedCommand instanceof Number))
switch receivedCommand {
case UP : triggeringItem.sendCommand(0)
case DOWN : triggeringItem.sendCommand(100)
default : logWarn("shutter","Command {} not supported!",receivedCommand)
}
else
logInfo("shutter","received Number {}, doing nothing!",receivedCommand)
end
This will suffice to control both each shutter as well as the whole group. Please be aware that there is no STOP command.
rule "Item AlleRolloPositionen"
when
Member of AlleRolloPositionen received command
then
if(!(receivedCommand instanceof Number))
switch receivedCommand {
default : triggeringItem.sendCommand(AlleRolloPositionen.state)
}
else
logInfo("shutter","received Number {}, doing nothing!",receivedCommand)
end
This is the same with a Number Type and a Group for alle rollershutter positions.
But, if i change a group member Position, the “master” Position go to undefined. What can I do, that the position of the “master” go to 0?
there should be no need to translate a number to itself. If setting the group to a specific position, it should send this command to all members of the group.
If this does not work, think about the code of the rule
rule "control shutter" // name of rule
when // list of triggers
Member of gShutter received command // a member of the group received a command
then // what to do
if(!(receivedCommand instanceof Number)) // received command is not a number
switch receivedCommand { // decide dependend on received command
case UP : triggeringItem.sendCommand(0) // command is UP, so send 0
case DOWN : triggeringItem.sendCommand(100) // command is DOWN, so send 100
default : logWarn("shutter","Command {} not supported!",receivedCommand) // any other command will cause a warn log
} // end of switch block
else // command is a number
logInfo("shutter","received Number {}, doing nothing!",receivedCommand) // log an info that the command was a number
end
Please pay attention to the invisible part and scroll to the right…
Now, if sending a number through this sort of rule, you would create an endless loop (the rule triggers itself)
For the group you could use this rule:
rule "shutter group position" // name of rule
when // list of triggers
Item gShutter received command // the group itselv received a command
then // what to do
if(receivedCommand instanceof Number) // command is a number
gShutter.members.forEach[m| // for each member of the group
m.sendCommand(receivedCommand) // send the received command
] // end of code block "for each"
end
But as said above, this rule should not be necessary, as the group will resend all received commands to the items.