Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Ping iPhone instead of GPS localization


SDeath

Question

Instead of using the GPS localization which consumes enormous amounts of power from the iPhone, I want to let the HC2 ping every minute if it can find the iPhone on my local network.

And based on that set a value if somebody is home or not.

Since 3.486 os.execute doesn't work.

Anybody have an idea how to use that function?

This is what I want to do:

Please login or register to see this code.

Edit:forgot the while true do.

Link to comment
Share on other sites

  • Answers 102
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Posted Images

Recommended Posts

  • 0
To me it seem that it would be a better plan of action to see if the MAC-adress of the device you wish to keep track of is in the ARP-table of the local network.

THat way nothing needs to be running on the device, apart from the network itself.

Yes, there would be a lag between the unit being removed from the net, and the ARP-record being cleansed if one sticks to the standard ARP timeouts.

Edit: Or being more evil... for those of us with a "intelligent" wifi-system (I personally use the Ubiquiti UniFi at home) I can use the API to query wether or not a certain MAC is associated with my Wireless Network. Thats even better.. and no ARP-lag

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

Yes,the MAC approach is better than this ping.. but can you describe how to do it?What is the code ?

Link to comment
Share on other sites

  • 0
Yes,the MAC approach is better than this ping.. but can you describe how to do it?What is the code ?

I haven't done it yet. I just started thinking about it.

But for me it is very easy i just realized. As I said, I am using Ubiquiti UniFi at home. And the API lets me do this:

I just call

Please login or register to see this link.

That returns a JSON object which has details of all connected hosts, including how long they have been idle. How much data sent etc etc. See enclosed screenshot.

Now, I realize that this is a feature that is not present in most AP's (Despite the fact that an UniFi is cheaper then most normal AP

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> )

So, for a normal Environment, i would probably design a script that dumps the local ARP-table where it can be accessed via HTTP by the HC2. Yes, it requires a "support machine", but i suppose most people have a NAS/RPi/or SOMETHING around that could do that?

Please login or register to see this attachment.

Link to comment
Share on other sites

  • 0

just installed UniFi on the NAS i like this idea... need instant pinging being 5 minutes later after arp delay is pointless to me! battery life saving on gps + this could be the ultimate combination!

Link to comment
Share on other sites

  • 0

I tried successfully a solution based on Android devices (Galaxy Note2).

The TCP port could be easily opened with "WIFI ADB" app or similar. Selecting from this app "auto open on know SSID" the port (5555) will be open only when you hook the desired network (your SSID).

Obviously you must set before a static IP on your router.

Link to comment
Share on other sites

  • 0
I tried successfully a solution based on Android devices (Galaxy Note2).

The TCP port could be easily opened with "WIFI ADB" app or similar. Selecting from this app "auto open on know SSID" the port (5555) will be open only when you hook the desired network (your SSID).

Obviously you must set before a static IP on your router.

Please tell me the exact code that you had used for this to work..

In this thread there are many different examples of code..so which one worked?

Thanks

Link to comment
Share on other sites

  • 0

You need to root your phone! To much hassle for normal users! Good idea though

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" />

Link to comment
Share on other sites

  • 0

you just need to install the app from google play and ensure the port is open

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

Link to comment
Share on other sites

  • 0
you just need to install the app from google play and ensure the port is open

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

That I already did... but I don't know how to make the virtual device or scene in HC2

What is the exact LUA code to put there, because in this thread there are some different variants of code for this purpose

Which one surely works for my android phone to be found ?

Link to comment
Share on other sites

  • 0

Holy crap. I upgraded my iPhone to iOS7 and now my iphone ping no longer works! Well that is: it works, but the iPhone keeps putting Wifi asleep when it's not being used, and that make my ping to fail (and turn off my lights - grrrrr!)

Anyone els experiencing this and any clue about a solution?

Thanks,

Ronald

Link to comment
Share on other sites

  • 0
