Howto check if I am at home easily

4,661 views
Skip to first unread message

oliver_...@gmx.de

unread,
Jan 11, 2013, 4:33:38 PM1/11/13
to ope...@googlegroups.com
Hi erveryone,

I would like to implement a check if I am at home.

My first idea was to ping the IP of my Smartphone (iPhone) as it always uses the local network via Wifi. So if the access point is unreachable I cannot ping the phone. From this it follows that I'm not at home.

Anyway, I face the problem that the iPhone doesn't response my ping requests if I haven't used the device for some time. I have been thinking about running any "server App" to telnet the port, but this doesn't work reliable, too.

Does anyone have ideas how to check absence easily?

Thanks for sharing your ideas and experiences.

Kind regards
Oliver

Victor Belov

unread,
Jan 11, 2013, 4:48:48 PM1/11/13
to ope...@googlegroups.com
Hi,

There were a discussion recently, about google location integration. I believe this would be the best way to do it!

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "openhab" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/T3vn-8smfH4J.
To post to this group, send email to ope...@googlegroups.com.
To unsubscribe from this group, send email to openhab+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openhab?hl=en.

Romain Bourdy

unread,
Jan 13, 2013, 7:29:00 AM1/13/13
to ope...@googlegroups.com
Bluetooth ping could work, as the phone should be listening for pairing requests. At an additional battery cost for sure :)

Nico Lembrechts

unread,
Jan 14, 2013, 9:27:44 AM1/14/13
to ope...@googlegroups.com
Hi,

I use a bash script on my linux box because the openhab build in bluetooth support is not working for me. Maybe you can have alook at my script. It uses l2ping. This also works with phones who are not discoverable.

Regards,
Nico

Op zondag 13 januari 2013 13:29:00 UTC+1 schreef Romain Bourdy het volgende:
BT_proximity.sh

J. Wege

unread,
Jan 15, 2013, 5:53:49 PM1/15/13
to ope...@googlegroups.com

From the results we got in our domotic projects with a number of different "items telling be home" (like tags on keys, pinging iPhones or localisation services from google), this is not that easy to achieve, since "single sign of presence" fairly often misleads and the result is wrong.

Examples: iPhone switched off / running out of battery / forgotten at friends / left in the car, wife cruises / bought a new one and no time to reajust the server / key left in the house / key taken with but just at the entrance an talking to neighbors for some minutes ...

Therefor we have subdivided this into "weak signs" and "strong signs". At recognition of weak signs, we try to collect at least two or three to make a desicion, where strong ones make an instant desicion. Strong ones are Keypads, Switches like "come home procedure" etc. Weak ones are "personalized services" like iPhone, Key-Tags or a "response" like server sends a request to the iPhone once detetcts presence and user responds within a timeframe.

We did this "strange" rules since either:

- your status makes strong sense and actions --> shall be REALLY reliable (i.e. inform Police/Alarm if lightswitch used, but all people absent)

- your status makes weak sense --> why at all have it?


In the end, mostly we came back to things like keypads or switches that are just touched when coming home or leaving to be the most reliable ones. We need to wait for people having injected RFID's or really good facial recognition to make strong desicions on presence completely automatic, I fear.

regards
jw

dari....@gmail.com

unread,
Jan 16, 2013, 8:18:35 AM1/16/13
to ope...@googlegroups.com
A friend did it using NFC tags, he same some tags in key position over the home. Once the smartphone is placed over one of these tags and HTTP call is sent to an HTTP board (is not using openHAB) that act as welcome back home.

I'm not sure if new iPhone has or not NFC support.

Regards,
Dario.



On Friday, January 11, 2013 10:33:38 PM UTC+1, oliver_...@gmx.de wrote:

Nico Lembrechts

unread,
Jan 16, 2013, 9:24:21 AM1/16/13
to ope...@googlegroups.com
I do the same with a karotz http://store.karotz.com/en_WW/ 
It kan read RFID en do http request. But then you are already in your house. With the bluetooth approach you can already detect when you approach your frontdoor or backyard and switch on garden lights, disable alarms, open screens that block access to my backdoor etc ...
The solution that works best for me for the moment is :
A button at both front and backdoor with led indicator (blinking or not) that puts the house in "away" mode when i push it. This turns of all the lights and other devices in my house.  Then it ignores bluetooth and wifi monitors for my phone for 5 minutes to be sure i am really away. Later when I came back home. Then when i detect the IP of my phone or the bluetooth ID of my phone the house switches to "home" mode again and multiple things happen. Like switch backyard lights if dark, wakeup satelite receiver  turn on music, rollup screens etc ..

Maybe this helps.
Regards,
Nico


2013/1/16 <dari....@gmail.com>
--
You received this message because you are subscribed to the Google Groups "openhab" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/k-j-DsuisGsJ.

Karel Goderis

unread,
Jan 19, 2013, 12:38:16 PM1/19/13
to ope...@googlegroups.com
Nico

any outdoor / frontdoor-panel bluetooth device you recommend?

