Hi have sucessfully managed to use ESPrence to detect the bluetooth signal from my watch and it can tell how far away it is from the sensor, this is great for say having the light on in the bathroom while you are in the room. Now its fairly easy to just make this work during the dark hours ( ie after twilight and before dawn) but how can I stop it detecting me when I walk past the front door to go to bed but still put the porch light on if I've been out late. Several ideas come to mind such as placing the sensor very close to the front door and letting it detect it at a very short distance only ( probably my best method so far) or setting the system before going out. But can anyone come up with any more ingenious methods ?
Forgive me @triphil
But where does Node RED fit into this?
Are you subscribing to its events in Node RED?
This is likely the simplest approach and the one I'd personally go with first. You can always add something more automated later but those things tend to get really complex very quickly.
I've also seen people use connected key-boards. Where you hang your keys. They detect when the keys are removed and can therefore be used to automate the in/out part of the process.
yes - many of the lights are controlled by Nodered and I thought this might be a good way of detecting me (or at least my watch) by the front door
I presume if you leave the house you normally take your mobile phone with you. Detecting the presence or absence of the mobile in the house would allow you to differentiate whether you are returning home or passing the front door in the entrance hall.
I use the node-red-contrib-arp node to control my security system automatically; turning it on
when I leave the house, and off when I return. It usually takes a short time to detect the changes such that the alarm system doesn't turn off until after I have entered the house, but if needed for your situation you could easily encode a delay.
Hope that helps.
As the Sensors are so cheap - why not put a 2nd one further outside the door ? Then use a Boolean node where both of them need to have been activated to indicated Coming/Going
Did consider that Craig but we live in a bungalow so would walk past the bedroom to get to the front door inside or outside the house
Just in case it wasn't clear, what I was suggesting was that you use the node-red-contrib-arp node to disable or enable the outdoor lights response to the bluetooth signal from your watch depending on whether your mobile phone is within or away from the property. You can include a delay such that on return to the property your phone does not immediately register that you are back, so that the lights will turn on. Equally, you could code that the bathroom light does not come on when you are returning.
I have a couple of mechanisms to track this - I've a button at each exit that I can press to put the house in away mode (tasmota light switches at the door - longpress configured to set this) and this could be used with some logic to track you being out, and to put the light on when you return, but not to put the light on if you've not been out, but pass your door.
I also use node-red-contrib-arp to look for my phone's mac address on the network to work out when I'm at home or not, this feeds into the code below. However in your case coming back at night, it may be possible for your phone to be detected while outside the house, and so a basic check of if it's on or off the network may not be sufficient, ie you may be outside on the network and in bluetooth range but those could be the same condition to you being inside the house. So I also look for 15 missed pings (arp scans really) to signify I'm out (1 arp scan per minute), and track whether I'm out, have just left, or have returned - this could then be used to trigger your events as required.
I probably derived the code from someones example but that's lost in time, so apologies for not crediting someone appropriately.
RSP
// anything stored in context is kept available for next time we get called
context.rgotping = 0;
context.rpingfails = context.rpingfails || 0;
//global.set('RhasJustLeft', false);
if(msg.payload.length > 0) {
context.rgotping = 1;
context.rpingfails = 0;
if (global.get('RisOut') === true){
//just returned
global.set('RhasReturned', true);
global.set('RhasJustLeft', false);
global.set('RisOut', false);
} else {
global.set('RhasReturned', false);
global.set('RhasJustLeft', false);
}
} else {
context.rpingfails +=1;
if(context.rpingfails==15) {
global.set('RhasJustLeft', true);
} else {
global.set('RhasJustLeft', false);
}
if(context.rpingfails>15) {
global.set('RisOut', true);
global.set('RhasJustLeft', false);
global.set('RhasReturned', false);
context.rgotping=0;
}
}
node.status({fill:"blue",shape:"ring",text:"Ping = "+context.rgotping+" | Fails = "+context.rpingfails+ " | RisOut "+global.get("RisOut")+" | RhasJustLeft "+global.get("RhasJustLeft")+" | RhasReturned "+global.get("RhasReturned")});
return msg;
The "arp scans" and code seems excessive, since only need to suppress the presence of the returning phone by introducing a DELAY node in the flow so that to all intents and purposes it has not yet returned even if it is once again on the wifi network as detected by the ARP node.
ARP scans of mobile devices is very unreliable anyway since the devices constantly go into low-power mode to save battery.
A simple physical button or the smart key holder (if you want more automation) is a better, simpler and more robust solution.
The button say's "I'm out now". One of the solar event aware timer tools lets you know whether it is light or dark, enhance with a light sensor if you also want it to come on for those horrible murky days where it will be darker before sunset. Further enhance with a magnetic door sensor so that "I'm out" can automatically turn back into "I'm In" if you don't want to have to press the button again (or use the smart key holder).
Simple and reliable. And doesn't matter if you forgot your phone or it ran out of power.
That's fair enough - I've had this running reliably for years and it works for me and I use the events to trigger other automations depending on who's arrived or left.
Use a different type of motion sensor - i have a standard outdoor unit - the type used for security lights etc - this is wired to the input of a shelly 2 and picks up movements outside the house and the shelly forwards on mqtt alerts which we then act on - so use your esphome devices inside and a standard shelly and light sensor outside (make sure that the stadnard sensor outputs a standard AC high voltage with an on/off relay mechanism - apparently many of the cheaper ones put out a varying voltage (i.e. not on or off) and this makes it impossible to detect with a shelly
Craig
Or plug a security light into a shelly with current measuring capability and use that to detect when the light turns on.