Plugin - IPhone Locator

I have just come home (18.45) and location of my iphone still had not changed since 6.15 this morning. I have Polling period: 720, and Dynamic Polling: map ticked and this 0:900,1:90,5:450,15:900,100:2800 in the field next to it. I guess that there is something wrong ?[/quote]

I have been seeing something peculiar like this and tried to track it down. It seems my Vera Lite was getting loaded and was crashing due to the logs being generated. I seem to have been able to grab the offending logs I believe to help amg0 troubleshoot the problem (as he knows from my PM) :wink:

This time my device hasn’t restarted (assuming from a buildup of logs) and I was able to pull live logs. It may require more verbose logs, but I do see something that doesn’t look proper. Down to the offending logs:

08 10/10/13 14:55:40.468 JobHandler_LuaUPnP::HandleActionRequest device: 53 service: urn:micasaverde-com:serviceId:HaDevice1 action: Poll <0x2e2f1680>
08 10/10/13 14:55:40.468 JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=53 <0x2e2f1680>
08 10/10/13 14:55:40.468 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HaDevice1 <0x2e2f1680>
08 10/10/13 14:55:40.468 JobHandler_LuaUPnP::HandleActionRequest argument action=Poll <0x2e2f1680>
02 10/10/13 14:55:40.469 Device_LuaUPnP::HandleActionRequest 53 none of the 1 implementations handled it <0x2e2f1680>
02 10/10/13 14:55:40.469 JobHandler_LuaUPnP::RunAction device 53 action urn:micasaverde-com:serviceId:HaDevice1/Poll failed with 501/No implementation <0x2e2f1680>
02 10/10/13 14:55:50.102 ZZZ-POLLING H1,C1,H2,C2,/1/1 <0x2c4f1680>

I’ll add in that DeviceNum 53 is my iPhoneLocator not sure why the name here for serviceId doesn’t reflect as such. Using v1.41 and the polling map is listed as such: 0:60,5:120,10:300,30:900[/quote]

Hello shmixx, no I am sorry but that log does not tell me a lot. . this “Poll” action is probably something internal to Vera and I have no idea what that could be or why this could be failing. The best bet is to enable DEBUG mode like explained and get a complete LuaPNP.log file. you could also run a command like tail -f luaPNP.log | grep iPhoneLocator in a ptty terminal and it will show us exactly all the debug lines generated by the IPhone plugin

NOTE to ALL users: I did pinpoint a potential bug, make sure PollingBase has a numeric value in it , whatever mode you use the polling ( dynamic or not ). no value could cause the plug in to crash and the symptom is no periodic refresh any more

I have just come home (18.45) and location of my iphone still had not changed since 6.15 this morning. I have Polling period: 720, and Dynamic Polling: map ticked and this 0:900,1:90,5:450,15:900,100:2800 in the field next to it. I guess that there is something wrong ?[/quote]

I have a potential bug in v<1.43 where empty PollingBase or PollingAuto could crash the plugin and prevent future refreshes. so my advise is upgrade to v >= 1.43 , or make sure these 2 variables are not left empty. hope it helps

Hi amg0, would it be possible to add PrevDistance as a device variable so that it would be possible to work out if a device is moving towards or away from ‘home’? (ok, so this could potentially be worked out by comparing the longitude and latitude figures against their previous values - but a little messy :P).

Thanks, a great plugin!! ;D

Nice work amg0!

I borrowed from your work (before you went and made it a plugin) and have been playing around with your code.

The purpose of the “fork” was to support different devices and location services. Since I don’t have Android or Windows Phone(s) to play with, I merely built a crude framework to base it all on. May be an idea to consider merging?