Karel

Nico Lembrechts

unread,
Jan 21, 2013, 7:26:59 AM1/21/13
to ope...@googlegroups.com
Karel,

I use a bluetooth usb dongle in the server where openhab is running. The range is 100 meter according to the specifications. 
I combine this with a ping to the IP of my smartphone. This is often detected before the bluetooth signal. But whatever is detected first triggers my "comming home" sequence.
Maybe you can use a rasperry pi for this if your server is not close to your door.
I also have a button at the doors for manualy changing the house modes.

I hope this helps.
I can share my scripts as well if you like.
Regards,
Nico

Op zaterdag 19 januari 2013 18:38:16 UTC+1 schreef karel....@me.com het volgende:

Victor Belov

unread,
Jan 21, 2013, 8:18:30 AM1/21/13
to ope...@googlegroups.com
Hi,

I would love to see your scripts for bluetooth and pings!

To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/ZAOWzArPLGIJ.

Victor Belov

unread,
Jan 21, 2013, 10:26:52 AM1/21/13
to ope...@googlegroups.com
Hi,

So you need to assign static IPs to your mobiles on your home network then, right?

Best regards,
Victor Belov

On Mon, Jan 21, 2013 at 6:48 PM, Nico Lembrechts <nico...@gmail.com> wrote:
For the ping I use the build in openhab method like this :
Switch Network_GalaxyS   "GSM Nico [%S]" <network> (Status)   { nh="192.168.1.102" }

For the bluetooth detection i created two items :
Contact Bluetooth_Nico "Bluetooth GSM Nico [MAP(bluetooth.map):%S]" <contact>
Contact Bluetooth_Katrien "Bluetooth GSM Katrien [MAP(bluetooth.map):%S]" <contact>

And for the bluetooth detection i use the attached shell script that runs as root in the background on my server.
I have attached my rules file too because i do some stuff in there as well.

Regards,
Nico


2013/1/21 Victor Belov <belov...@gmail.com>

Nico Lembrechts

unread,
Jan 21, 2013, 2:44:01 PM1/21/13
to ope...@googlegroups.com

Yes, i use dhcp server configured to assign the same ip every time . Based on the mac address .

Op 21 jan. 2013 16:26 schreef "Victor Belov" <belov...@gmail.com> het volgende:

Karel Goderis

unread,
Jan 21, 2013, 3:17:15 PM1/21/13
to ope...@googlegroups.com
Interesting

My server is in the basement and surrounded with quite a bit of concrete. 100m seems quite a bit but I presume that is when there is clear line of sight. 

Anyways I tested both google lattitude as well as the iOS functionality and the results are quite off my expectations eg the radius to take into account is about 50 to 100m. Not really useable to say the least.

A short distance solution like Bluetooth is more appropriate but even then if you say 100m it is still too much.....

K

Sent from my iPhone
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/ZAOWzArPLGIJ.

Victor Belov

unread,
Jan 21, 2013, 3:25:58 PM1/21/13
to ope...@googlegroups.com
Hi,

Presumably, you can use multiply bluetooth anchors inside the house. One can be created really cheaply on base of Raspy and bluetooth USB dongle.
P.S. with RSSI and trilateration on a network of such devices you can potentially position any bluetooth device inside your house :-)

Best regards,
Victor Belov

Ben Jones

unread,
Jul 19, 2013, 4:11:00 AM7/19/13
to ope...@googlegroups.com
Hi Nico,

Sorry for resurrecting such an old thread but I have been searching for better methods for detecting presence and came across your bluetooth scripts. I have been using the network health binding for pinging my Android/iPhones static IP addresses but these seem to be fairly unreliable. They work most of the time but sometimes the WIFI radios shutoff and presence detection fails.

So I bought a few cheap BT USB dongles in the hope I could plug them into the Raspberry Pi's I have dotted around the house, and use your scripts to detect presence more reliably. However I have been having a lot of trouble with them. When plugged into a RPi I can call l2ping once and it works fine, then the second time I call it, the whole RPi crashes, locks up, and has to be power cycled.

