Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phone presence instead of geofencing #13

Open
vincentcox opened this issue Nov 21, 2024 · 2 comments
Open

Phone presence instead of geofencing #13

vincentcox opened this issue Nov 21, 2024 · 2 comments

Comments

@vincentcox
Copy link

vincentcox commented Nov 21, 2024

It would be nice if it can set the status to away if certain devices are absent in the network. I don't like geofencing because it drains the battery.

Following code is an example if 2 devices are present or not:


# Function to check for the presence of two MAC addresses in the network
check_mac_addresses() {
    # Arguments: Two MAC addresses to check
    local mac1="$1"
    local mac2="$2"

    # Run arp-scan to detect all MAC addresses in the network
    # Adjust the network range as per your configuration
    local mac_addresses
    mac_addresses=$(arp-scan --localnet | awk '{print $2}')

    # Check if both MAC addresses are in the output
    if echo "$mac_addresses" | grep -iq "$mac1" && echo "$mac_addresses" | grep -iq "$mac2"; then
        return 0  # True: Both MAC addresses found
    else
        return 1  # False: At least one MAC address not found
    fi
}

# Example usage
if check_mac_addresses "aa:bb:cc:dd:ee:ff" "11:22:33:44:55:66"; then
    echo "Both MAC addresses are present."
else
    echo "One or both MAC addresses are missing."
fi 

Is that something that fits the project?

@tbilou
Copy link

tbilou commented Dec 14, 2024

@vincentcox, since the only device I have running 24/7 is my router (running openwrt) I adapted Silviu's amazing script to run there and implemented your phone presence idea.
I used a built-in tool instead of arp-scan but it works really well.

@s1lviu
Copy link
Collaborator

s1lviu commented Dec 16, 2024

Hi guys,
Unfortunately, the last period was a little busy for me.
@vincentcox thanks for the idea and for the 🍕 :) I will try to analyze and find the time to implement that.
@tbilou sounds interesting, maybe you can contribute to a separate branch with your implementation if not to the main with a cross-platform solution
Best,
Silviu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants