0

To check the Fibaro Presence via iPhone, Smartphone or TV

by crissxcross27. August 2014

A house cannot be smart until it knows when its residents are at home and when they are not, this way they can shut down the heaters and turn off standby-devices to safe electricity.

Of course, with the Fibaro App this is possible via GPS function. Though, nowadays Smartphones do not really belong to battery miracles and the activated GPS certainly does not help to increase the battery performance.

In the following I want to show you a little LUA Script, with which it is possible to check the presence of IP-based devices. Via a so called PING a request is send to the network-device. If the device is available in the Network, via LAN or WIFI, there will be a response. This response can be noted in a variable of Fibaro, to then use it in scenes. I already explained how to create variables on here. (Apply Fibaro HCL daytime-variable)

This way, smartphones can be pinged – after all, they nowadays are our accompanists, so that you can derive that if the smartphone is not connected to Wi-Fi, I am not home either.

You could also ping a Smart TV. If it is turned on, it will response. If it is turned off and only in standby, it will not response. In this case, you could turn off the HiFi Board via a scene, to safe electricity.

Apply a variable

First of all you need a variable that will later on be filled with attendance-condition by the System. You can apply this on the Web surface of the Home Center 2 under the menu item: Controllers > variable controllers > apply a variable.

Apply a Fibaro Variable

Apply a Fibaro Variable

Name them freely, according to your wishes. In this example, I use “SamsungTVWHZ“ as name of the variable, which can adopt two conditions, 0 and 1. If the Samsung TV is turned on and thus accessible, the variable is set on 1. If it is turned off and does not answer, it takes on the value 0.

To ping Samsung TV

To perfrom the script, I created a new virtual module under “modules > add”, which I gave the abstract name “Attendance” . The field for IP addresses and TCP Port can stay empty. In the register-card “expanded”, you can now add a new button and set the point before “LUA Code”.

Send Fibaro LUA Script to PING

Send Fibaro LUA Script to PING

Following has to be used as the script:

Following has to be replaced by your own values and variables in the script now. In the first line you can find the IP address, which has to be pinged. Change it to the IP address of your TV device, resp. to the IP address of the device, whose condition you want to determine. The IP address is followed by the port. In this example, it is the port 55000 for Samsung Smart TV devices.

After that you need to define the variable, which you applied before.

The virtual module now is ready to use. As soon as you push the button of the virtual device, the script will send the ping and write the response in the variable. The Log-text is issued under the virtual module.

Nun ist das virtuelle Modul einsatzbereit. Sobald du den Knopf des virtuellen Gerätes drückst, wird das Script den Ping senden und die Antwort in die Variable schreiben. Unter dem virtuellen Modul wird der Log Text ausgegeben.

Fibaro virtual module checks network status of IP devices

Fibaro virtual module checks network status of IP devices

To check the Fibaro-Presence via iPhone

Since the iOS 6 firmware, the iPhone switches off the Wi-Fi-module while in lock screen. This way, the iPhone does not react to a Ping, even though it is in reach of Wi-Fi. Though, it is possible to check if the iPhone is at home. I already explained the workaround in an example with Homematic before (to check the Homematic presence via smartphone or iPhone). Therefore, the iPhone needs to be awakened by a Push-Notification, after that the Ping can be executed.

For this purpose, you can create a new message in the menu of the Fibaro Home Center, under the menu item: Controllers > Notifications. Title and content of the message can be assigned freely. After one click to save it, this message is now also available as an option in scenes.

Various notifications can be applied

Various notifications can be applied

Furthermore you also need a new variable for the iPhone, as well as a new button in the just created virtual module. The script stays the same. Again, you need to adjust the IP address to the one of your iPhone, use 62078 as Port. Do not forget to adjust the variable in the script.

Fibaro LUA Script pings iPhone

Fibaro LUA Script pings iPhone

Before the triggering of the virtual module, a push-notification can now be deposed in the scene. The previously created message can, as well as the receiver, be chosen.

Fibaro – Scene sends push notification and activates virtual module

Fibaro – Scene sends push notification and activates virtual module

In this case, a time interval is less recommendable as the trigger mechanism, because it is probably going to be getting on your nerves, if a push notification is coming up every minute. This can be released by contact with a door/window. As soon as the front door is opened, the scene is going to start. All that should be done time-delaying, because if you leave your house, you need to be out of reach of your Wi-Fi first. This way, you can delay the sending of the push notification, as well as the performing of PING (pushing of the button of the virtual module) in the scene by entering the time in seconds in the red field.

The virtual module will also fill this variable, depending on if you leave your house or come back. Thus the heating can be controlled depending on your presence. The turning on of the light as soon as you get home is not yet perfect with this examination, due to the fact that push notification and Ping are being send time-delayed as well, whenever you come home. For that it sadly is too sluggish.

 

Surely, one or the other of you all can set up the whole complete LUA. The challenge is hereby approved.

About The Author
crissxcross
Hi, I'm crissxcross, qualified IT system electronics. Professionally, I work as a product marketing manager in the Smart Home. And private I am self a Smart Homie :-) If I do not sit in front of the monitor like I photograph and am a big fan of Apple. I am the founder of the SiiO.de blog.

Leave a Response