I have tried two different dongles, and have a third on order (for which I don't hold much hope!). I also tried these dongles in my Intel based Ubuntu 12.04 headless server. This was slightly better, I could ping a device 4-5 times before it crashed the whole machine.

Just wondering if you have seen this sort of behaviour? Do you have an recommendations for the type of BT USB dongle I should be using? BT seems a much more reliable method for detecting presence, I just need to get it to stop crashing my devices!

Many thanks,
Ben

On Tuesday, 22 January 2013 03:48:30 UTC+13, Nico Lembrechts wrote:
For the ping I use the build in openhab method like this :
Switch Network_GalaxyS   "GSM Nico [%S]" <network> (Status)   { nh="192.168.1.102" }

For the bluetooth detection i created two items :
Contact Bluetooth_Nico "Bluetooth GSM Nico [MAP(bluetooth.map):%S]" <contact>
Contact Bluetooth_Katrien "Bluetooth GSM Katrien [MAP(bluetooth.map):%S]" <contact>

And for the bluetooth detection i use the attached shell script that runs as root in the background on my server.
I have attached my rules file too because i do some stuff in there as well.

Regards,
Nico


2013/1/21 Victor Belov <belov...@gmail.com>
Hi,

Nico Lembrechts

unread,
Jul 19, 2013, 4:40:50 AM7/19/13
to ope...@googlegroups.com
Hi Ben,

I haven't seen that sort of behavior already. The first thing I think of is that you need to increase the sleep time in between l2ping attempts.
From what I remember when I played with hcitool you always need to wait until a previous Bluetooth related process is stopped od it can indeed freeze your machine.
Also make sure not other Bluetooth related daemons are running. By default Ubuntu starts some Bluetooth server. I believe you can do /etc/init.d/bluetooth stop or something like that.
No idea for the raspberry, but i am sure i already used my script on a PI some time ago. Don't remeber what OS I had installed back then.
My best guess is an issue with different processes that all want to access the Bluetooth stack at the same time.

Good luck


2013/7/19 Ben Jones <ben.j...@gmail.com>
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ben Jones

unread,
Jul 19, 2013, 4:42:18 AM7/19/13
to ope...@googlegroups.com

Jonathan Spooner

unread,
Jul 19, 2013, 6:03:17 AM7/19/13
to ope...@googlegroups.com
I stuck some notes on the wiki regarding how I do it.... it might give you some ideas... I just use hcitool scan.


Jon

Ben Jones

unread,
Jul 21, 2013, 4:38:51 PM7/21/13
to ope...@googlegroups.com
Yeah I saw that thanks Jon. Unfortunately the RPis are very unstable with the BT dongle plugged in. I have just ordered some from ModMyPi which apparently are supposed to work no problem on the RPi so I will test with those.

As for your script, I was under the impression that l2ping would be a bit quicker than a full scan? What are your reasons for doing a scan rather than a ping?

Cheers for your help!
Ben

Jonathan Spooner

unread,
Jul 22, 2013, 4:41:36 AM7/22/13
to ope...@googlegroups.com
I originally just thought keep it as passive as possible, no setup required etc, just have my script look out for whatever BT mac addresses I deem fit.  Other than that no reason.

Jon



--

Max Stephan

unread,
Nov 13, 2013, 9:51:23 AM11/13/13
to ope...@googlegroups.com
Hi,

old thread, but still I have a different approach to this as I was neither able to get the bluetooth nor the network health solution described below work properly for me. None of our devices was visible using the bluetooth solution, neither on my RasPlex devices nor on my ReadyNAS, and ping only works occasionally.

I have an AVM fritzbox which (at least for the past four weeks) shows a reliable status of devices connected to our network using the built-in "ctlmgr_ctl r landevice" command (see http://www.wehavemorefun.de/fritzbox/Landevice). Thus I have opened telnet on my fritzbox and put a shell script on the fritzbox which just dumps out all known landevices with their current connection status.

On my openhab server (which is a ReadyNAS running some kind of linux) i have another expect script regularly run by cron that telnets to the fritzbox, dumps the devices using the script above and updates the status of all known landevices in openhab using the REST interface.

In case someone is interested in more details just drop a note here and I will provide more details. It is quite a hacky solution though, but works fine for me.

The ctrlmgr_ctl command on the fritzbox btw provides really nice possibilities like turning on/off guest wlan, getting traffic stats and more... It would be highly appreciated if someone was able to extend the fritzbox binding by some of these capabilities. Documentation on this can be found http://www.wehavemorefun.de/fritzbox/User-Interface-Module, unfortunately my own programming skills are far below requirements for extending the binding. The script solution above could be extended as well, but again this is just some dirty hack.

Max



On Friday, January 11, 2013 10:33:38 PM UTC+1, oliver_...@gmx.de wrote:

Wajid Malik

unread,
Jul 16, 2014, 2:38:15 AM7/16/14
to ope...@googlegroups.com

I just want to do that when my mobile's Bluetooth is on, then the Openhab shows me like Bluetooth  status changed to ON and when its off it should show as Bluetooth status is OFF and also when the status is ON it should send a message to my hangout like Bluetooth is on or anything just to indicate that its on.

As i am not a programmer so i am getting confused with codes and writing scripts etc. can any one guide me how to do and what should i write in rules file.

upto now i have just made item files which is showing number of paired devices and new device detected, but its continuously showing as MyMobile status updated to ON, i dont know how to make it status OFF when bluetooth is OFF and on when blue tooth is ON.

here is my item file:

Switch MyMobile                                           { bluetooth="My Mobile's Bluetooth MAC!" }
String UnknownDevices    "Unknown devices in range: [%s]" { bluetooth="?" }
Number NoOfPairedDevices "Paired devices in range: [%s]"  { bluetooth="!" }

Regards

Wajid 

Alex Karls

unread,
Jul 16, 2014, 3:53:07 AM7/16/14
to ope...@googlegroups.com
Has been mention already for sure, but why don´t use MQTT / owntracks?

Maximilian

unread,
Jul 17, 2014, 1:39:33 AM7/17/14
to
Hi,

mqttitude looks good to me too.
But I do not get it to work properly.

The app shows a coming home message when I come home.
But the switches in openhab won't update nor will the map load in google maps.


Here is my config I have so far:

Items:
Switch    Presence_PhoneMqttHome    "Maximilian at Home"    { mqttitude="100:/owntracks/xxxxx/i5-weiss:home" }
String    Presence_PhoneMqttHome_gm    "Maximilian at Home on google Maps"    { mqtt="<[100:owntracks/xxxxx/i5-weiss:state:JS(mqttitude-maps.js)]" }


Sitemap:
Frame label="Location" {
Switch  item=Presence_PhoneMqttHome
Webview  url="https://192.168.4.208:8443/static/map.html"  height=12
}


webapps/static/maps.html:
<!DOCTYPE html>
<html>
  <head>
    <style>
      #map_canvas {
        width: 900px;
        height:500px;
      }
    </style>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
    <script src="//maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script>
      $(function() {
    $.ajax({
        url: "/rest/items/Presence_PhoneMqttHome_gm?type=json",
        dataType: "json",
        data: {
        },
        success: function( data ) {
             console.log(data);
             var coords = data.state.split(',');
             var latlng = new google.maps.LatLng(coords[0],coords[1]);
             var map_canvas = document.getElementById('map_canvas');
                 var map_options = {
                    center: latlng,
                    zoom: 14,
                    mapTypeId: google.maps.MapTypeId.HYBRID
                }
                var map = new google.maps.Map(map_canvas, map_options)
            var marker = new google.maps.Marker({
                position: latlng,
                    map: map,
                    title:"Maximilians Iphone 6",
                image: "http://s1.hubimg.com/u/7148626_f520.jpg"
            });
            }
      });
    });
    </script>
  </head>
  <body>
    <div id="map_canvas"></div>
  </body>



openhab.cfg:
mqttitude
mqttitude:home.lat=49.123456
mqttitude:home.lon=11.123456
mqttitude:geofence=50


mqtt
mqtt:100.url=ssl://m20.cloudmqtt.com:20575
mqtt:100.clientId=xxxxx/oH
mqtt:100.user=xxxxx
mqtt:100.pwd=xxxxxxxxx


-> I can see a url with coordinates appear in the debug that works. (Cant remeber it since its been I while since I tried. Might update that by tonight.)

Do you have any hints ?

kr
maximilian


Alex Karls

unread,
Jul 17, 2014, 2:05:38 AM7/17/14
to ope...@googlegroups.com
First thing: resize the radius of the home geofence, 50 meters is (for where i´m from) way to small, mine is set to 200. 
Next thing: in which Topic to you post from your iPhone? What settings do you have in the App?

The switch item and the map look ok to me.. When i come home it looks like this in the log:
17:02:09.329 TRACE o.o.b.m.i.MqttitudeConsumer[:109]- Message received on topic owntracks/alex/iphone: {"t":"p","tst":"1405262918","acc":"165","_type":"location","lon":"11.4754","lat":"49.2615","batt":"92"}
17:08:35.427 TRACE o.o.b.m.i.MqttitudeConsumer[:123]- Checking item alex...
17:08:35.432 TRACE o.o.b.m.i.MqttitudeConsumer[:137]- Location received for alex: Lat: 49.2615, Long: 11.4754
17:08:35.438 DEBUG o.o.b.m.i.MqttitudeConsumer[:147]- alex is inside the 'home' geofence (15.038931532606505m)

I mighty be worth to set the logging level to TRACE for MQTT in logback.xml:
<logger name="org.openhab.binding.mqtt" level="TRACE" />
<logger name="org.openhab.binding.mqttitude" level="TRACE" />



mqttitude:home.lat=49.46290
mqttitude:home.lon=11.08180

mqttitude:geofence=50


mqtt
mqtt:100.url=ssl://m20.cloudmqtt.com:20575
mqtt:100.clientId=xxxxx/oH
mqtt:100.user=xxxxx
mqtt:100.pwd=xxxxxxxxx


-> I can see a url or coordinates appear in the debug that works. (Cant remeber it since its been I while since I tried. Might update that by tonight.)


Do you have any hints ?

kr
maximilian


--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openhab/S79q1Kde9cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.



--
mit freundlichen Grüßen,
Alexander Karls

Wajid Malik

unread,
Jul 17, 2014, 2:09:57 AM7/17/14
to ope...@googlegroups.com

Hello, i have done the bluetooth binding, now openhab detects when any bluetooth device is in range, now i want to use bluetooth dongle in my office which can get connected to openhab and when a bluetooth device enters in the range it send message on hangout account defined in rule file. How can i integrate blueooth dongle and which bluetooth dongle is compatible with openhab?

Regards

Wajid Naeem Malik 

Ben Jones

unread,
Jul 17, 2014, 3:08:12 AM7/17/14
to ope...@googlegroups.com
One thing - if you place a waypoint name at the end of your binding then openHAB will be looking for waypoint enter/leave events. So you need to ensure you have a waypoint setup in your OwnTracks app on your phone, with a description = 'home'.

IMO this is the best way to use the binding as it allows the OwnTracks app to use the builtin waypoint features of iOS and Android and only react to enter/leave events, rather than having to check every location update and calculate the distance from home each time.


Maximilian

unread,
Jul 17, 2014, 3:19:41 AM7/17/14
to ope...@googlegroups.com
Hi,

I will post the trace tonight but it looks quite familiar so far.

My owntracks config is attached.

I plan on using the distance feature to control my heating but it is not needed until winter.
For switching lights the waypoint mode is enough.
I have two waypoints (work and home while work is not being used at the moment)

kr
maximilian
status.png
settings_gesamt_1.png
settings_gesamt_2.png

Alex Karls

unread,
Jul 17, 2014, 4:53:03 AM7/17/14
to ope...@googlegroups.com
The reporting Topic is missing.. you only defined a subscription 


--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openhab/S79q1Kde9cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

Maximilian

unread,
Jul 17, 2014, 2:36:15 PM7/17/14
to ope...@googlegroups.com
Hm. Thanks.

I just tried it.
I could not see that the topic was missing clearly because evertime I select the i button that brings me to annother config page (see attachement) there was a value.
In light grey only but just like the others.
On the main page there was no entry of course.
I added in bold text on the front page what was on the config page in light grey now.

Still it neither shows the map nor does the swith button change its state.
Maybe something is wrong with the iframe ? Using the url from the log the correct google maps window opens.


Because I promised, here is the traces:

openhab.log
20:31:10.612 INFO  o.o.i.t.mqtt.MqttService[:106] - MQTT Service initialization completed.
20:31:10.614 INFO  o.o.i.t.m.i.MqttBrokerConnection[:112] - Starting MQTT broker connection '100'
20:31:42.769 DEBUG o.o.b.m.internal.MqttActivator[:34]- MQTT binding has been started.
20:31:42.796 TRACE o.o.b.m.i.MqttGenericBindingProvider[:52]- Starting to load MQTT config for item Presence_PhoneMqttHome_gm
20:31:42.808 DEBUG o.o.b.m.i.MqttItemConfig[:71]- Loaded MQTT config for item 'Presence_PhoneMqttHome_gm' : 1 subscribers, 0 publishers
20:31:42.877 DEBUG o.o.b.m.i.MqttEventBusBinding[:61]- MQTT: Activating event bus binding.
20:31:42.989 DEBUG o.o.b.m.i.MqttitudeActivator[:33]- Mqttitude binding has been started.
20:31:43.024 DEBUG o.o.b.m.i.MqttitudeBinding[:177]- Registering Mqttitude consumer for /owntracks/xxxxxxx/i5-weiss (on 100)
20:31:43.082 DEBUG o.o.b.m.i.MqttitudeBinding[:84]- Activating Mqttitude binding
20:31:47.709 TRACE o.o.b.m.i.MqttEventBusBinding[:298]- No mqtt-eventbus properties configured.
20:31:47.714 DEBUG o.o.b.m.i.MqttitudeBinding[:118]- Mqttitude binding configuration updated, 'home' location specified (Lat: 49.4629, Long: 11.0818) with a geofence of 500.0m.
20:31:47.716 DEBUG o.o.b.m.i.MqttitudeBinding[:152]- Unregistering Mqttitude consumer for /owntracks/xxxxx/i5-weiss (on 100)
20:31:47.763 DEBUG o.o.b.m.i.MqttitudeBinding[:177]- Registering Mqttitude consumer for /owntracks/xxxxx/i5-weiss (on 100)

event.log
2014-07-17 20:31:43 - Presence_PhoneMqttHome_gm state updated to http://maps.google.com/maps?z=12&t=m&q=loc:49.4631+11.0823
2014-07-17 20:31:43 - Presence_PhoneMqttHome_gm state updated to http://maps.google.com/maps?z=12&t=m&q=loc:49.4631+11.0823
2014-07-17 20:31:47 - Presence_PhoneMqttHome_gm state updated to http://maps.google.com/maps?z=12&t=m&q=loc:49.4631+11.0823

Kr
maximilian
g.PNG

Alex Karls

unread,
Jul 18, 2014, 6:20:36 AM7/18/14
to ope...@googlegroups.com
Thanks for the log. It looks like OH never knows what your phone is talking because there is no kind of message in the log like in mine:
17:02:09.329 TRACE o.o.b.m.i.MqttitudeConsumer[:109]- Message received on topic owntracks/alex/iphone: {"t":"p","tst":"1405262918","acc":"165","_type":"location","lon":"11.4754","lat":"49.2615","batt":"92"}

So, i guess the you misconfigured either the app or the binding, because the consumer registers at MQTT, which is OK. 

Here is my item:

Switch  alex    "Anwesenheitstatus Alex (GPS / ownTracks)"      (GF_Mobiles,gMobiles)           { mqttitude="mosquitto:owntracks/alex/iphone" } 

and my openhab.cfg (i know, its only TCP ;) )

