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

UDP and Fibaro


Question

Posted

Good afternoon

I am trying to send an ascii string to a UDP device via a Lua Scene without success.

Firstly can someone tell me if this is possible as there seem to be conflicting data.

I have scoured the forums and google without success, below is my latest attempt.

 

 

This is the error I get [DEBUG] 16:08:03: 2021-02-14 16:08:03.316379 [ fatal] Unknown exception: /opt/fibaro/scenes/23.lua:22: attempt to index global 'Net' (a nil value)

 

 

I am new to Lua so please excuse my lack of understanding

 

Thank you in advance

Regards

Andrew


if (
 ( tonumber(fibaro:getValue(141, "value")) > 0 )

)
then
    
socket = Net.FUdpSocket()

local ip = '192.168.0.251'
local port = 3671
local data = string.char(0xaf, 0xbf, 0xcf, 0xdf, 0xef, 0xff)


socket:setReadTimeout(1000)


local bytes, errorCode = socket:write(data, ip, port)
if errorCode == 0 then
  fibaro:log("sent")
else
  fibaro:log("failed")
end


socket = nil

1 answer to this question

Recommended Posts

  • 0
Posted

Hi @fogmajor,

 

Move your code from scene to virtual device and try.

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...