This is probably already a requested but I can not find anything about it.
Is there a way to find out if I have logged on via my own lan (WLAN), or that I have logged via the WAN (remotely via telephone using ddns).
Greetings Hans
Wan or lan
This is probably already a requested but I can not find anything about it.
Is there a way to find out if I have logged on via my own lan (WLAN), or that I have logged via the WAN (remotely via telephone using ddns).
Greetings Hans
@hansjeu Yes and no. I cant think of any variable or something like that to get this info directly from pimatic.
What you can do is use the ping plugin to ping the device(s) which you use to log in to pimatic and then use the rules for your special actions like
if [mobilephone] is present and ... then ...
If you explain why you want to get the info with which device you are logged in maybe someone has another better idea.
I am creating a pimacle-system for friends. They live in rural areas and therefore have a not too fast internet.
That’s why I want to use as little bandwidth as possible.
There are some cameras connected to the pimatic-system. Which I show via iframe. To approach pimatic via WAN I use a ddns-adress . This naturally consumes quite a bit of the bandwidth.
What I want is: if one approaches pimatic via Wifi iframe uses the IP address and if one approaches pimatic via the internet iframe uses the DDNS-adress.
This I want to realize using rules . via wifi ‘load camera1 with" http://192… … "’ or if via internet ‘load camera1 with" http://ddns-adress"’
You solution works for one mobile phone, I got 3 to consider.
I was thinking more of pinging for the mac-adress of the router but this is imposible i believe.
So i hope there is another trick.
greetings Hans
I can’t think of a nice solution yet, but you could send one ping (-c 1) via a button to see if it is available.
like:
ping -c 1 192.168.0.xxx > /dev/null && echo "1" || echo "0"
if 192.168.0.xxx is available you wil get a 1 (on the lan) and if not you’ll get a 0 (on the wan).
When put into a curl command you could write a bash script and start it via the button like:
#!/bin/bash
ping -c 1 192.168.0.xxx > /dev/null && export lan=1 || export lan=0
curl --silent --insecure -X PATCH --header "Content-Type:application/json" --data '{"type": "value", "valueOrExpression": '"${lan}"'}' --user "${PIM_USER}:${PIM_PASS}" http://192.168.xxx.yyy/api/variables/lan-status
Once your “lan-status” variable is set you could create a rule:
if lan-status=1 then load camera1 with" http://192...
Or even cleaner like I described in this topic if you know the mac address.
#!/bin/bash
"sudo arp-scan --localnet | grep -iq AA:BB:CC:DD:EE:FF && export lan=1 || export lan=0"
curl --silent --insecure -X PATCH --header "Content-Type:application/json" --data '{"type": "value", "valueOrExpression": '"${lan}"'}' --user "${PIM_USER}:${PIM_PASS}" http://192.168.xxx.yyy/api/variables/lan-status
I am going to test this solution.
But i have a question.
Pimatic (the raspberry) is doing the arp-scan.
i know the ip-number and ther mac-address of the router.
will the answer not be always 1?
No. When using arp-scan --localnet
it will stay within the network segment as defined by the network mask. In a 192.xxx network that will be limited to the 255-2 addresses in that network.
ButI did not understand you correctly. If you want to ping the router it will have a fixed ip address and you can simply use the ping command from the first example.
ed to ping from pimatic to the phone. That’s wahy I mentioned the arp-scan
The rules are systemwide… this is probably not the best approach.
Maybe something like a meta-site would be possible? Do you have anything other on the pi running that can serve http?
I myself would link the iframe to a site that determines the client ip and based on that information redirect to the ipcam-site.
@Harry-van-der-Wolf said:
No. When using
arp-scan --localnet
it will stay within the network segment as defined by the network mask. In a 192.xxx network that will be limited to the 255-2 addresses in that network.ButI did not understand you correctly. If you want to ping the router it will have a fixed ip address and you can simply use the ping command from the first example.
And I understood you wrong again. If the pimatic and the router are in the same network(segment), there is no need to ping each other. You need to ping from pimatic to the phone. That’s why I mentioned the button in the gui (on your phone) that will “arp-scan” ping your phones mac address.