################################### MQTT Transport #########################################

#

# Define your MQTT broker connections here for use in the MQTT Binding or MQTT

# Persistence bundles. Replace <broker> with a id you choose.


# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883

mqtt:mosquitto.url=tcp://localhost:1883


# Optional. Client id (max 23 chars) to use when connecting to the broker.

# If not provided a default one is generated.

#mqtt:<broker>.clientId=<clientId>


# Optional. User id to authenticate with the broker.

 mqtt:mosquitto.user=mosquitto


# Optional. Password to authenticate with the broker.

mqtt:mosquitto.pwd=snafu12345 (not my real Password)


# Optional. Set the quality of service level for sending messages to this broker. 

# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2 

# (Deliver exactly once). Defaults to 0.

#mqtt:<broker>.qos=<qos>


# Optional. True or false. Defines if the broker should retain the messages sent to

# it. Defaults to false.

#mqtt:<broker>.retain=<retain>


# Optional. True or false. Defines if messages are published asynchronously or

# synchronously. Defaults to true.

#mqtt:<broker>.async=<async>


On my phone i only configured the host, the port, set the "Auth"-Switch to active, entered Username and Passwort, set a client ID (free to choice) and under "Reporting" it set the DeviceID (free to choice) and the topic, which MUST BE THE SAME as in the binding config, to owntracks/alex/iphone. Then, defined a home zone with 200 meters radius in openhab.cfg 