Holy crap. I upgraded my iPhone to iOS7 and now my iphone ping no longer works! Well that is: it works, but the iPhone keeps putting Wifi asleep when it's not being used, and that make my ping to fail (and turn off my lights - grrrrr!)

The same issue with iOS7

Please login or register to see this image.

/emoticons/default_icon_cry.gif" alt=":cry:" />

[ Dodano: 2013-10-07, 23:32 ]

Have added a new nice virual device "Who at home", see the picture with the LUA code below:

Please login or register to see this code.

First you need of course create 3 variables: u1home, u1home, u3home and control them with the code attached in the previous posts.

Please login or register to see this attachment.

Link to comment
Share on other sites

  • 0
Holy crap. I upgraded my iPhone to iOS7 and now my iphone ping no longer works! Well that is: it works, but the iPhone keeps putting Wifi asleep when it's not being used, and that make my ping to fail (and turn off my lights - grrrrr!)

The same issue with iOS7

Please login or register to see this image.

/emoticons/default_icon_cry.gif" alt=":cry:" />

[ Dodano: 2013-10-07, 23:32 ]

Have added a new nice virual device "Who at home", see the picture with the LUA code below:

Please login or register to see this code.

First you need of course create 3 variables: u1home, u1home, u3home and control them with the code attached in the previous posts.

I don't understand how you're doing this. Where do I place the LUA code? In each button or in the main loop only?

Also, is the Virtual Device's ID a number you assign yourself? I cannot see an iD for my VD anywhere in the GUI currently...

Could you please elaborate a little more?

Thanks!

Ronald

Link to comment
Share on other sites

  • 0
I don't understand how you're doing this. Where do I place the LUA code? In each button or in the main loop only?

In the main loop, buttons are defined as titles

Also, is the Virtual Device's ID a number you assign yourself? I cannot see an iD for my VD anywhere in the GUI currently...

To get the ID of VD you have to find it with API request:

Please login or register to see this link.

and search for the virtual device with the defined name. You will find there the ID.

Link to comment
Share on other sites

  • 0

easer to enter of that virtual device and look to url, last numbers are a id of virtual device

Link to comment
Share on other sites

  • 0
easer to enter of that virtual device and look to url, last numbers are a id of virtual device

Any method to get VirtualDeviceId in main loop or another place for lua code in virtual device?

Something like this: _Id_, similar to _sliderValue_?

Will be easer to share the code of virtual device.

Link to comment
Share on other sites

  • 0

rafal.m, yes, there will be method who return id of virtual device (maybe next beta)

like

Please login or register to see this code.

Link to comment
Share on other sites

  • 0
rafal.m, yes, there will be method who return id of virtual device (maybe next beta)

like

Please login or register to see this code.

Great! If its possiible, then I want also extra value in proporties: "lastButtonId", so we can detect which button was selected last time, and what is the modification timestamp.

[ Dodano: 2013-10-08, 12:18 ]

Right now I have to detect that by currentIcon.

Link to comment
Share on other sites

  • 0

[ Dodano: 2013-10-07, 23:32 ]

Have added a new nice virual device "Who at home", see the picture with the LUA code below:

Please login or register to see this code.

First you need of course create 3 variables: u1home, u1home, u3home and control them with the code attached in the previous posts.

Ok, I get this one now. However, this is only showing a status. I want to add three buttons so that I can tell my HC2 that I am at home.

For this I added three buttons plus the three global variables. Then in the LUA code for button 1, I simple add the following line:

fibaro:setGlobal("u1home"), "1")

When I try to debug that, it gives the follow error when pressing the button:

[ERROR] 22:14:44: line setGlobal("u1home"), "1");..."]:1

Any idea's what I am doing wrong?

Thanks,

Ronald

Link to comment
Share on other sites

  • 0
fibaro:setGlobal("u1home"), "1")

to many parenthesis

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

should be:

fibaro:setGlobal("u1home", "1")

[ Dodano: 2013-10-08, 22:33 ]

easer to enter of that virtual device and look to url, last numbers are a id of virtual device

thanks Andrew, good suggestion

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...