Release Candidate and Support: Amazon Echo Control Binding

You can use my code example above and tweak to suit your needs. Something like this:

var Timer stopMotionTimer = null
rule "Window open while heat is on"
when
    Item Your_heater_item changed from OFF to ON
then
    if(stopMotionTimer === null && Window_item.state == OPEN){
        stopMotionTimer = createTimer(now.plusMinuets(15)) [|
        Echo_Plus_TTS.sendCommand('Alert, window is open!')
        stopMotionTimer = null
        ]
    }
end

Note: This will only work if the window is open when the heat turns on. If someone opened the window while the heat is on you won’t get the notification. You can change the when part of the rule to be the window item and in the if statement replace the Window_item to your Heater_item. This way the rule will run when the window is opened and if the if statement is true (the heater is on) you will get an alert after 15 minuets.

Hello,
thanks for your idea - but I am still struggeling:
Configuration model ‘rules.rules’ has errors, therefore ignoring it: [120,1]: missing EOF at ‘var’

Rule:
var Timer stopMotionTimer = null

rule “Fenster offen wenn Heizung an”
when
Item EG_Vi_hkpump changed from OFF to ON
then
if(stopMotionTimer === null && DB_ve.state == OPEN){
stopMotionTimer = createTimer(now.plusMinuets(15))
Echo_Text_Test.sendCommand(‘Die Heizung ist angesprungen. Bitte Fenster schließen.’)
stopMotionTimer = null

}

end

I suggest, this has something to do with this “var” but I don’t know wher to put this in
 NOOB alert :wink:

Add the lambda to the end of this line like below and close it

if(stopMotionTimer === null && DB_ve.state == OPEN){
stopMotionTimer = createTimer(now.plusMinuets(15)) [ |
Echo_Text_Test.sendCommand(‘Die Heizung ist angesprungen. Bitte Fenster schließen.’)
stopMotionTimer = null
]
}
end
1 Like

Simply put, rule files will start with imports, then gobal variables, lambdas, then your rules. So put the stopMotionTimer global variable further up in your file. It’s currently on line 120 and likely has rules above it


1 Like

Should run like this but need to check the output of DB_ve is it a contact item or something else. If your still having issues post your items and we can help

@5iver good catch, didn’t notice the [120,1] or even think about the possibility of a rule above.

1 Like

Ok folks - I put this at the top of my rules and the “var” Error is gone.
But there is a mew Problem:
Rule ‘Window open while heat turned on’: ‘plusMinuets’ is not a member of ‘org.joda.time.DateTime’; line 8, column 39, length 18

Hope you still have ideas


Miss spelled the word minutes.

Got it! It works!
Thank you so much guys!!!

Ok, now it becomes more difficult. I would like to extend this rule for all my windows. So I do not have a state == OPEN , right?
I have 2 Contacts for each Window.
The Items look like this:
Group:Contact:OR(OPEN,CLOSED) gEGContactsKippe “Offene Fenster EG [(%d)]” <window>

Group:Contact:OR(OPEN,CLOSED) gEGContactsOffen “Gekippte Fenster EG [(%d)]” <window>

Contact EG_wo_fe_li1 “Wohnen Links Auf [MAP(de.map):%s]” <window> (gEGContactsOffen) { channel=“knx:device:bridge:Tasterschnittstellen:EG_wo_fe_li1” }

Contact EG_wo_fe_li2 “Wohnen Links Kippe [MAP(de.map):%s]” <window> (gEGContactsKippe) { channel=“knx:device:bridge:Tasterschnittstellen:EG_wo_fe_li2” }

String EG_wo_fe_li “Wohnen Links [MAP(de.map):%s]” <contact> (gHFenster, gEG, gEGFenster, gEGContacts, gWO)

Contact EG_wo_fe_re1 “Wohnen Rechts Auf [MAP(de.map):%s]” <window> (gEGContactsOffen) { channel=“knx:device:bridge:Tasterschnittstellen:EG_wo_fe_re1” }

Contact EG_wo_fe_re2 “Wohnen Rechts Kippe [MAP(de.map):%s]” <window> (gEGContactsKippe) { channel=“knx:device:bridge:Tasterschnittstellen:EG_wo_fe_re2” }

String EG_wo_fe_re “Wohnen Rechts [MAP(de.map):%s]” <contact> (gHFenster, gEG, gEGFenster, gEGContacts, gWO)

And there are also rules:
rule Fenster_Wohnen_links
when
Item EG_wo_fe_li2 changed or
Item EG_wo_fe_li1 changed
then
if (EG_wo_fe_li2.state == CLOSED && EG_wo_fe_li1.state == CLOSED) {
EG_wo_fe_li.postUpdate(0)
} else if (EG_wo_fe_li2.state == OPEN && EG_wo_fe_li1.state == CLOSED) {
EG_wo_fe_li.postUpdate(1)
} else {
EG_wo_fe_li.postUpdate(2)
}
end