################################# Mqttitude Binding ###################################

#

# Mqttitude can track your presence in two ways;

#

#  1. Regions - by defining a region in your Mqttitude app (on your phone) you specify

#               a set of lat/lon coordinates, a geofence, and a name - by using this name 

#                               in your item binding openHAB will listen for enter/leave events for this 

#               region and thus allow you to track your presence in multiple locations

#  2. Home    - by defining the lat/lon of your home, along with a geofence radius (below), 

#               the binding will listen for location publishes from the Mqttitude app and 

#               manually calculate the distance from your 'home'

#

# Optional. The latitude/longitude coordinates of 'home'. 

mqttitude:home.lat=49.1234567

mqttitude:home.lon=11.1234567


# Optional. The geofence radius.

mqttitude:geofence=200


and thats it. 

Ben Jones

unread,
Jul 18, 2014, 6:25:00 AM7/18/14
to ope...@googlegroups.com
Alex - is there any reason you don't use the waypoints feature of OwnTracks and the binding? 

Alex Karls

unread,
Jul 18, 2014, 8:14:13 AM7/18/14
to ope...@googlegroups.com
yes: is simply don´t need this feature.. what i needed was presence detection to unlock the flat, and thats what it does.. K.I.S.S ;) 


On Fri, Jul 18, 2014 at 12:25 PM, Ben Jones <ben.j...@gmail.com> wrote:
Alex - is there any reason you don't use the waypoints feature of OwnTracks and the binding? 

