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

QuickApp setVariable ?


Question

Posted (edited)
Have the next script working, 

How can is save the print data to Variable ? 
-self:getVariable():
-hub.setGlobalVariable
 
-- Import the necessary modules
local http = net.HTTPClient()
 
-- Function to perform network discovery
local function performNetworkDiscovery()
  local api = "/api/networkDiscovery/arp"
  local url = "http://127.0.0.1:11111" .. api
  local requestBody = "{\"body\": 0}"
 
  http:request(url, {
    options = {
      method = "POST",
      headers = {
        ["Content-Type"] = "application/json",
      },
      data = requestBody
    },
    success = function(response)
      local responseData = json.decode(response.data)
      
      -- Process each device
      for _, device in ipairs(responseData) do
        local ip = device.ip
        local mac = device.mac
        local vendor = device.vendor
     
        -- Do something with the IP, MAC, and vendor information
        -- For example, print them to the console
        print("IP: " .. ip)
        print("MAC: " .. mac)
        print("Vendor: " .. vendor)
        print("----------------------------------")
      end
    end,
    error = function(error)
      print("Network discovery request failed with error: " .. error)
    end
  })
end
 
-- Main entry point of the script
function main()
  -- Perform network discovery
  performNetworkDiscovery()
end
 
-- Run the script
main()
Edited by morsink

6 answers to this question

Recommended Posts

  • 0
Posted
fibarp.setGlobalVariable('nameGlobal',valueOutcome)
  • 0
Posted (edited)
self:getVariable("varName", "value")
hub.setGlobalVariable("varName", "value")
 
By the way as you are typing this a popup menu with related commands appears - just choose the command there and it will enter the command with the correct syntax

Please login or register to see this spoiler.

Edited by cag014
  • Like 1
  • 0
Posted
14 hours ago, SmartHomeEddy said:

(@morsink is on a HC2 but asks for a QuickApp?)

Probable forgot to update the profile😀

  • Like 1
  • 0
  • Inquirer
  • Posted
    On 7/3/2023 at 8:12 AM, SmartHomeEddy said:

    (@morsink is on a HC2 but asks for a QuickApp?)

    Correct have a HC2 and HC3. Start to use the HC3 as new basis station. And will roll out the HC2 when the basics are correct in HC3

    Thanks all for the support. Just start to learn a little bit of code wrighting.   I get working  the next QuickApp. But 

    Please login or register to see this link.

     i will try this to.

    Please login or register to see this attachment.

    • 0
    Posted
    3 hours ago, morsink said:

    Correct have a HC2 and HC3. Start to use the HC3 as new basis station. And will roll out the HC2 when the basics are correct in HC3

    Thanks all for the support. Just start to learn a little bit of code wrighting.   I get working  the next QuickApp. But 

    Please login or register to see this link.

     i will try this to.

    Please login or register to see this attachment.

     

    Take a look on

    Please login or register to see this link.

    , no LUA knowledge required and during the transition you can control all HC2 devices/scenes from HC3 also. Like a slave... that's what I am doing now.

    By the way I'm considering continuing to use HC2 (controlled by AOQ on HC3) as a repeater.

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