Welcome to Smart Home Forum by FIBARO
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!
Smart Home Forum by FIBARO Team
Search the Community
Showing results for tags 'repeat/until'.
Found 1 result
Repeat / until loop not working, need help
Guest posted a question in Scenes and InterfaceWhen I plugin the plug in the power socket from my denon receiver, internally the unit is initializing different settings, like network, etc... when i plugin the unit, the receiver is set to standby, ok. I want to make a lua code whereby it makes a loop with repeat / until...until i get a code back from the unit if it's in standby mode, or on mode, from there it should continue, see below. but it's skips the repeat/until... When the unit is plugged in, no code is been returned... So i was thinking: instead of this: "if not(trim(result) == "PWON" or "PWSTANDBY") then" use "if (trim(result) == """) then" Are there other ways to detect an empty string ? With other words: When no code is been returned, stay in this loop until PWON or PWSTANDBY is been returned. fibaro:log("Connecting..."); tcpSocket = Net.FTcpSocket("10.0.1.155", 23); tcpSocket:setReadTimeout(1000); function trim(s) -- trim leading and trailing whitespaces -- return (s:gsub("^%s*(.-)%s*$", "%1")) end -- Denon is Initializing it's Network -- repeat fibaro:sleep(2000); tcpSocket:write(string.char(0x50, 0x57, 0x3f, 0x0d)); -- requesting for the PWON or PWSTANDBY status ? fibaro:sleep(500); result, err = tcpSocket:read(); tcpSocket:disconnect(); fibaro:debug("Denon Receiver..."..result); if (err == 0) then if not(trim(result) == "PWON" or "PWSTANDBY") then fibaro:sleep(1000) fibaro:debug("...is Initializing"); end end until (trim(result) == "PWON" or "PWSTANDBY") fibaro:debug("Ready to Receive Data: "..result); -- Rest of the code -- Please some help would be appreciated. Thankss a lot