--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openhab/S79q1Kde9cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

Ben Jones

unread,
Jul 18, 2014, 4:11:11 PM7/18/14
to ope...@googlegroups.com
Fair enough - I would try the waypoint functionality if you can though - IMO it is much better. The reason being the phone OSs have built in region monitoring services and will send the enter/leave events more accurately than having to wait for location updates, which are only sent every 'n' secs or after 'n' meters.

It means you can reduce the frequency of the simple location updates right down and save battery life (potentially) since OwnTracks only really cares about these enter/leave events. It also means you eliminate the problem whereby you have location updates set to say every 200m and you get an update when you are 225m from home. Then you arrive home and due to inaccuracies in location awareness the phone still thinks you are 50m from home. So you won't get any further location update since the phone thinks you have only moved 175m.

Hope that makes sense!

Alex Karls

unread,
Jul 19, 2014, 3:08:08 AM7/19/14
to ope...@googlegroups.com
as iPhone User, the argument "save battery live" tickled my curiosity ;) I`ll give a try.. Thanks Ben

Maximilian

unread,
Jul 19, 2014, 5:14:43 AM7/19/14
to ope...@googlegroups.com
Hi,

what brought me closer to the solution:


- adding a topic in the app (did not solve it allone)
- remove the ":home" in my switch: Switch    Presence_PhoneMqttHome    "Maximilian at Home"    { mqttitude="100:/owntracks/
xxxxx/i5-weiss:home" }
I assume the binding uses manual mode since a geofence is defined.
The app tells me that I left the reagion home though. (I defined a waypoint but I guess that the binding does not use that information)

the trace shows the follogin:

21:24:59.572 TRACE o.o.b.m.i.MqttitudeConsumer[:109] - Message received on topic owntracks/xxx/i5-weiss: {"t":"p","tst":"1405711360","acc":"65","lon":"11.0823","_type":"location","lat":"49.4631","batt":"95"}
21:24:59.580 TRACE o.o.b.m.i.MqttitudeConsumer[:123] - Checking item Presence_PhoneMqttHome...
21:24:59.580 TRACE o.o.b.m.i.MqttitudeConsumer[:137] - Location received for Presence_PhoneMqttHome: Lat: 49.4631, Long: 11.0823
21:24:59.581 DEBUG o.o.b.m.i.MqttitudeConsumer[:147] - Presence_PhoneMqttHome is inside the 'home' geofence (42.527317231402925m)
21:24:59.582 INFO  runtime.busevents[:26] - Presence_PhoneMqttHome state updated to ON
21:24:59.591 INFO  runtime.busevents[:26] - Presence_PhoneMqttHome_gm state updated to http://maps.google.com/maps?z=12&t=m&q=loc:49.4631+11.0823

21:25:03.980 TRACE o.o.b.m.i.MqttitudeConsumer[:109] - Message received on topic owntracks/xxxx/i5-weiss: {"t":"t","tst":"1405711364","acc":"65","lon":"11.0823","_type":"location","lat":"49.4631","batt":"95"}
21:25:03.988 TRACE o.o.b.m.i.MqttitudeConsumer[:123] - Checking item Presence_PhoneMqttHome...
21:25:03.989 TRACE o.o.b.m.i.MqttitudeConsumer[:137] - Location received for Presence_PhoneMqttHome: Lat: 49.4631, Long: 11.0823
21:25:03.989 DEBUG o.o.b.m.i.MqttitudeConsumer[:147] - Presence_PhoneMqttHome is inside the 'home' geofence (42.527317231402925m)
21:25:03.990 INFO  runtime.busevents[:26] - Presence_PhoneMqttHome state updated to ON
21:25:03.998 INFO  runtime.busevents[:26] - Presence_PhoneMqttHome_gm state updated to http://maps.google.com/maps?z=12&t=m&q=loc:49.4631+11.0823

when I add the ":home" to the item the log shows:
Not a location enter/leave event, ignoring
-> maybe it workes if I move around outside. Its just that then I cannot do my configuration easily... ;)

I will try the region mode and get back with more results.

kr
Maximilian

Alex Karls

unread,
Jul 19, 2014, 5:46:32 AM7/19/14
to ope...@googlegroups.com
good to hear that you are digging deeper :) good luck with the waypoints, i`m fumbling around with this since the last two hours, seem to work

