Autor Thema: How to coordinate multiple phones?  (Gelesen 1467 mal)

PeteDD

  • Newbie
  • *
  • Beiträge: 3
  • Gerät: Samsung A15
  • Version: Android
How to coordinate multiple phones?
« am: 11.08.2024, 19:27:17 »
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

  • Administrator
  • Hero Member
  • *****
  • Beiträge: 764
    • EgiGeoZone
  • Gerät: Xiaomi Redmi Note 5, Samsung Galaxy Note 2, S4, S5, S2, S7
  • Version: MIUI 10.0 Global, Android 4.4, 5, 6, 7, 8, 8.1, 12, 13
Re: How to coordinate multiple phones?
« Antwort #1 am: 12.08.2024, 07:57:25 »
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


Schöne Grüße
Egmont

PeteDD

  • Newbie
  • *
  • Beiträge: 3
  • Gerät: Samsung A15
  • Version: Android
Re: How to coordinate multiple phones?
« Antwort #2 am: 14.08.2024, 20:55:55 »
@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

  • Newbie
  • *
  • Beiträge: 3
  • Gerät: Samsung A15
  • Version: Android
Re: How to coordinate multiple phones?
« Antwort #3 am: 15.08.2024, 02:32:10 »
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:
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;
http response is just Status Code: 200

CheckHomeStatus and PrepareURL function is:
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();

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

  • Administrator
  • Hero Member
  • *****
  • Beiträge: 764
    • EgiGeoZone
  • Gerät: Xiaomi Redmi Note 5, Samsung Galaxy Note 2, S4, S5, S2, S7
  • Version: MIUI 10.0 Global, Android 4.4, 5, 6, 7, 8, 8.1, 12, 13
Re: How to coordinate multiple phones?
« Antwort #4 am: 18.08.2024, 13:57:13 »
Yes, Fhem is for a bigger project.

What you did with Node Red is great.
Schöne Grüße
Egmont