Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Phone Detection and Flagging for home automation

If you have a question or need help, this is the place to be.
Post Reply
gizak
Posts: 1
Joined: Mon Feb 25, 2013 6:54 pm
Location: Phoenix, AZ

Phone Detection and Flagging for home automation

Post by gizak »

Goal: Use detection of Android phones on local network to activate/deactivate IP Camera Security System.

Ideally, I want to create it so that this only triggers when BOTH mine and my wife's cell phone are no longer connected to the home access point, and another action trigger to deactivate the cameras when at least 1 is connected.

First issue: Detection.
If possible, I want the PC to do be able to do this somehow, by polling for the hostname or ip address of both phones periodically, and when found, alert Eventghost - still have not found a way to do this easily.
Another way to do this is to have the phones themselves tell the eventghost they are "home" by using Tasker with the Eventghost plugin. Unfortunately, this will require more administration on both phones.
Anybody else have suggestions on multiple user presense via Android to --> Eventghost?

Second issue: Flagging.
In other automation programs, I would use flagging to require multiple triggers to be TRUE before an action would execute.
I need a way to tell Eventghost to only start an action when BOTH phones are NOT present, and to deactivate cameras if at least ONE phone IS present. Is there a way to pull this off with enable/disabling folders in Eventhost?

Once I can get these 2 issues sorted out, I can use EG to send cmds to my IP Camera Software to turn on/off inside cameras. No point in recording inside when people are home as it wastes network, power, and drive space resources =)

Maybe there are other ways to pull this off without Eventghost, but I've become fond of the silly ghost and use it for so many other things in my automation addiction.
/Another1Addicted2Automation
Dragon470
Experienced User
Posts: 205
Joined: Thu Feb 10, 2011 2:16 am

Re: Phone Detection and Flagging for home automation

Post by Dragon470 »

1. I would use the ping plugin if you will have your phones always connected to the network. Otherwise BT or something could be used.
2. This just requires some scripting.
phone check config.png
phone check config.png (17.11 KiB) Viewed 5169 times

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1544" Guid="{25A9A0C5-0D7E-4D93-B04B-1D4C52118B30}" Time="1362099865.79">
    <Autostart Name="Autostart" Expanded="True">
        <Plugin Identifier="PingPlugin" Guid="{E0E0AFD7-31D5-41FE-B9DA-237234DB07A7}" File="Ping">
            gAIpLg==
        </Plugin>
    </Autostart>
    <Folder Name="phone detect" Expanded="True">
        <Macro Name="Ping: Add Hosts: Phones 1 and 2 and initialize vars" Expanded="True">
            <Event Name="Main.OnInit" />
            <Action>
                PingPlugin.AddHost(u'192.168.1.151', u'Phone1', 200, 60, u'Phone1Present', u'Phone1Away', 1, 1)
            </Action>
            <Action>
                PingPlugin.AddHost(u'192.168.1.152', u'Phone2', 200, 60, u'Phone2Present', u'Phone2Away', 1, 1)
            </Action>
            <Action>
                EventGhost.PythonScript(u'eg.globals.Phone1Status = "Away"\neg.globals.Phone2Status = "Away"')
            </Action>
        </Macro>
        <Macro Name="Python Script" Expanded="True">
            <Event Name="Main.Phone1Present" />
            <Event Name="Main.Phone2Present" />
            <Event Name="Main.Phone1Away" />
            <Event Name="Main.Phone2Away" />
            <Action>
                EventGhost.PythonScript(u'x = eg.event.suffix[5:]\nprint x\n\nif x == "1Away":\n    eg.globals.Phone1Status = "Away"\nelif x == "2Away":\n    eg.globals.Phone2Status = "Away"\nelif x == "1Present":\n    eg.globals.Phone1Status = "Present"\nelif x == "2Present":\n    eg.globals.Phone1Status = "Present"\n    \n    \nif eg.globals.Phone1Status == "Away":\n    if eg.globals.Phone2Status == "Away":\n        eg.TriggerEvent("TurnOnCameras")\n    else:\n        eg.TriggerEvent("TurnOffCameras")\nelse:\n    eg.TriggerEvent("TurnOffCameras")')
            </Action>
        </Macro>
        <Macro Name="Ping: Get Hosts Status" Expanded="True">
            <Action>
                PingPlugin.RemoveHost(u'192.168.1.151')
            </Action>
            <Action>
                PingPlugin.RemoveHost(u'192.168.1.152')
            </Action>
        </Macro>
    </Folder>
</EventGhost>
Attachments
ping tested.xml
(2.15 KiB) Downloaded 228 times
miljbee
Experienced User
Posts: 146
Joined: Fri Mar 27, 2009 1:29 pm
Location: Orl├®ans, France

Re: Phone Detection and Flagging for home automation

Post by miljbee »

Yes, the detection is the hard part.

Here is how I have done it :

my AP is an Airport Extreme, and it has a nice feature for this purpose : It can output detailled logs of what it is currently doing via Syslog.
Windows doesn't support syslog, but the syslog protocol is really simple : it's jus a plain text broadcast using udp.
So I have written a simple UDP Listenenr in C# that receives all the airport log messages.
When I get a log messages concerning Association/Disassociation, they also contain the mac address of the client.
Using this ionformation, I can forward an event to EG Telling if the phone X has just connected or disconnected.

Previously, I was using the ping plugin. But it has some problems, I don't remember excatly what they were.
So I rewrote it to C#. I am still using it for monitoring various connected devices.

I have also tried with bt. Can't remember were I got some code to do that, but it wasn't really reliable.

Finally, I use Sosumi to locate my wife's iPhone via iCloud.
miljbee
TCP Events : A Better Network Event Sender/Receiver Plugin.
The Network Event Sender/Receiver in C#
Get events in EG from Google Calendar.
Fritte
Posts: 9
Joined: Sun Dec 29, 2013 7:29 pm

Re: Phone Detection and Flagging for home automation

Post by Fritte »

Would you like to share that syslog program?
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Phone Detection and Flagging for home automation

Post by Sem;colon »

...you could use tasker on android with some eventghost plugin, then you can tell tasker "if I'm connected to ssid xyz, send an event to eventghost" ;)
If you like my work, Image me a drink :wink:
blaher
Experienced User
Posts: 487
Joined: Thu Nov 17, 2011 1:27 am

Re: Phone Detection and Flagging for home automation

Post by blaher »

viewtopic.php?f=2&t=5955 has some more examples.
m19brandon
Experienced User
Posts: 177
Joined: Mon Feb 03, 2014 10:36 pm

Re: Phone Detection and Flagging for home automation

Post by m19brandon »

I do something similar with ping plugin and a timer that pings all my IP devices and a py script that tracks everything. I like the stereo or TV to be playing when I get home from work, so when my iPhone joins the network after more than 2 hours and between a set time then EG turns stereo in the living room. It works great.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Phone Detection and Flagging for home automation

Post by Pako »

Please pay attention to the new Nmap plugin.
It might suit your needs.

Pako
Post Reply