Ask Alexa for contact state

  • Platform information:
    • Hardware:RPi 3
    • OS: openHABian (latest/stable)
    • Java Runtime Environment: no idea
    • openHAB version: latest/stable
  • Issue of the topic:

I got alexa into my openHAB and all the documented functions seem to work. However, I got contacts for my windows and would like to ask alexa for the state of all windows. Basicly Id like to ask if all windows are closed.
Is this even possible? It seems “contact” is not a supported tag. Any ideas? Are there any workarounds? Could I maybe fake the summarized state of all windows into an item like a switch and then ask for that items state or something?

Thanks in advance

I don’t really know Alexa since I don’t have one, but I don’t think that you can do that directly from openHab. Maybe you can make an OR Group and expose it to the cloud. You can ask if this switch is ON or OFF… Or you can use IFTT and then you can send string based on the item state (“All windows are closed”) or something like that

I just tried with a light and she can’t tell me the current state… I think you might have to fake some sort of thermostat device to get feedback…

I never faked a device. Can you give me some more hints in the right direction? :slight_smile:

All you need is a Temperature item. Give it any name you want. I have one called “Outside”. Then I ask Alexa for the “Outside Temperature” and she responds. But this temperature can represent anything. So you could have a garage door and you set it to 100 for open and 0 for closed. Then ask Alexa what the “Garage Door Temperature” is and she will respond as 0 or 100.

Hopefully this will get easier once the V3 Alexa skill is developed.

This realy sounds like a hackish workaround. But thanks anyway. I really hope v3 helps with some of this

I’ve written a rule that loops over all windows and if any of them is open, the label of the device is added to a string.
At the end of the rule, the string is spoken via echo tts.

This is the rule to loop over all windows, which in my case are all member of the group gContacts.
openwindows is a counter which is incremented when an open contact is discovered.

Talk_OpenWindows is a switch item that may be triggered by any event to initiate the status report via Echo device.

rule “Talk_OpenWindows”

Item Talk_OpenWindows received update
var String textZeile1= “”
var openwindows = 0

gContacts?.members.forEach ( item | 
	if (item.state==OPEN) {
		textZeile1 = textZeile1 + item.label +" , "

if (openwindows == 0) {

                Echo_TTS.sendCommand("All windows are closed.")
} else {


Best Regards.

FYI, the Alexa V3 skill gives the ability to model a contact sensor and request its state by voice. However, it cannot be used in Alexa routines as of yet.

Contact DoorSensor "Door" {alexa="ContactSensor.detectionState"}
Contact WindowSensor "Window" {alexa="ContactSensor.detectionState"}

“Alexa, is the door open?”
“Alexa, is the window open?”


What happens when you have a Front Door Switch, which has:


And a contact sensor with


As if I ask Alexa, is the front door open? She says front door doesnt support that. But it works just fine for other contact sensors.

If your intention is to have a door with a smart lock and contact sensor capabilities, you can define a group endpoint to accomplish this as follow:

Group gDoor "Door" {alexa="Endpoint.Door"}
Switch DoorLock "Lock" (gDoor) {alexa="LockController.lockState"}
Contact DoorSensor "Sensor" (gDoor) {alexa="ContactSensor.detectionState"}

Alexa, lock the door
Alexa, is the door locked?
Alexa, is the door open?


Actually, you are better off modeling each capabilities as single endpoint and create a group “Door” on the Alexa side that include these two, as you wouldn’t be able to setup the unlock pin in the Alexa app, when part of the group endpoint.

Switch DoorLock "Door Lock" {alexa="LockController.lockState"}
Contact DoorSensor "Door Sensor" {alexa="ContactSensor.detectionState"}

Hi Jeremy

The first post didnt work for me, but doing the group in the app does - thanks!