Fighting with rules

item:

Group:Switch:OR(CLOSED, OPEN) gmpresence "Presence [%s]"

sitemap:

Text item=gmpresence

So the gmpresence status is “-” at the moment.

1 Mobile Online

Ill turn it of and check if something is changing.

Im not sure if this is something you need to know. But i got a MAP binding for the Clients:

OPEN=Away
CLOSED=Home
NULL=Unknown
UNDEF=Fehler
-=Fehler

Thats how my Items look like:

Contact  RetoMobile  "Reto's Mobile: [MAP(unifi.map):%s]"  (gmpresence)           { channel="unifi:client:home:retomobile1:online" }
Contact  PapiMobile    "Papi's Mobile: [MAP(unifi.map):%s]"   (gmpresence)            { channel="unifi:client:home:papimobile:online" }
Contact  MamiMobile     "Mami's Mobile: [MAP(unifi.map):%s]"   (gmpresence)           { channel="unifi:client:home:mamimobile:online" }
Contact  ChantalMobile  "Chantal's Mobile: [MAP(unifi.map):%s]" (gmpresence)             { channel="unifi:client:home:chantalmobile:online" }

Check the state of all 4 mobile
They MUST be either CLOSED or OPEN
if ONE of them if neither then your group will be undefined

The Status is one of these. On the Sitemap ill see:
(Due to Mapping Transformation)

Reto’s Mobile:
Home

Papi’s Mobile:
Away

Mami’s Mobile:
Away

Chantal’s Mobile:
Away

edit
Now my Phone is disconnected. The Group is still on “-”.

My apologies,
The group needs to be a Contact too!! Sorry

Group:Contact:OR(CLOSED, OPEN) gmpresence "Presence [%s]"

Rules:

rule "Licht Aus"

when
    Item gmpresence changed from OPEN to CLOSED
then
    //sendNotification("xyz@xyz.com","Licht Aus")
    //sendMail("xyz@xyz.comt", "Bewegung Erkannt", "ALARM")
    Reto_Office_Licht.sendCommand(OFF)
    Reto_Flur_Licht.sendCommand(OFF)
    Treppe_Licht.sendCommand(OFF)
    Wohnzimmer_Licht.sendCommand(OFF)
    Esszimmer_Licht.sendCommand(OFF)
    Papi_Office_Licht.sendCommand(OFF)
end

And

rule "ALARM"

when Item HueTrigger changed from OFF to ON            

then
    if (gmpresence == CLOSED) {
        sendNotification("xyz@xyz.com","ALARM")
        //sendMail("xyz@xyz.com", "Bewegung Erkannt", "ALARM")
        Reto_Office_Alarm.sendCommand("LSELECT")
        Treppe_Alarm.sendCommand("LSELECT")
        Reto_Flur_Alarm.sendCommand("LSELECT")
        Wohnzimmer_Alarm.sendCommand("LSELECT")
        Esszimmer_Alarm.sendCommand("LSELECT")
        Papi_Office_Alarm.sendCommand("LSELECT")
    }
end

Once you an Vincent get this Group working look at Generic Presence Detection.

The Group Status in the Sitemap is still “-” will this be a problem?

Group:Contact:OR(CLOSED, OPEN) gmpresence “Presence [%s]”

Try no space before the OPEN

Group:Contact:OR(CLOSED,OPEN) gmpresence "Presence [%s]"

Sorry Vincent

Still no luck :frowning:
Status is still “-”

Just checked the eventlog again. My Parents came home. THis works expected:

2018-04-02 23:57:27.965 [vent.ItemStateChangedEvent] - PapiMobile changed from OPEN to CLOSED
2018-04-02 23:53:06.369 [vent.ItemStateChangedEvent] - MamiMobile changed from OPEN to CLOSED

Try that
In the items file, define the group BEFORE the items

hmmm it’s kinda fucked up.

I did comment all mobiles out only one. And put the Group infront. Now it shows a status.

So i put back the devices one by one
It should have changed the status from “Closed” to Open with the last device, beacuse this one is offline and considered as “Open”.

Sadly still “Closed”

Are we right with the statement “OR” infront of the Group? Or should it be AND?

Yes we are right, you have three phones at home so your state for presence is CLOSED
If ALL the phones are OPEN then your presence is OPEN
It is working!!!

rule "ALARM"

when Item HueTrigger changed from OFF to ON            

then
    if (gmpresence == OPEN) {
        sendNotification("xyz@xyz.com","ALARM")
        //sendMail("xyz@xyz.com", "Bewegung Erkannt", "ALARM")
        Reto_Office_Alarm.sendCommand("LSELECT")
        Treppe_Alarm.sendCommand("LSELECT")
        Reto_Flur_Alarm.sendCommand("LSELECT")
        Wohnzimmer_Alarm.sendCommand("LSELECT")
        Esszimmer_Alarm.sendCommand("LSELECT")
        Papi_Office_Alarm.sendCommand("LSELECT")
    }
end

Sorry it took so long, the rules should work now,
You only need one rule for turning off your lights
And a simple if check for setting your alarm

Good luck

Yeah!

Edit!

Still Thanks!

but the Alarm Rule doenst work. I dont see any error. The State is actually “OPEN” but it doenst trigger when i hit the motion sensor :\

No Alarm Lights are happening

edit2

i fixed it. It was “gmpresence.state==open”

Vicent
Since you are this skilled.

I got another question :smiley:

the command " Reto_Office_Alarm.sendCommand(“LSELECT”)"

Let the Bulbs Blink 10x. Is it possible to repeat the “LSELECT” Command as long till i turn it manually off?

I am sorry I don’t quite understand want you want to do.
What do you means turn manually off? What item?

Well when i send the Command “Reto_Office_Alarm”
The bulbs blink 10x but then all lights turn off, till someone hits the Motion Sensor again.

Is there a possibility to loop this command, so the Bulbs wont stop blinking till i manually turn off the lights? or hit any “Alarm Off” button?

What makes the light blink? A rule?

Install the expire binding

Create an item:

Switch Reto_Office_Alarm_Timer { expire="10s, command=OFF" }
rule "ALARM"

when Item HueTrigger changed from OFF to ON            

then
    if (gmpresence == OPEN) {
        sendNotification("xyz@xyz.com","ALARM")
        //sendMail("xyz@xyz.com", "Bewegung Erkannt", "ALARM")
        Reto_Office_Alarm.sendCommand("LSELECT")
        Reto_Office_Alarm_Timer.sendCommand(ON)
        Treppe_Alarm.sendCommand("LSELECT")
        Reto_Flur_Alarm.sendCommand("LSELECT")
        Wohnzimmer_Alarm.sendCommand("LSELECT")
        Esszimmer_Alarm.sendCommand("LSELECT")
        Papi_Office_Alarm.sendCommand("LSELECT")
    }
end
rule "Reto office lights timer"
when
    Item Reto_Office_Alarm_Timer received command OFF
then
    if (ItemToSwitchAlarmOff.state == ON) {
        Reto_Office_Alarm.sendCommand("LSELECT")
        Reto_Office_Alarm_Timer.sendCommand(ON)
        ItemToSwitchAlarmOff.postUpdate(OFF)
    }
end

Now when you set the alarm with the hue trigger, the timer with the expire binding will start
When it expires after 10s it will turn to OFF and check if you have turned some item ON.
It is it turned on, it will resend the command to blink the lights, start the timer again and reset the alarm off item.

Good luck