Library of Functions


Description


Returns the identification number of the virtual device from which it is called.
 
Scope
This function is only defined in the scope of a virtual device.  It will not work in a scene.

Usage and Arguments


fibaro:getSelfId()

  • This function takes no arguments.

Returned Values


A number containing the identification number of the virtual device.

Examples


-- find the number of this virtual device
local thisdevice = fibaro:getSelfId()
-- use the virtual device number to find the IP address and
-- port specified on the device's configuration page
local ip = fibaro:getValue(thisdevice, 'IPAddress')
local port = fibaro:getValue(thisdevice, 'TCPPort')
 
-- open up a connection to that port and write a message there.
tcpSocket = Net.FTcpSocket(ip, port)
bytes, errorCode = tcpSocket:write("this is written to the TCP port.")