My “stuff” is published publicly on GitHub [url=https://github.com/snappygeek/Vera-GeoFence]https://github.com/snappygeek/Vera-GeoFence[/url]

PS: I’m a horrible coder.

@amg0

You are too quick with your updates ! I thought i was on the newest version 1.41… now its already 1.43 This is fantastic to see this great plugin developing further and further. Going to get the newest update now. By the time I log into the app store it might be 1.45 already… ;D

[quote=“nutcracker, post:83, topic:177230”]Hi amg0, would it be possible to add PrevDistance as a device variable so that it would be possible to work out if a device is moving towards or away from ‘home’? (ok, so this could potentially be worked out by comparing the longitude and latitude figures against their previous values - but a little messy :P).

Thanks, a great plugin!! ;D[/quote]

you have variables curLat and curLong for latest detected position and prevLat, prevLong for previous detected position. this is how I determine if the phone is going away or moving closer ( that logic is already built in the plugin and is how I chose what ICON to show ).

-- save position debug(string.format("saving lat:%f long:%f",lat,long)) local curlatitude = luup.variable_get(service,"CurLat", lul_device) local curlongitude = luup.variable_get(service,"CurLong", lul_device) debug(string.format("old values lat:%f long:%f",curlatitude,curlongitude)) luup.variable_set(service, "PrevLat", curlatitude, lul_device) luup.variable_set(service, "PrevLong", curlongitude, lul_device) luup.variable_set(service, "CurLat", lat, lul_device) luup.variable_set(service, "CurLong", long, lul_device)
using the function distanceBetween(lat1, lon1, lat2, lon2, distance_unit) in the code you can compare distance with home, or even distance between the 2 points. at some point I had some thinking about predicting arrival at home by calculating distance between last and prev position, dividing by period between 2 poll and have an average speed… but I did not code that yet.

[quote=“mikee123, post:85, topic:177230”]@amg0

You are too quick with your updates ! I thought i was on the newest version 1.41… now its already 1.43 This is fantastic to see this great plugin developing further and further. Going to get the newest update now. By the time I log into the app store it might be 1.45 already… ;D[/quote]

yes agile programing :slight_smile: in fact I just release a private version of v1.44 and I would like feedbacks on the Google Map and the Center Buttons. does it work for you ? do you see the map ? I am a bit confused by google map API and whether or not I need to register a developper API key. on my machine it works without it, but what about yours ? thx for your inputs

I just upgraded to 1.43, i did not see 1.44 (I have the newer 1.43) Happy to try though, but i might not be able to give you feedback until Saturday

[quote=“nutcracker, post:83, topic:177230”]Hi amg0, would it be possible to add PrevDistance as a device variable so that it would be possible to work out if a device is moving towards or away from ‘home’? (ok, so this could potentially be worked out by comparing the longitude and latitude figures against their previous values - but a little messy :P).

Thanks, a great plugin!! ;D[/quote]
Should be easy. Will add to my todo

Hi,

this is a great plugin - but do others find it drains your phone battery? - seems pinging FindMyIphone constantly (or every few minutes as I have it set) really draws down the battery. This leads to a bit of a dilemma - how to set the polling frequency often enough to be useful but minimise battery drain.

Also, we have a couple of Iphones on the same iCloud account but I only up the locator to look for mine - however, my wife is complaining her battery is draining quicker too. Does iCloud ping all devices even if the plugin is only monitoring one of them ?

I will have to play with the polling interval and the Dynamic Polling settings to see if I can find optimal settings. Anyone else found a sweet spot ?

Thanks

[quote=“amg0, post:89, topic:177230”][quote=“nutcracker, post:83, topic:177230”]Hi amg0, would it be possible to add PrevDistance as a device variable so that it would be possible to work out if a device is moving towards or away from ‘home’? (ok, so this could potentially be worked out by comparing the longitude and latitude figures against their previous values - but a little messy :P).

Thanks, a great plugin!! ;D[/quote]
Should be easy. Will add to my todo[/quote]

@amg0
Maybe it would also make sense to inject another new variable in the Advanced Tab where you just give the status of your calculations like: to/from/steady/home or going/coming/steady/home or such … which then can be fetched by Lua code.
This would free potential users to figure out how to code these result (eg. @nutcracker).
Just a thought …

MJ

[quote=“emtschei, post:91, topic:177230”][quote=“amg0, post:89, topic:177230”][quote=“nutcracker, post:83, topic:177230”]Hi amg0, would it be possible to add PrevDistance as a device variable so that it would be possible to work out if a device is moving towards or away from ‘home’? (ok, so this could potentially be worked out by comparing the longitude and latitude figures against their previous values - but a little messy :P).

Thanks, a great plugin!! ;D[/quote]
Should be easy. Will add to my todo[/quote]

@amg0
Maybe it would also make sense to inject another new variable in the Advanced Tab where you just give the status of your calculations like: to/from/steady/home or going/coming/steady/home or such … which then can be fetched by Lua code.
This would free potential users to figure out how to code these result (eg. @nutcracker).
Just a thought …

MJ[/quote]

+1!

[quote=“shmixx, post:92, topic:177230”][quote=“emtschei, post:91, topic:177230”][quote=“amg0, post:89, topic:177230”][quote=“nutcracker, post:83, topic:177230”]Hi amg0, would it be possible to add PrevDistance as a device variable so that it would be possible to work out if a device is moving towards or away from ‘home’? (ok, so this could potentially be worked out by comparing the longitude and latitude figures against their previous values - but a little messy :P).

Thanks, a great plugin!! ;D[/quote]
Should be easy. Will add to my todo[/quote]

@amg0
Maybe it would also make sense to inject another new variable in the Advanced Tab where you just give the status of your calculations like: to/from/steady/home or going/coming/steady/home or such … which then can be fetched by Lua code.
This would free potential users to figure out how to code these result (eg. @nutcracker).
Just a thought …

MJ[/quote]

+1![/quote]

I agree but do not you already have it ? if you fetch IconCode plugin variable, it returns a number:
0: means away
25: means out and going away
50: means muted
75: means away but coming home
100: means home

so another variable would be more user friendly but would have exactly the same values/semantic, hence I am not sure if it is really necessary. what are the thoughts ?

No match device :
50 10/11/13 7:58:21.091 luup_log:118: IPhoneLocator: forceRefresh action is called on behalf of device:118 <0x30504680>
50 10/11/13 7:58:22.584 luup_log:118: IPhoneLocator: iCloud device ignored, name:iPhone4S-Sebastien pattern:iPhone4S-Sebastien <0x30504680>
50 10/11/13 7:58:22.585 luup_log:118: IPhoneLocator: iCloud device ignored, name:iPad de 3l33t pattern:iPhone4S-Sebastien <0x30504680>
50 10/11/13 7:58:22.585 luup_log:118: IPhoneLocator: iCloud device ignored, name:iPad de 3l33t pattern:iPhone4S-Sebastien <0x30504680>
50 10/11/13 7:58:22.586 luup_log:118: IPhoneLocator: iCloud device ignored, name:iPad2-Sebastien pattern:iPhone4S-Sebastien <0x30504680>

[quote=“emtschei, post:76, topic:177230”][quote=“captainigloo, post:75, topic:177230”]Hello
For me version 1.40 and 1.41 release does not work, while 1.21 works fine. Why ???[/quote]

Bonjour Capitaine Igloo

Did you try to reboot your Vera system, refresh your browser [CTRL]-[F5] or reboot PC.
What does not work, what does the log say: http:///cgi-bin/cmh/log.sh?Device=LuaUPnP?
We need a bit more info as to what is wrong (log extracts/screenshots/error messages, etc.).

MJ[/quote]

[quote=“amg0, post:89, topic:177230”][quote=“nutcracker, post:83, topic:177230”]Hi amg0, would it be possible to add PrevDistance as a device variable so that it would be possible to work out if a device is moving towards or away from ‘home’? (ok, so this could potentially be worked out by comparing the longitude and latitude figures against their previous values - but a little messy :P).

Thanks, a great plugin!! ;D[/quote]
Should be easy. Will add to my todo[/quote]

Thank you. As per your other post, I’ll take a look at IconCode.

Btw, the support for _ didn’t work when I upgraded recently - using the advanced tab work around in the meantime.

[quote=“emtschei, post:91, topic:177230”][quote=“amg0, post:89, topic:177230”][quote=“nutcracker, post:83, topic:177230”]Hi amg0, would it be possible to add PrevDistance as a device variable so that it would be possible to work out if a device is moving towards or away from ‘home’? (ok, so this could potentially be worked out by comparing the longitude and latitude figures against their previous values - but a little messy :P).

Thanks, a great plugin!! ;D[/quote]
Should be easy. Will add to my todo[/quote]

@amg0
Maybe it would also make sense to inject another new variable in the Advanced Tab where you just give the status of your calculations like: to/from/steady/home or going/coming/steady/home or such … which then can be fetched by Lua code.
This would free potential users to figure out how to code these result (eg. @nutcracker).
Just a thought …

MJ[/quote]

The following is what I’ve used (in the past and currently) for plugins I’ve created for event triggers which PLEG could then use to ascertain direction.

For instance, a PLEG “Condition” could be (may be syntactically off): PhoneGoingAway = IsHome ; Five_Away ; Ten_Away < 00:30:00

And, of course, PLEG is capable of triggering scenes, etc.

This would avoid code outside of the plugin(s).

In D_*.json:

        {
            "id": 1,
            "label": {
                "lang_tag": "current_distance_greater",
                "text": "Distance to 'Home' is MORE than"
            },
            "serviceId": "urn:upnp-org:serviceId:IPhoneLocator1",
            "norepeat": "1",
            "argumentList": [
                {
                    "id": 1,
                    "prefix": {
                        "lang_tag": "hft_distance_tag",
                        "text": "Distance:"
                    },
                    "dataType": "i4",
                    "name": "CurrentDistance",
                    "comparisson": ">",
                    "suffix": {
                        "lang_tag": "hft_km_or_miles",
                        "text": "km or miles"
                    },
                    "HumanFriendlyText": {
                        "lang_tag": "hft_outside_radius",
                        "text": "_DEVICE_NAME_ is located OUTSIDE a radius of _ARGUMENT_VALUE_  KM/Miles/NM"
                    }

                }
            ]
        },
        {
            "id": 2,
            "label": {
                "lang_tag": "current_distance_less",
                "text": "Distance to 'Home' is LESS than"
            },
            "serviceId": "urn:upnp-org:serviceId:IPhoneLocator1",
            "norepeat": "1",
            "argumentList": [
                {
                    "id": 1,
                    "prefix": {
                        "lang_tag": "hft_distance_tag",
                        "text": "Distance:"
                    },
                    "dataType": "i4",
                    "name": "CurrentDistance",
                    "comparisson": "<",
                    "suffix": {
                        "lang_tag": "hft_km_or_miles",
                        "text": "km or miles"
                    },
                    "HumanFriendlyText": {
                        "lang_tag": "hft_inside_distance",
                        "text": "_DEVICE_NAME_ is located INSIDE a radius of _ARGUMENT_VALUE_ KM/Miles/NM"
                    }
                }
            ]
        },

In the S_*.xml file:

        <stateVariable>
            <sendEvents>yes</sendEvents>
            <name>CurrentDistance</name>
            <dataType>float</dataType>
            <defaultValue>0</defaultValue>
        </stateVariable>

Looks as if the update to 1.43 did not do a lot to updating my postition on my iphone. It is stuck again not updating (settings: I have Polling period: 720, and Dynamic Polling: map ticked and this 0:900,1:90,5:450,15:900,100:2800 in the field next to it. ) as per my previous post on this thread. Manual refresh still does not work, except when i am on my local LAN, then everything works fine, automatic updates and manual ones.

@amg0 - sorry I can’t PM (not permissioned?) - email format is aaaaaaaa_@aaa.com

[quote=“amg0, post:93, topic:177230”]I agree but do not you already have it ? if you fetch IconCode plugin variable, it returns a number:
0: means away
25: means out and going away
50: means muted
75: means away but coming home
100: means home

so another variable would be more user friendly but would have exactly the same values/semantic, hence I am not sure if it is really necessary. what are the thoughts ?[/quote]

amg0 - I think from my perspective, I didn’t realize those had different numerical values (my ignorance there), and the overall thought was to do similar to what you had mentioned before - build off logic to calculate distance changes over time and have a more accurate way to modify the polling period. I think we’ll all be better suited to relax until you get farther into the code for that as it will probably be more optimal to have the calculation done in the plugin, vs trying to bolt it on. So I think I may retract my +1. ;D

Meanwhile, I need to get out and test 1.44 and see if my polling gets stuck again and hopefully grab some logs of the issue. I’ll get back to you when I’m able to test. Hopefully later today or into the evening when I step out.

[quote=“amg0, post:93, topic:177230”]I agree but do not you already have it ? if you fetch IconCode plugin variable, it returns a number:
0: means away
25: means out and going away
50: means muted
75: means away but coming home
100: means home

so another variable would be more user friendly but would have exactly the same values/semantic, hence I am not sure if it is really necessary. what are the thoughts ?[/quote]

That of course make sense, @amg0, as the status is already there and I think one can work with this.
Thanks for the insight.

MJ