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


Search the Community

Showing results for tags 'net.fhttp'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • FIBARO Community
    • FIBARO Portal and Forum policy
    • FIBARO
    • Say hello!
    • Off-topics
  • FIBARO Update
    • FIBARO System Update
    • FIBARO Mobile Update
  • FIBARO Community Support
    • Scenes and Interface
    • FIBARO Products
    • FIBARO Mobile
    • FIBARO HomeKit
    • FIBARO Assistant Integrations
    • Other Devices / Third-party devices
    • Tutorials and Guides
    • Home Automation
    • Suggestions
  • FIBARO Społeczność
    • FIBARO
    • Przywitaj się!
    • Off-topic
  • FIBARO Aktualizacja
    • FIBARO System Aktualizacja
    • FIBARO Mobile Aktualizacja
  • FIBARO Wsparcie Społeczności
    • Sceny i Interfejs
    • FIBARO Urządzenia
    • FIBARO Mobilnie
    • FIBARO HomeKit
    • Integracja z Amazon Alexa i Google Home
    • Urządzenia Firm Trzecich
    • Poradniki
    • Automatyka Domowa
    • Sugestie

Categories

  • Scenes
  • Virtual Devices
  • Quick Apps
  • Icons

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Google+


Skype


Website URL


WhatsApp


Country


Gateway/s


Interests