Christoph Wempe

unread,
Jul 19, 2014, 6:55:06 AM7/19/14
to ope...@googlegroups.com
I use a rather unorthodox and individual method to track my "at home" status.

The first factor is to check if the phone is logged in on my wifi network.
But this was not accurat enouigh for me, because I life on the 3rd floor and my phone already (dis)connect on the other side of the street.

But I want to turn off the radio BEFOR I leave my flat and turn it on AFTER I closed the door.

I then realized I use my bluetooth headsets 99& of time I leave the house.

Now I use a combination of "connected to wifi" and "BT-headset is connected" to get a very precise moment when I leave the house.
(Android with Tasker)

Of cause there are down sides to this method.
Like, I don't use my headphones when I am with friends.

Darko Križić

unread,
Jul 19, 2014, 4:57:06 PM7/19/14
to ope...@googlegroups.com
Hi, 

I have 3 Airport Extreme spread over my house offering Wifi. I first wrote a script. Each member of my family has an iPhone (but could be any mobile phone). I gave each iPhone a unique IP-Address and wrote a script, that pinged each device. That did not work, because an iPhone is basically, but not all times:
  • iPhone active -> pingable
  • iPhone on standby on charger -> pingable
  • iPhone on standby no charger -> NOT pingable
So this solution was not reliable. I found out, that the iPhone is not pingable, but is still registered in the Wifi Access Points. I wrote a script, that asks all APs via SNMP for the registered MAC addresses. Here is how the binding for me looks like:

Switch DKrizic "Darko Krizic [MAP(presence.map):%s]" <present> (All,Presence,Persist) {exec="<[/usr/local/bin/presence_mac 90.b9.31.26.af.f5:100000:REGEX((.*))]"}


The script is called presence_mac and gets the MAC address of the iPhone. If the iPhone is in the network (even in standby without charger) it gives the following result:

root@openhab:~# /usr/local/bin/presence_mac 90.b9.31.26.af.f5

ON


And when it is offline:

root@openhab:~# /usr/local/bin/presence_mac 90.b9.31.26.af.f5

OFF


This works fully reliable. Here is the script.

#!/bin/bash

mac=$1

if [ "$mac" = "" ]

then

echo "ERROR"

exit 0

fi

macs=$(

for ax in axeg axog axdg aegh

do

snmpwalk -c public -v 2c -m AIRPORT-BASESTATION-3-MIB $ax SNMPv2-SMI:enterprises.apple.airport | grep wirelessPhysAddress | awk -F\" '{print $2}' | tr '[:upper:]' '[:lower:]' | tr ':' '.'

done

)