rule Fenster_Wohnen_rechts
when
Item EG_wo_fe_re2 changed or
Item EG_wo_fe_re1 changed
then
if (EG_wo_fe_re2.state == CLOSED && EG_wo_fe_re1.state == CLOSED) {
EG_wo_fe_re.postUpdate(0)
} else if (EG_wo_fe_re2.state == OPEN && EG_wo_fe_re1.state == CLOSED) {
EG_wo_fe_re.postUpdate(1)
} else {
EG_wo_fe_re.postUpdate(2)
}
end

How can I do this to let Alexa talk if one of this windows is opened when the heat turns on?

Check your openhab log viewer after opening a window and see what it shows.

Same as you did before using the Echo_Text_Test.sendCommand
Echo_Text_Test.sendCommand(‘Die Heizung ist angesprungen. Bitte Fenster schließen.’)

I can’t get the rule working with a group of windows.
I tried:
when
Item EG_Vi_hkpump changed from OFF to ON
then
if(gHContacts != 0){
Echo_Text_Test.sendCommand(‘Die Heizung ist angesprungen. Alle Fenster sind geschlossen.’)
}
else{
Echo_Text_Test.sendCommand(‘Die Heizung ist angesprungen. Es sind Fenster offen.’)
}
end

or

when
Item EG_Vi_hkpump changed from OFF to ON
then
if(gHContacts == 0){
Echo_Text_Test.sendCommand(‘Die Heizung ist angesprungen. Alle Fenster sind geschlossen.’)
}
else{
Echo_Text_Test.sendCommand(‘Die Heizung ist angesprungen. Es sind Fenster offen.’)
}
end

or

when
Item EG_Vi_hkpump changed from OFF to ON
then
if(gHContacts.state != 0){
Echo_Text_Test.sendCommand(‘Die Heizung ist angesprungen. Alle Fenster sind geschlossen.’)
}
else{
Echo_Text_Test.sendCommand(‘Die Heizung ist angesprungen. Es sind Fenster offen.’)
}
end

The group in Items:
Group:Contact:OR(OPEN,CLOSED) gHContacts “Fensterkontakte Haus [(%d)]” <window>

The Sitemap shows the correct number of open windows.
Alexa is ignoring the real state of the windows. Alswas saing all closed or all opened.
There is no error in the log by the way.

Asking about what the log show’s when the window is opened e.g.

Some items post ON and OFF while others post a value. The important thing is to know what it’s posting. My garage door sensor sends an mqtt message of either 1 or 0. For this item I have it as a Switch (switches use ON and OFF, contacts use OPEN and CLOSED) and use the ONOFF.map to transform it to open or closed.

Switch ESP_Easy_Door "Garage Door" <contact>
	{ mqtt="<[pibroker:/Esp/Door/State:state:MAP(ONOFF.map)]" }

and my ONOFF.map has 1=ON and 0=OFF. If I using a contact instead of switch I would have the ONOFF.map look like 1=OPEN and 0=OFF.

Also some of your rules posted start with a when and other with rule Fenster_Wohnen_links with no quotes. All rules should start and end like the one you got to work.
FYI when posting rules and item’s please use code fences e.g. one of the five paper looking things (hover over to get description) between the smiley face and the gear icon.

Screenshot%20at%202018-09-14%2018-47-03

Hope this kinda makes sense, I’m a bit tired.:sleepy:

Thanks

Is it possible to play a local / personal mp3 file through alexa?

@NCO I’ve read that Plex now plays direct on echo devices. I haven’t tried it myself, but check out the Plex binding and see if that’s what your looking for.

Thanks!
I will check it out.

Ok, I figured it out.
I made 2 rules. 1 Rule is for the case when the heat is on and a window of one of my three groups is going to be opened. After 15 minutes, there is a message, to close the windoe of the group.
This looks like this:

var Timer stopMotionTimer = null

rule "Window open while heat is on"

when
    Item gEGContacts changed to OPEN or
    Item gOGContacts changed to OPEN or
    Item gDBContacts changed to OPEN