Found 5 results

  1. I find the documentation on network programming in LUA not very elaborate so I put a question here. From my HC2 I want to send a HEX string to a (wifi connected) device in my network and I want to receive a HEX string from the same device. so I start with opening a session to the device with IP and port as shown in the code and next I try to send a 0x07 to the device local WHR = Net.FHttp("172.17.1.221", 8899); res, status, errorCode = WHR:PUT('0x07'); but this results in an error message. Can anybody give me some hints on network programming on the HC2 in VD's of direct me to useful documentation. thanks
  2. Please integrate this into the scene. "Net.FHttp". Thank you.
  3. All I tend to be a little lazy when using API calls from LUA in VD and Scenes. I also recently spotted "api.get" in some posts but have seen any information on that in ip/docs or the various fibaro websites. For those that are considerably more professional in the LUA and Fibaro development than me, could you comment on your best practice e.g. error handling, debugging, parsing JSON etc. I will try to curate and consolidate in the first entry of this topic for everyone's benefit. Tutorial for API in VD and scenes by the prolific AutoFrank Also, I should of thought Wikipedia for HTTP error codes. Wikipedia HTTP Error Codes So perhaps comment away on the extract from my announcer VD that uses jishi SONOS API bridge below and lets make that a good example of best practice for those learning the ropes (me included)? thanks in advance local device = fibaro:getSelfId(); local ipaddress = fibaro:getValue(device, "IPAddress"); local port = fibaro:getValue(device, "TCPPort"); local cmd = "/sayall/" local vol = "/50" Debug(true,"white","Ready to send to "..ipaddress..":"..port) Debug(true,"white", "Raw:"..cmd.."Hello"..vol); -- use an encodeTSS function here in cmd = cmd .. encodeTTS(announce).. vol; -- Issue API call sonos = Net.FHttp(ipaddress, port); response, status, errorcode = sonos:GET(cmd); -- simple error checking if tonumber(status)==200 then response=json.decode(response) else Debug(true,"red","Error calling Sono API:"..errorcode.." status: "..status); end
  4. hi, I made this VD a while ago. It makes a weekly report of the HC2 and works pretty good but I want to move in to a scene. I used Net.FHttp and this doesnt work in scenes. Can somebody help? Regards Martijn --- UPDATE MEMORY VARIABLES fibaro:call(fibaro:getSelfId(), "pressButton", "8") --- MAKE CONNECTION connection = Net.FHttp("127.0.0.1", 11111); --- FUNCTION REQUEST DEVICES getData = function() --- MAKE CONNECTION response ,status, errorCode = connection:GET( "/api/devices/" ); --- STATUS NOTIFICATIONS fibaro:debug("status = " .. status); fibaro:debug("errorCode = " .. errorCode); --- IF SUCCES if (tonumber(status) == 200) then --- DECODE TO LUA TABLE deviceTable = json.decode(response); end return deviceTable; end --- FUNCTION REQUEST CONSUMPTION getConsumption = function(url) --- MAKE CONNECTION response ,status, errorCode = connection:GET( url ); --- IF SUCCES if (tonumber(status) == 200) then consumptionTable = json.decode(response); end return consumptionTable; end --- CONSTRUCT SUBSTRACTION DAYS START DATE OF LAST WEEK if(os.date("%a") == "Mon") then substract = 7 elseif(os.date("%a") == "Tue") then substract = 8 elseif(os.date("%a") == "Wed") then substract = 9 elseif(os.date("%a") == "Thu") then substract = 10 elseif(os.date("%a") == "Fri") then substract = 11 elseif(os.date("%a") == "Sat") then substract = 12 elseif(os.date("%a") == "Sun") then substract = 13 end --- SET VARIABLES UserId = 2; lowBat = 70; SelfId = fibaro:getSelfId() dev = getData(); lowBattDevices = ""; deadDevices = ""; totalConsumption= 0 ; heavyConsumption= ""; now = os.date("*t") week_start = os.time({year=now.year,month=now.month,day=now.day-substract,hour=0,min=0,sec=0}) --, week_end = week_start + 604799 -- plus a week --- LOOP THROUGH DEVICES for i = 1, #dev do --- SET VARS batLevel = tonumber(dev.properties.batteryLevel); deadValue = dev.properties.dead; deviceName = tostring(dev.name); prestr = "[" .. dev.id .. "] ➜ " .. deviceName; --- DEAD DEVICES if(dev.visible == true and deadValue == "true") then --- TRY TO WAKE fibaro:wakeUpDeadDevice(dev.id) fibaro:sleep(2*1000); --- CHECK IF STILL DEAD if(fibaro:getValue(dev.id, 'dead') ~= "1") then deadDevices = deadDevices .. prestr .. " ✔ Woke up \n"; else deadDevices = deadDevices .. prestr .. " ❌ Did not wake up \n"; end end --- LOW BATT / IF FIELD EXISTS if (dev.visible == true and dev.properties.batteryLevel ~= nil and (batLevel < 100 or batLevel == 255)) then --- ONLY LOW BAT OF ALLREADYDEAD if(deadValue == "true" or batLevel <= lowBat or (deadValue ~= "true" and batLevel == 255)) then -- lowBattDevices = lowBattDevices .. prestr .. " - " .. string.format('<%s style="color:%s;">%s</%s>', "span", "red", dev.properties.batteryLevel .. " %", "span") .. "<br>\n" lowBattDevices = lowBattDevices .. prestr .. " - " .. dev.properties.batteryLevel .. "% ❌ \n" else lowBattDevices = lowBattDevices .. prestr .. " - " .. dev.properties.batteryLevel .. "% ✔ \n" end end --- CONSUMPTION if (dev.visible == true) then --- SET VARS url = "/api/energy/" .. week_start .."/" .. week_end .. "/compare/devices/power/" .. dev.id Consumption = getConsumption(url); --- ONLY IF THERE IS A KWH FIELD if(Consumption[1].kWh ~= nil) then --- SET VARS kwh = tonumber(Consumption[1].kWh) --- HEAVY USERS LOOP if kwh > 1 then heavyConsumption = heavyConsumption .. prestr .. " ⚡ " .. Consumption[1].kWh .. " kWh \r"; end --- TOTAL CONSUMPTION SUM totalConsumption = tonumber(totalConsumption) + kwh end end end --- CONSTRUCT MAIL HOME REPORT emailContent = "Weekly Home Report \n"; emailContent = emailContent .. "Date: " .. os.date("%d %b %Y - %H:%M") .. "\n \n"; emailContent = emailContent .. "⎋ Low Battery\r"; emailContent = emailContent .. lowBattDevices .. "\r \r"; emailContent = emailContent .. "⎋ Dead Nodes\n"; emailContent = emailContent .. deadDevices .. "\n \n"; --- SEND MAIL fibaro:call(UserId,"sendEmail", "Weekly Home Report " .. os.date("%d %b %Y - %H:%M"),emailContent); --- CONSTRUCT MAIL CONSUMPTION REPORT emailContentConsumption = "Weekly Consumption Report \n"; emailContentConsumption = emailContentConsumption .. "Date: " .. os.date("%d %b %Y - %H:%M") .. "\n \n"; emailContentConsumption = emailContentConsumption .. "⌘ Consumption\n"; emailContentConsumption = emailContentConsumption .. "From: " .. os.date("%d %b %Y",week_start) .. " till " .. os.date("%d %b %Y",week_end) .. "\n \n"; emailContentConsumption = emailContentConsumption .. "Heavy consumption \n"; emailContentConsumption = emailContentConsumption .. heavyConsumption .. "\n\n"; emailContentConsumption = emailContentConsumption .. "Consumption total\n"; emailContentConsumption = emailContentConsumption .. totalConsumption .. " kWh \n\n"; --- SEND MAIL fibaro:call(UserId,"sendEmail", "Weekly Consumption Report " .. os.date("%d %b %Y - %H:%M"),emailContentConsumption); --- CONSTRUCT MAIL CONSUMPTION REPORT emailContentMemory = "Weekly Memory Report \n"; emailContentMemory = emailContentMemory .. "Date: " .. os.date("%d %b %Y - %H:%M") .. "\n \n"; emailContentMemory = emailContentMemory .. "⌽ Memory\n"; emailContentMemory = emailContentMemory .. "➜ Free memory: " ..fibaro:getValue(SelfId, "ui.labFreeRam.value") .. "\n"; emailContentMemory = emailContentMemory .. "➜ Maximum free: " ..fibaro:getValue(SelfId, "ui.labMax.value") .. "\n"; emailContentMemory = emailContentMemory .. "➜ Minimum free: " ..fibaro:getValue(SelfId, "ui.labMini.value") .. "\n"; emailContentMemory = emailContentMemory .. "➜ Memory Cache: " ..fibaro:getValue(SelfId, "ui.labCache.value") .. "\n"; emailContentMemory = emailContentMemory .. "➜ Memory Buffers: " ..fibaro:getValue(SelfId, "ui.labBuffers.value") .. "\n"; emailContentMemory = emailContentMemory .. "➜ Memory Used: " ..fibaro:getValue(SelfId, "ui.labUsed.value") .. "\n"; emailContentMemory = emailContentMemory .. "➜ Storage: " ..fibaro:getValue(SelfId, "ui.labStorage.value") .. "\n"; --- SEND MAIL fibaro:call(UserId,"sendEmail", "Weekly Memory Report " .. os.date("%d %b %Y - %H:%M"),emailContentMemory);
  5. I need solution for: HttpRequest = Net.FHttp(lvn_IP, lvn_Port); HttpResponse,HttpStatus,HttpErrorCode = HttpRequest:GET(lvs_SiteAddress); How I Can use timeout for Net.FHttp ? Where do I get full net. Lua reference ?
×
×
  • Create New...