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

Yamaha volume in LUA/Slider


JohanK
 Share

Question

HI,

 

Been wrestling with this for some time now so time to ask for help

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

 

I'm trying to control my Yamaha Amp, no problem switching input sorces, scenes, on/off etc but when it comes to setting (and later reading) the volume I simply can't get it to work.

 

I'm using a virtual device with a slider. In the LUA-code for the slider I've wrote the script below. When I change the slider the scripts works one in five times, the rest nothing happens.

 

As far as I can tell it reads the slider value OK, the command sent is correct etc. To me it feels like I need to send some end command to the Yamaha but can't figure out how to do it.

 

Any help or feedback is appreciated.

 

Here is the script:

 

local IPYamaha = "192.168.1.67"

local pYamaha

local cmdYamaha

local YamahaValue

 

 

YamahaValue = 8 * tonumber(_sliderValue_)

YamahaValue = YamahaValue  - 800

 

fibaro:log(tostring(YamahaValue))

 

cmdYamaha = '<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Lvl><Val>' .. tostring(YamahaValue) .. '</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>'

 

pYamaha = Net.FHttp(IPYamaha,80)

 

response ,status, errorCode = pYamaha:POST('/YamahaRemoteControl/ctrl', cmdYamaha)

 

fibaro:sleep(1000)   

   if errorCode == 0

   then

     fibaro:log('status'..status)

   else

     fibaro:log("error")

   end 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi there, I'm just starting out with LUA but thought I would just comment based on my knowledge of other scripting languages. BTW Which Yamaha Amp are you using?

 

If you were to add fibaro:log('CMD'..cmdYamaha) to the script does cmdYamaha contain exactly the contents you were expecting (knowing how picky XML an be!)

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi,

     

     

    Thanks, I'm new to LUA myself, installed Fibaro yesterday after giving up on Zipato.

     

    I'm using a Yamaha RX-V575 but I believe that Yamahas interface applies to most of their network models.  The cmd is correct, I've debugged it, replaced it with static values etc...the thing is that it only works every now and then. For instance I replaced it with a static value setting the volume to the same value...still only works one out of five.

     

    So I'm thinking that I should close the connection somehow

    Link to comment
    Share on other sites

    • 0

    Any news on this Johan?

     

    I tried your code on my Yamaha A1020 and got the same result as you; it works about one time out of five.

    I am currently using defined buttons with "@MAIN:VOL=Down 5 dB0x0D0x0A" to regulate the volume, a slider would be so much nicer.

    Link to comment
    Share on other sites

    • 0

    Its a bit more complicated than that. Whether you use RS232, or IP control, if you want to use the slider effectively you need to know all the codes for each volume unit e.g if your volume goes 1-100 then you will probably have 100 individual codes. You need to know those and put them in a table in your script then you reference that table to get the correct volume.

     

    The definitive code on doing this you need to look for Jean-Christophe's (Krikroff) Pioneer VSX virtual device. I don't personally have a Pioneer and my personal config is very different but that code works 100%. Download the vfib, install it and look at/understand the code and you will be able to work it out.

     

    All the best

     

    Dave:)

    Link to comment
    Share on other sites

    • 0

    Hello!

    Have reciver Yamaha 3030. I control via post request in virtual device

    Please login or register to see this code.

    Found on Fibaro forum France.

    With virtual device all work fine, but in scene i have error

     

    [ERROR] 12:22:07: line 46: attempt to index global 'Net' (a nil value)

     
     
    Its error in Net.FHttp("192.168.0.10",80) line
    I not found in Fibaro Api how works net.Fhttp. Whats is right code for control Yamaha via Lua Scene?
    Thanks all for Help!
    Link to comment
    Share on other sites

    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.

     Share

    ×
    ×
    • Create New...