then
if(EG_Vi_hkpump.state == ON){
    if(stopMotionTimer === null && gEGContacts.state == OPEN && gOGContacts.state == OPEN && gDBContacts.state == OPEN){
        stopMotionTimer = createTimer(now.plusMinutes(15)) [|
        Echo_TTS.sendCommand('Die Heizung ist an. Bitte Fenster schließen im Erd, Ober und Dachgeschoss.')
        stopMotionTimer = null
        ]
    }
    else if(stopMotionTimer === null && gEGContacts.state == CLOSED && gOGContacts.state == OPEN && gDBContacts.state == OPEN){
        stopMotionTimer = createTimer(now.plusMinutes(15)) [|
        Echo_TTS.sendCommand('Die Heizung ist an. Bitte Fenster schließen im Ober und Dachgeschoss.')
        stopMotionTimer = null
        ]
    }
        else if(stopMotionTimer === null && gEGContacts.state == OPEN && gOGContacts.state == CLOSED && gDBContacts.state == OPEN){
        stopMotionTimer = createTimer(now.plusMinutes(15)) [|
        Echo_TTS.sendCommand('Die Heizung ist an. Bitte Fenster schließen im Erd und Dachgeschoss.')
        stopMotionTimer = null
        ]
    }
        else if(stopMotionTimer === null && gEGContacts.state == OPEN && gOGContacts.state == OPEN && gDBContacts.state == CLOSED){
        stopMotionTimer = createTimer(now.plusMinutes(15)) [|
        Echo_TTS.sendCommand('Die Heizung ist an. Bitte Fenster schließen im Erd und Obergeschoss.')
        stopMotionTimer = null
        ]
    }
        else if(stopMotionTimer === null && gEGContacts.state == OPEN && gOGContacts.state == CLOSED && gDBContacts.state == CLOSED){
        stopMotionTimer = createTimer(now.plusMinutes(15)) [|
        Echo_TTS.sendCommand('Die Heizung ist an. Bitte Fenster schließen im Erdgeschoss.')
        stopMotionTimer = null
        ]
    }
        else if(stopMotionTimer === null && gEGContacts.state == CLOSED && gOGContacts.state == OPEN && gDBContacts.state == CLOSED){
        stopMotionTimer = createTimer(now.plusMinutes(15)) [|
        Echo_TTS.sendCommand('Die Heizung ist an. Bitte Fenster schließen im Obergeschoss.')
        stopMotionTimer = null
        ]
    }
        else if(stopMotionTimer === null && gEGContacts.state == CLOSED && gOGContacts.state == CLOSED && gDBContacts.state == OPEN){
        stopMotionTimer = createTimer(now.plusMinutes(15)) [|
        Echo_TTS.sendCommand('Die Heizung ist an. Bitte Fenster schließen im Dachgeschoss.')
        stopMotionTimer = null
        ]
    }
}
end

The other rule is when windows are already open and the heat turns on.


rule "Heat turned on while window open"

when
    Item EG_Vi_hkpump changed from OFF to ON
then
    if(gEGContacts.state == OPEN && gOGContacts.state == OPEN && gDBContacts.state == OPEN) {
        Echo_TTS.sendCommand('Die Heizung ist angesprungen. Es sind Fenster im Erd, Ober und Dachgeschoss offen.')
        }
        else if(gEGContacts.state == CLOSED && gOGContacts.state == OPEN && gDBContacts.state == OPEN){
        Echo_TTS.sendCommand('Die Heizung ist angesprungen. Es sind Fenster im Ober und Dachgeschoss offen.')    
        }  
        else if(gEGContacts.state == OPEN && gOGContacts.state == CLOSED && gDBContacts.state == OPEN){
        Echo_TTS.sendCommand('Die Heizung ist angesprungen. Es sind Fenster im Erd und Dachgeschoss offen.') 
        }
        else if(gEGContacts.state == OPEN && gOGContacts.state == OPEN && gDBContacts.state == CLOSED){
        Echo_TTS.sendCommand('Die Heizung ist angesprungen. Es sind Fenster im Erd und Obergeschoss offen.') 
                }
        else if(gEGContacts.state == OPEN && gOGContacts.state == CLOSED && gDBContacts.state == CLOSED){
        Echo_TTS.sendCommand('Die Heizung ist angesprungen. Es sind Fenster im Erdgeschoss offen.') 
        }
        else if(gEGContacts.state == CLOSED && gOGContacts.state == OPEN && gDBContacts.state == CLOSED){
        Echo_TTS.sendCommand('Die Heizung ist angesprungen. Es sind Fenster im Obergeschoss offen.') 
        }
        else if(gEGContacts.state == CLOSED && gOGContacts.state == CLOSED && gDBContacts.state == OPEN){
        Echo_TTS.sendCommand('Die Heizung ist angesprungen. Es sind Fenster im Dachgeschoss offen.') 
        }
        else
        Echo_TTS.sendCommand('Die Heizung ist angesprungen. Fenster sind geschlossen.')
end

Maybe someone can use it.
Now I would like to set a volume for the messages and reset it at the end of the message and to play a tone before the message is played.
Any ideas?

Is there a way to send a command to alexa which I would normally use my voice for?
For example “Alexa, start MyPod and play my Rockman playlist”. I know this works for routines
 but is there some way to feed her commands without my voice?

No, unfortunately there is currently no way to wake Alexa through anything other than speech. It would be a great addition to the API to allow any commands via text. Until that day ever comes, you could cludge something together with two Amazon Echo devices. Just use text-to-speech on one device that is within earshot of your target Echo.

Alexa_Living_Room_Speak.sendCommand('Alexa ask Tile to find my keys')

So I admit it’s kind of weird to have two Echos talk to each other, but you can use this method to send any command you’d normally use your own voice for, including opening other skills etc.

I Thought it would be nice to put this here.

I think a lot these future features are appropriate for this skill:

http://phx.corporate-ir.net/phoenix.zhtml?c=176060&p=irol-newsArticle&ID=2368311

1 Like