Garage door automation

I’m new to using Home Assistant and someone suggested that Node Red might be able to accomplish an automation I want to create.

I want my garage door to open when I approach it, however I only want this to happen if I’m not walking, as I do walk around my neighborhood a lot. Using Bluetooth or other devices attached to the cars is not an option I want to try. What I would like to do is set up several zones and use those with timers. Here is what I’m thinking of.

Since my house can be approached by car in 3 directions, I want to setup zones Z1, Z2 and Z3, which are sufficiently far enough away from my house that traveling by car I will easily reach my house in less than 3 minutes, but far enough that one couldn’t walk there that fast. My garage is located off an alley, so I will zones GarageSouth and GarageNorth. If my phone is detected in any of the Z zones and within 3 minutes the phone is detected in either Garage zone, the door should be opened. I can already control my garage and monitor it’s state from Home Assistant, so that part isn’t a problem.

Would Node Red be a good solution for this project? Now to complicate it further, I’d like to have this work for my wife as well using her phone. Also consider the fact that we might be in the same car! Issuing multiple open commands won’t be an issue, but the solution should not open the garage if my phone enters a Z zone and then my wife’s phone enters a Garage zone (let’s say she is walking home). It should be the same phone for both zones. And they should not “step on” each other, so if both of us are in separate cars and we each enter a Z zone about the same time, each of us should have 3 minutes to get to a Garage zone.

Any suggestions on how I should proceed with this project?

What mechanism do you plan to use to determine where the phone is?

The biggest problem is NOT making zones but to detect phone presence reliable & fast enough. At the same time not consuming a lot of battery in the phone.

Look at Owntracks that easily integrates with Node-RED. Study the possibilities for that software. There you can define your zones as you wish but if you say you do not want to use BT devices, well the reliability will not be very accurate and updates might not be fast enough. It could therefore happen you will sit in your car in front of your garage and wonder why the door is not already open

My experience is that you have to use BT beacons to get a better & more reliable solution but it will not work with your requirements since you say the zones should be "sufficiently far enough away from my house" and therefore I assume you can't really install long range beacons there

The only thing left for you to improve the performance is to use an operation mode that unfortunately consumes much more power from your phone battery

Besides, then always remember to leave your phone home when you take a longer walk with your dog in case you would happen to get too close or into one of your defined zones. The same goes for your wife

A challenge & cool & impressive solution would be to consider using a camera with number plate recognition software

Or just simply radio controlled, one transmitter for each car, just press the button when approaching your house. I guess this is not so fancy but a rather common, simple solution

1 Like

Hi Walter,

If he wants to experiment with license plate recognition, he can always try my node-red-contrib-openalpr-cloud node. But I would test it first before having it control his garage door :grin:

Bart

Yes, that is an alternative. Another one is to use Amazon Web Services Rekognition. It is pretty good in finding text in a pictures.
https://docs.aws.amazon.com/rekognition/latest/dg/text-detection.html

As example, the simple python script below sends an image for analyze and it returns

Detected text:LR33 TEE
Confidence: 99.14%
Id: 0
Type:LINE

I can imagine a possible setup:

  1. A motion detection software (like Motion) and a camera looking at the drive way, saves pictures to a folder for analyze when a car is detected

  2. A python script is started and loops thru the saved pics and sends them one-by-one to aws for analyze

  3. If the result matches a valid number plate, the garage door opens, the script stops sending further pictures and deletes or move them all to another folder, the python script terminates

  4. Motion waits for the next car

In Node-RED you can add a lot of other conditions, i.e. door should only open during certain hours or weekdays, whatever the imagination brings up

To integrate the python script with Node-RED I would use MQTT and just send the resulting text findings (with a minimum confidence level). In Node-RED you could then have a table or array with valid numbers that is used for validation

cooper

import boto3
imageFile='cooper.jpeg'
client=boto3.client('rekognition','eu-west-1')

with open(imageFile, 'rb') as image:
    response = client.detect_text(Image={'Bytes': image.read()})
    textDetections=response['TextDetections']
    print response
    print 'Matching texts'
    for text in textDetections:
            print 'Detected text:' + text['DetectedText']
            print 'Confidence: ' + "{:.2f}".format(text['Confidence']) + "%"
            print 'Id: {}'.format(text['Id'])
            if 'ParentId' in text:
                print 'Parent Id: {}'.format(text['ParentId'])
            print 'Type:' + text['Type']
            print
1 Like

Yes, certainly :smile:

As the others have said, GPS zones are not always 100% reliable.

Certainly I would try OwnTracks to help as this is MQTT based but remember that the Owntracks server would need to be Internet accessible. Best to keep that separate from any internal MQTT broker.

To get started however, I would use - at least to experiment with - a geofencing app on your mobile. Depending on the mobile platform, there are a number of these and typically they will interact with IFTTT or similar. This might be easier to begin experimenting with.

Well owntracks does have geofence capability built in (regions) so not a bad place to start, and Ben has done a contributed node to help decrypt own tracks data so you can use a public broker more safely.

Does OwnTracks give you a reliable position if the phone has not been used for some time (so has gone into deep sleep). This is a particular problem with the latest version of Android, at least on some phones, which aggressively prevent background apps from accessing the internet when the phone is not in use in order to prolong battery life. Also will it give an update quickly enough for this requirement?

Hard to say I'm afraid. Phones do their own thing to save battery power, it is up to the manufacturer and the OS vendor.

Like other GPS apps, the OwnTracks app will likely have its own schedule for updating but how much that is impacted by the phone, I couldn't predict. I use iOS anyway.

Also, while phone GPS is often great, it regularly falls back to estimates with a wide margin of error, not good for geofencing.

Frankly, if you want real reliability, a 433MHz transmitter/reciever combo would be the way to go with an "old fashioned" button.

As I said, you really need to have a go - that's why I suggested not starting with OwnTracks which needs some setup and configuration. But it depends on how much time you have and how keen you are to experiment.

Here is someone who has real experience in using OwnTracks and I have tested a lot.

I can tell you already, it will NOT be good enough to use the geofencing (called regions in OwnTracks) enter/leaving events with an iPhone for the use case described by the topic owner. It is simply too unpredictable in two ways:

  • it can take too long until the app knows you entered or left a region
  • it is VERY unpredictable when the app is given access to COMMUNICATE via the network, wifi or 4G when running in "significant move mode"

What I have received as explanation (from the app author) is that iOS more or less decides when and what the app is allowed to do, nothing to do about it. If it works better with Android, well, no idea, someone has to test this out

If the region crossings are not communicated to Node-RED, the garage door will be closed. Or opened later when the delayed events finally is communicated

Besides, even if it would be reliable and always communicated fast enough when leaving/entering regions, the remaining logic would be very complex covering all use cases and exceptions.

1 Like

Unless Owntracks makes use of a feature in Android of which I am unaware then the situation in Android will be the same. I have written a DIY application much like owntracks and even hooking into the latest Android features the app encounters exactly the same problems as described by @krambriw on iOS.