Return data in webhook response?

chaoscreater

Active member
Hmm actually, just thought of another idea that might work. This is based on your ping suggestion.

As per my original post, I'm using Powershell on my PC to trigger the MacroDroid webhook. I can get my PC's IP and pass it as a parameter to the webhook, like this:

$Desktop_PC_IP = (Get-NetIPAddress | Where-Object {$_.AddressState -eq "Preferred" -and $_.ValidLifetime -lt "24:00:00"}).IPAddress

$url = 'https://trigger.macrodroid.com/xxxxxxxxxxxx-0135-41e0-8db3-3c47aba7725f/Phone_IP_Address?Desktop_PC_IP=$Desktop_PC_IP'

$response = Invoke-RestMethod -Uri $url -Method GET -UseBasicParsing

On my phone, I'll receive the PC's IP address and can use it in a shell script as an Action. I can ping from my phone to my PC.

Since I'm not blocking ping on my PC, my phone should get a ICMP packet response from my PC. This *should* allow both of them to build up the ARP table. After all, the PC has to respond to the inbound ping request and needs to know some basic details, such as the MAC address of the device that is pinging from. So doing it this way should actually force the PC to have an updated ARP table. Just as a reminder, the issue that I mentioned before is that the phone's MAC entry will somehow drop off from my PC's ARP table after a short period (not sure why) and this causes the Get-Neighbour Powershell command to fail. However, since we're pinging from phone to PC, it *should* trigger the PC to populate the phone's MAC address in the ARP table.

I can then run the below on the PC to get the IP address of the phone.

# Define the MAC address you want to find the IP address for
$macAddress = "xx-xx-xx-xx-xx-xx"

# Get the ARP table
$arpTable = Get-NetNeighbor | Where-Object {$_.LinkLayerAddress -eq $macAddress}

if ($arpTable) {
# Extract the IP address from the ARP table entry
$ipAddress = $arpTable.IPAddress
Write-Host "IP Address for MAC address $macAddress is: $ipAddress"
} else {
Write-Host "No entry found for MAC address $macAddress"
}
 
Top