English > English corner

How to coordinate multiple phones?

(1/1)

PeteDD:
I have found EgiGeoZone to work exceptionally well with one phone.  Has anyone come up with a way to coordinate multiple phones with EgiGeoZone.  By this I mean I want to generate an http message when both of two phones are outside the geofence to create an "away" condition and then when either of the two phones returns to inside the geofence, create an "at-home" condition.

I am thinking that perhaps using Code Red as an intermediary might work.  But would love to hear how others have done this. 

My target app to control is BlueIris and I know how to send the right messages to it but not how to coordinate two EgiGeoZone inputs.  (Yes, I know that the BI android app knows how to coordinate multiple phones but that app is too unpredictable about exactly where and when it sees the user enter or leave the geofence (and I'm talking about miles and many, many minutes of difference).

Admin:
Hi Pete,
to realise that, you need a home automation server like Fhem https://fhem.de/. There you can use for example the residents plugin https://fhem.de/commandref.html#RESIDENTS


PeteDD:
@Admin
Herzlichen Dank.   That looks like a great system if I really wanted to manage a whole house full of switches, etc but seems like a big over-kill for what I am trying to accomplish (that is, a lot to learn to get it running, just to do a simple logic tree).

PeteDD:
Here is how I did it with Node Red (which I already had running on a Raspberry Pi server)

http in -> Process Geofence Function    -> http response
                                                          |
                                                           |->CheckHomeStatus and PrepareURL function  -> http request -> debug (optional)


Here's the http in:   Method: GET   URL: /geofence

Here's Process Geofence:

--- Code: ---const phone = msg.req.query.phone;
const fence = msg.req.query.fence;
if (phone && fence) {
    const isEntering = fence.toLowerCase() === 'entering';
    const isExiting = fence.toLowerCase() === 'exiting';
   
    if (isEntering || isExiting) {
        const atHome = isEntering;
        flow.set(phone, atHome);
       
        msg.payload = {
            status: 'success',
            message: `${phone} is ${fence} the geofence`,
            value: atHome
        };
    } else {
        msg.payload = {
            status: 'error',
            message: 'Invalid fence value. Must be "entering" or "exiting".'
        };
    }
} else {
    msg.payload = {
        status: 'error',
        message: 'Missing phone or fence parameter'
    };
}
return msg;

--- Ende Code ---
http response is just Status Code: 200

CheckHomeStatus and PrepareURL function is:

--- Code: ---function checkHomeStatusAndPrepareURL() {
    const jillAtHome = flow.get('Jill') || false;
    const peteAtHome = flow.get('Pete') || false;
    let schedule;
    if (!jillAtHome && !peteAtHome) {
        schedule = 'Away';
    } else {
        schedule = 'Day_Night';
    }
    const baseUrl = 'http://10.123.123.123:81/admin';
    const params = `schedule=${encodeURIComponent(schedule)}&lock=2&user=USERNAME&pw=PASSWORD3`;
    msg.url = `${baseUrl}?${params}`;
   
    return msg;
}
return checkHomeStatusAndPrepareURL();

--- Ende Code ---

and finally, the http request... Method: GET   and ***LEAVE THE URL BLANK*** (that last part may not be obvious)  Payload: ignore.

Then the messages that EgiGeoFence sends would look like these, for example:


http://10.222.222.222:1880/geofence?phone=Pete&fence=entering
http://10.222.222.222:1880/geofence?phone=Pete&fence=exiting
http://10.222.222.222:1880/geofence?phone=Jill&fence=entering
http://10.222.222.222:1880/geofence?phone=Jill&fence=exiting



Admin:
Yes, Fhem is for a bigger project.

What you did with Node Red is great.

Navigation

[0] Themen-Index

Zur normalen Ansicht wechseln