[How To] Alexa V3 - Report status of window contact (Update: now possible via ContactSensor in DE)

Hello,
As it is sometimes - you wait months for something until you create a workaround and a week later Alexa detects my “ContactSensor” item in a search for new devices. :crazy_face:
Even though it’s not updated in the “Openhab Alexa V3 skill” documentation - not even in the Alexa skill API documentation from Amazon - that ContactSensor is supported in Germany - it can be found by Alexa App and shows the status ‘open’ vs. ‘closed’. Alexa also responds to the question: “Is my bedroom window open?” with “Bedroom window is closed” (without the phrase “I’ll check this”)
The additional “Switch” items are not necessary anymore. Just add alexa=“ContactSensor.detectionState” to your “Contact” item. For groups of windows I created an additional “Contact” item which references the group, instead of adding the Alexa tag in every window contact.

My new items file looks like this:

// group for complete MAX! system
Group gMax "Max! system"

// groups for rooms
Group gMaxBedroom "Bedroom" (gMax)

// groups for specific aspects
Group:Contact:OR(OPEN,CLOSED) gMaxWindow "Windows contacts" <window> (gMax)

// house
Contact house_windowContact_stateControl "Windows in my house" {alexa="ContactSensor.detectionState" [itemSensor="gMaxWindow"]}

// bedroom
Contact og_bedroom_windowContact_state "Bedroom window" <window> (gMaxbedroom, gMaxWindow) {channel="mqtt:topic:myMQTTBroker:og_bedroom_windowContact:STATE", alexa="ContactSensor.detectionState"}

— old post —
since the current Alexa Skill API doesn’t support category “ContactSensor” in Germany I was wondering if I could request the state of my MAX! window contacts in another way.
Therefor I found category “LockController” for which Alexa is able to tell the status locked (“abgeschlossen”) and open (“geöffnet”). So I updated my item definition of the window contacts with this category and guess what: It’s working perfectly! :smiley:
If I ask Alexa for example: “Is my bedroom window closed?”, she’s answering me: “I’ll check this.” and later “Bedroom window is closed”. You can also ask “Is the bedroom window opened?” or “What’s the status of my bedroom window?”.

I used this solution for all of my window contacts and have now also the possibility to ask Alexa if any window in my house is closed or opened.
:stuck_out_tongue: Makes it easy to know if any window in the attic is open when it begins raining, without looking into the App or walking up the stairs.

Kind regards,
Carsten

My items file:

// group for complete MAX! system
Group gMax "Max! system"

// groups for rooms
Group gMaxBedroom "Bedroom" (gMax)

// groups for specific aspects
Group:Contact:OR(OPEN,CLOSED) gMaxWindow "Windows contacts [MAP(max.map):%s]" <window> (gMax)

// house
Switch house_windowContact_stateControl "Windows in my house" {alexa="LockController.lockState" [itemSensor="gMaxWindow"]}

// bedroom
Switch og_bedroom_windowContact_stateControl "bedroom window" {alexa="LockController.lockState" [itemSensor="og_bedroom_windowContact_state"]}
Contact og_bedroom_windowContact_state "Bedroom window state [MAP(max.map):%s]" <window> (gMaxbedroom, gMaxWindow) {channel="mqtt:topic:myMQTTBroker:og_bedroom_windowContact:STATE"}

Hint: After searching for new devices in Alexa, the window contact (aka window lock) item in the Alexa App sometimes seems to be unresponsive. In this case you can simply open and close the corresponding window one time and the status will be updated.

4 Likes

Short addon: This also works without the “.detectionState”.

Hi there,

i try to add an Homematic IP Windows Sensor to ALexa. My problem now is that the Homematic Thing/Itemn is a String-Item an dAlexa tells me “Device is not responding”.

I tried to change the String to Contact with the same result.

Any ideas?

Thanks
Nils

The ContactSensor interface only supports Contact or Switch item type. So if the Homematic binding doesn’t support such item type for providing a contact state, then you will have to use a proxy item.

In order to better understand your setup, can you please provide the item definition you are trying to expose to Alexa?

Here is my item i tried to use:

