That is very likely the case. But the last reading from the sensor will still be around so unless something went wrong (e.g. battery died), whatever the last reported value was will be its current state. You don’t need random readings. OH will retain the last reported value.
Here is what I did. It was my first DIY home automation project and it solves exactly this problem. The following is just the bare skeleton of a tutorial but hopefully it is enough to get you started.
Parts:
- Raspberry Pi 3 (a Raspberry Pi 0W would probably work just fine)
- Raspberry Pi Camera
- 2x Cheap reed sensors (I’ve two garage door openers)
- Dual Relay
- Lots of wire, I used speaker wire for the long runs
- Some resistors (I used 10K Ohm), though I’m not certain I used these in my setup
Wiring:
See Idiot’s Guide to a Raspberry Pi Garage Door Opener – driscocity.com for the tutorial I used to wire it all up. There are probably a lot of newer tutorials out there. At a high level:
- 5V Pin, Ground Pin, and GPIO Pins to the relay to control the relay
- two wires from the output side of the relay connected to the wall button the same place where the wires from the opener itself connect to the button (alternatively you can run a wire up to the opener itself and wire them to where the button wires attach to the opener
- 3.5V Pin and GPIO Pins wired to the reed sensors on the doors, using the resistors between the RPi and the sensor
- Attach the camera per included instructions
Software:
Remote open/close and open/close sensor reporting:
I posted my Python script here.
-
Trigger the Garage: OH sends an MQTT message which causes the script to set the pin that controls the relay to high, wait half a second, then sets it to low which simulates a person pressing the wall button to trigger the opener.
-
Report state of the Garage: This script periodically polls (several times a second) the GPIO pins attached to the reed switches and reports OPEN or CLOSED based on the state of the sensor.
In addition, I installed and configured uv4l to turn the attached RPi Camera into an IP stream.
openHAB:
Items
Switch aGarageOpener1 "Garage Door Opener 1"
Contact vGarageOpener1 "Garage Door Opener 1 is [MAP(en.map):%s]"
<garagedoor> (gDoorSensors,gDoorCounts)
{ mqtt="<[mosquitto:entry_sensors/main/garage/door1:state:default]" }
Switch aGarageOpener2 "Garage Door Opener 2"
Contact vGarageOpener2 "Garage Door Opener 2 is [MAP(en.map):%s]"
<garagedoor> (gDoorSensors, gDoorCounts)
{ mqtt="<[mosquitto:entry_sensors/main/garage/door2:state:default]" }
String GarageOpener2_Cmd
{ mqtt=">[mosquitto:entry_sensors/main/garage/door2/cmd:state:*:default]" }
Rules
rule "A Garage Opener was triggered"
when
Item aGarageOpener1 received command or
Item aGarageOpener2 received command
then
var topic = triggeringItem.name.substring(1) + "_Cmd"
sendCommand(topic, "ON")
logInfo(logName, "Garage opener " + triggeringItem.name.substring(triggeringItem.name.length-1) + " was triggered.")
if(vNetwork_Cerberos.state == OFF) { // this is a network binding Item that goes OFF when the RPi goes offline
aAlert.sendCommand("Attempting to trigger a garage opener but the controller is offline!")
}
end
Sitemap
Just the relevant snippets.
Switch item=aGarageOpener1 icon="garagedoorclosed" mappings=[ON=Open] visibility=[vGarageOpener1 == CLOSED]
Switch item=aGarageOpener1 icon="garagedooropen" mappings=[ON=Close] visibility=[vGarageOpener1 == OPEN]
Switch item=aGarageOpener2 icon="garagedoorclosed" mappings=[ON=Open] visibility=[vGarageOpener2 == CLOSED]
Switch item=aGarageOpener2 icon="garagedooropen" mappings=[ON=Close] visibility=[vGarageOpener2 == OPEN]
Video icon="camera" url="http://cerberos.koshak.net:8080/stream/video.mjpeg" encoding="mjpeg"
The visibility and custom icon is so the icon on the sitemap and the button are appropriate based on whether the garage door is open or closed.
So with minimal investment in cost and time (I spent an afternoon wiring it together) I can control my openers remotely and have two ways to verify they are closed remotely. And should I set up a security camera system I’ll already have one in the garage.
If I were to do it over again I would get a wide-angle camera (I still might) and would use a RPi 0W instead of a full RPi 3. If you don’t want to do the camera, you can probably implement this using an ESP8266 or Arduino.
If you want something off the shelf Garagio is worth a look.
If you are looking to get into more home automation, the Zwave controller would be worth a look as it will position you to gradualy add more zwave devices as you go.