#echo $macs

count=$(echo $macs | grep $mac | wc -l)

#echo $count

if [ $count == 0 ]

then

echo "OFF"

else

echo "ON"

fi


Regards,

Darko

Alexander Karls

unread,
Jul 20, 2014, 2:29:35 AM7/20/14
to ope...@googlegroups.com
Good one.. I prefer to use SNMP at work for monitoring with Icinga / Nagios and Cacti, so i like this Solution very much :) 
--

Nico Lembrechts

unread,
Jan 21, 2013, 9:48:30 AM1/21/13
to ope...@googlegroups.com
For the ping I use the build in openhab method like this :
Switch Network_GalaxyS   "GSM Nico [%S]" <network> (Status)   { nh="192.168.1.102" }

For the bluetooth detection i created two items :
Contact Bluetooth_Nico "Bluetooth GSM Nico [MAP(bluetooth.map):%S]" <contact>
Contact Bluetooth_Katrien "Bluetooth GSM Katrien [MAP(bluetooth.map):%S]" <contact>

And for the bluetooth detection i use the attached shell script that runs as root in the background on my server.
I have attached my rules file too because i do some stuff in there as well.

Regards,
Nico


2013/1/21 Victor Belov <belov...@gmail.com>
Hi,

I would love to see your scripts for bluetooth and pings!
On Mon, Jan 21, 2013 at 4:26 PM, Nico Lembrechts <nico...@gmail.com> wrote:
Karel,

I use a bluetooth usb dongle in the server where openhab is running. The range is 100 meter according to the specifications. 
I combine this with a ping to the IP of my smartphone. This is often detected before the bluetooth signal. But whatever is detected first triggers my "comming home" sequence.
Maybe you can use a rasperry pi for this if your server is not close to your door.
I also have a button at the doors for manualy changing the house modes.

I hope this helps.
I can share my scripts as well if you like.
Regards,
Nico

Op zaterdag 19 januari 2013 18:38:16 UTC+1 schreef karel....@me.com het volgende:
Nico

any outdoor / frontdoor-panel bluetooth device you recommend?

Karel

On 16 Jan 2013, at 15:24, Nico Lembrechts <nico...@gmail.com> wrote:

I do the same with a karotz http://store.karotz.com/en_WW/ 
It kan read RFID en do http request. But then you are already in your house. With the bluetooth approach you can already detect when you approach your frontdoor or backyard and switch on garden lights, disable alarms, open screens that block access to my backdoor etc ...
The solution that works best for me for the moment is :
A button at both front and backdoor with led indicator (blinking or not) that puts the house in "away" mode when i push it. This turns of all the lights and other devices in my house.  Then it ignores bluetooth and wifi monitors for my phone for 5 minutes to be sure i am really away. Later when I came back home. Then when i detect the IP of my phone or the bluetooth ID of my phone the house switches to "home" mode again and multiple things happen. Like switch backyard lights if dark, wakeup satelite receiver  turn on music, rollup screens etc ..

Maybe this helps.
Regards,
Nico


2013/1/16 <dari....@gmail.com>
A friend did it using NFC tags, he same some tags in key position over the home. Once the smartphone is placed over one of these tags and HTTP call is sent to an HTTP board (is not using openHAB) that act as welcome back home.

I'm not sure if new iPhone has or not NFC support.

Regards,
Dario.
On Friday, January 11, 2013 10:33:38 PM UTC+1, oliver_...@gmx.de wrote:
Hi erveryone,

I would like to implement a check if I am at home.

My first idea was to ping the IP of my Smartphone (iPhone) as it always uses the local network via Wifi. So if the access point is unreachable I cannot ping the phone. From this it follows that I'm not at home.

Anyway, I face the problem that the iPhone doesn't response my ping requests if I haven't used the device for some time. I have been thinking about running any "server App" to telnet the port, but this doesn't work reliable, too.

Does anyone have ideas how to check absence easily?

Thanks for sharing your ideas and experiences.

Kind regards
Oliver

--
You received this message because you are subscribed to the Google Groups "openhab" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/k-j-DsuisGsJ.
To post to this group, send email to ope...@googlegroups.com.
To unsubscribe from this group, send email to openhab+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/openhab?hl=en.


--
You received this message because you are subscribed to the Google Groups "openhab" group.
To post to this group, send email to ope...@googlegroups.com.
To unsubscribe from this group, send email to openhab+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/openhab?hl=en.

--
You received this message because you are subscribed to the Google Groups "openhab" group.
To view this discussion on the web visit https://groups.google.com/d/msg/openhab/-/ZAOWzArPLGIJ.
To post to this group, send email to ope...@googlegroups.com.
To unsubscribe from this group, send email to openhab+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openhab?hl=en.

--
You received this message because you are subscribed to the Google Groups "openhab" group.

To post to this group, send email to ope...@googlegroups.com.
BT_proximity.sh
huisverlaten.rules
Reply all
Reply to author
Forward
0 new messages