//Türkontakt
Contact TuerFlur "Türkontakt Flur" {alexa="ContactSensor"}
String TuerKontakt "Türkontakt Flur String" {channel="homematic:HmIP- 
HEATING:raspi:INT0000009:1#WINDOW_STATE"}

With a rule I tried to convert the String to Contact:

//Flur Tür
rule "Tür String to Contact"
when
        Item TuerKontakt received update
then
        if (TuerKontakt.state.toString.contains("OPEN")){
                TuerFlur.postUpdate(OPEN)
                sendTelegram("achterhome", "Tür offen")
        }
        else {
                TuerFlur.postUpdate(CLOSED)
                sendTelegram("achterhome", "Tür geschlossen")
        }
end

I noticed that the String item is not logged when my door opens. I think that is the problem. I tried the Sensor direct or via a Heating-Group. Both are not showing up in my logs files exept I reboot my Raspberry. Than the sensor get a state once.

Your item definition looks good to me, from the Alexa configuration perspective. I am not quite sure if you are saying you are still having an issue or you got it working. Anyway, if there is some kind of updating issue, then it would think it’s on the homematic side at this point.

I still have the problem with my door sensor. But at this point I think too it is a problem with Homematic. I try to reconnect the sensor this evening and report back if it is working.

Is it possible to get the state of a switch item? I know, that alexa=“ContactSensor.detectionState” is also usable for switch items. But then I have to ask alexa “Alexa, is the Light open?”. Alexa doesnt understand the question “Alexa, is the Light on?”

This should answer your question:

Thank you - that’s good news.
One question:
Why do you need the Contact house_…?
Shouldn’t this be covered by the Group gMaxWindow?

One more question.

Is it possible to set a “friendly name” e.g “window” to all contacts?
I have various contacts (skylight, Balcony, …) and I would like to ask:
Alexa, which window is open?
Alexa just mentions the Windows with “window” in their name (item label).

By the way: I can ask: Is the Skylight open?

This is unfortunately not possible. You have to request each specific device. However you could create a group contact item type that includes all your window contact sensors and represents the overall state of these sensors that you could request via Alexa. It’s not exactly what you wanted but at least you will know if all your windows are open or closed.

item

Group:Contact:OR(OPEN, CLOSED) gAllWindows "All Windows" {alexa="ContactSensor.detectionState"}
Contact SkylightWindow "SkylightWindow" (gAllWindows) {alexa="ContactSensor.detectionState"}

utterances

Alexa, is all windows open? (you could try “are” but I am not sure it will work)
Alexa, is skylight open?

Thanks - I will play around with this a bit

I have a loxone miniserver and the window contact is implemented as a switch item.

Switch windowContact “Fenster 1” {channel=“loxone:miniserver:123”,alexa=“ContactSensor.detectionState”}

In my case if the switch is on, the window is closed and off, if it is open.
With the setup above alexa tells me, the door is open, although it is closed.
It seems a “ON” switch is interpreted as an open window.
Is there a possibility to invert the state, so that alexa recognizes the window state correctly?

While it is not documented, you can remap the sensor state.

Switch windowContact "Fenster 1" {channel="loxone:miniserver:123", alexa="ContactSensor.detectionState" [NOT_DETECTED="ON", DETECTED="OFF"]}
1 Like

Hey guys,

I have two windows in my bedroom and both have contact sensors and I have them in Alexa now aswell.

What would currently be the best solution if I want to be able to ask Alexa something like:
Sind die Schlafzimmer Fenster geschlossen? and then get an answer back if one of the windows is open (lets say the left one) which is something like: Schlafzimmer Fenster Links ist offen.

Is that currently possible ?

You can only request if a given contact sensor is open or not. You could however have a group representing multiple contact sensors but you would only be able to know the state of that group.

Unfortunately we have no control at the skill level to implement what you are asking.

Thank you for the suggestion with the group. I will try that!

The only other solution in the meantime would be to maybe solve it via Dummy Items, rules and the Alexa Echo Control binding and an Alexa Routine.

Would it be possible that way once the proactive reporting (that you mentioned in another thread) would be available in the skill ?

Correct.

Nope. Again, we have no control at the skill level. Proactive reporting will only allow contact sensors to be used in Alexa routines as trigger devices.

1 Like