...map[ label + " All OFF" ]
nope⊠i also tried this⊠this is resulting in
[Station 1All OFF, Station 2All OFF]
But i want
[Station 1, Station 2, All OFF]
this gives me a error in VS Code
Assignment to final variable(org.eclipse.xtext.xbase.validation.IssueCodes.assignment_to_final)
As I said, it was really unclear what you were trying to accomplish.
Just add another element.
reply_buttons.add("All OFF")
That wonât work because reply_buttons is a List Object and there is no + operator for List objects. But there is an add method. Or maybe itâs append. I havenât done Rules DSL in a long time.
Does it work though? Does openHAB itself give an error. I find that VSCode doesnât always tell the whole story with openHAB stuff⊠See above why it wonât work!
sorry that i was not clear enough
this gives me also a error:
The method add(String) is undefined for the type Iterable<String>(org.eclipse.xtext.diagnostics.Diagnostic.Linking)
OK, the map returns an Iterable. Iâm going to guess that underneath itâs a List of some sort so cast it to a List. Youâll have to import java.util.List.
import java.util.List
val List<String> reply_buttons = (gOSPI_Station.members.filter[ i | i.state == OFF ].map[ label ]) as List<String>
reply_buttons.add("All OFF")
If that doesnât work you need to use the forEach approach above to manually add each element to a List and then append âAll OFFâ.
this gives me a error
Rule 'Telegram Bot receive rasen': Could not cast [Station 1, Station 2] to java.util.List; line 18, column 38, length 80
So for now i created a dummy item:
Switch OpenSprinklerAllStationsOff "Alle aus" (gOSPI_Station)
and kept that line in the rules:
val reply_buttons = gOSPI_Station.members.filter[ i | i.state != ON ].map[ label ]
this is the result i was searching for⊠but requieres such dummy item⊠but i can live with that⊠maybe this will help me with the second part of the rule for the telegram answer
Thanks all for you help
Hi, I am just trying to improve the presence detection in my house.
I would like to detect if a light has been switched since last 10 minutes but to avoid tonâs of rows I would like to use a group function.
All the Items are in a âLuciâ Group
A single row function which works is for example:
var Number Presenza=0
if (Luce_1.changedSince(now.minusMinutes(10))) Presenza=1
if (Luce_2.changedSince(now.minusMinutes(10))) Presenza=1
âŠ
Now Can you Help with the group Function?
I tried:
But doesn't work as expected (no errors but always Presenza=0 even if I switch a light)if (Luci.members.filter[ i | i.changedSince(now.minusMinutes(10)) ]) Presenza=1
Any help?
Thanks
Lorenzo
That gives you a list. A list is neither true nor false, so far as an if() is concerned.
Maybe you could see if the list length > 0
It works
Thanks
Lorenzo
Hi all,
I have a group of lights that is controlled by a number of different options, OH switch, Alexa, physical wall switch.
Iâm writing a few rules to work out if any of the lights in the group are on to then determine if the rule should run or not, they are Phillips Hue spots so I canât search by ON / OFF, I have to do it by Brightness > 0.
Iâve got different options on how I can code the rule, my question to help determine the best way isâŠis there a way to determine if:
all lights in the group are brightness = 0
or
any lights in the group are brightness > 0
or
what lights in the group are brighness of either = or > 0
???
Thanks in advance.
You can make a Group just for this purpose, a Switch type with aggregate function OR(ON,OFF) should do.
To add on: hereâs an example that I use everyday - scroll down to zigbee.items to see the setup, and then just below the screenshot of my sitemap.
To do your first two queries you would just compare against the dimmer group. The last one will have to be done by individually checking each light.
Of course, Iâm always trying to make things too complicated. Good old KISS theory, keep it simple stupid as my old maths teacher used to sayâŠ
EDIT:
Right, Iâve just found out that after some scratching of head and some very random results in using a switch, it would appear the Hue spots that I have donât accept on / off commands in the way youâd hope, they turn the lights on but only to a brightness of 1âŠthey need to be brightness 100âŠso the group switch is out, but for anyone else reading this, the concept of the group switch certainly works.
Hey guys,
Thanks to this topic, I managed to have the items of a group named and sent to me via telegram that have a certain status.
rule "Abfrage"
when
Item Abfrage received command ON
then
sendTelegram("bot1", gWindow.members.filter[i | i.state==OPEN].map[ label ].reduce[ result, label | result = result+", " + label ] + " ist offen" )
end
Unfortunately, I get a ânullâ message when none of the items in the group have the requested status.
Does anyone know how I can prevent this?
Greetings
Expand your rule. Get your list of Items into a variable first. Then test to see if it has length zero before doing anything with it.
Hi I created a short test to understand the behaviour of Group but I receive always a ânullâ message
> Items
> Group PIPPO "test group" > Switch PIPPO_1 "membro 1" (PIPPO) > Switch PIPPO_2 "membro 2" (PIPPO) > Switch PIPPO_3 "membro 3" (PIPPO) > Switch MQTT_Remote "membro 4" (PIPPO)
Sitemap
Switch item= MQTT_Remote
Rule (I tried both the logInfo)
rule "testgroup"
when
Member of PIPPO received command
then
logInfo ("testgroup ", "MQTT_Remote")
// logInfo ("testgroup ", MQTT_Remote)
val prova=triggeringItem
logInfo ("testgroup 1", prova)
end
Where am I wrong?
Thanks
logInfo(X,Y)
wants to be given two strings. Your prova
is an Item object, not a string.
Examples-
logInfo ("testgroup 1", "Testing " + prova.name)
logInfo ("testgroup 1", "State " + prova.state.toString)
There is a handy way to see objects using {} in the text and an extra parameter.
logInfo ("testgroup 1", "trigger Item was {}", prova)