Yeah, how would you know… You seem to have used the card for standard flows. There’s a ‘twin’ one, for advanced flows, which has a tag symbol in it, next to the card’s name. Which means, it provides for local tags in flows.
So there’s an ‘twin’ card purely for adv. flows, because they didn’t want to break existing standard flows I assume.
The script (note: it will fail as soon as the webpage is changed somehow. Then the filter will have to be adjusted again): change ‘2, 15’ into ‘2, 17’ for IP addresses like xxx.xxx.xxx.xxx (mine is xx.xxx.xxx.xx atm)
var response = args[0];
var myIP = '' + response.split("-")[1].slice(2, 15);
return myIP;
Just for fun:
When you use Better logic variable cards, you can display the IP on an Advanced virtual device like this (without flows):
but the script returns an error. I do see the ‘response’ (called ‘antwoord’ in my case) with the html code and my IP address. So the URL is correct (it is different from your example)
4 decades ago I had to write stuff in Pascal and it wouldn’t compile. Checked the code over and over again. Only thing I missed was the . at the end. It had ‘end’ but it should have been 'end."
Update:
A little improvement.
While the filter slice(2, 15) is not flexible, I found a way to ensure the IP only is returned, no matter the number of digits:
var response = args[0];
// A) while the - symbol is (while the returned data doesn't change)
// the first one, and close to the actual IP address,
// we select the string following the - symbol.
// B) when the IP has less than 12 digits, remove trailing HTML code "</"
var myIP = '' + response.split("-")[1].slice(2).split("<")[0];
console.log('args: ', args[0]);
return myIP;
So recognizable I don’t know how many days I’ve spend in total to find out about a missing }.) or the like. My urge to get it working helps, but oh I have given up on many scripts as well
Indeed the HomeyScript app is needed, due to the HomeyScript flowcard + code to filter out the IP.
Also the 1. card is not needed. You can trigger the flow just how you’d like it. The time trigger seems a logical choice to me
The logics GET request card = HTTP GET request. It’s the right card.
To check if your IP is determined correctly:
When you add the green [Result] tag to a timeline card, it returns the complete web page in HTML, where your IP should be somewhere between <title> and </title>
(it should be present somewhere in the first 20 lines or so)