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

Why does this line in my VD not work?


Question

Posted

This line here...

Please login or register to see this code.

gives the error "line getGlobal ("Nursery_S..."]:10""

 

Yet if I debug the values for those two lines I get correct figures

fibaro:debug(volume) = 15
fibaro:debug(jsonTable.volume) = 30

 

It's just a button to reduce the volume on my Sonos from the current volume (jsonTable.volume) until it reaches a preset volume (volume).

It's a simple "greater than" comparison but I just get this error all the time.

17 answers to this question

Recommended Posts

  • 0
Posted

The topic has been moved from "

Please login or register to see this link.

" to "

Please login or register to see this link.

".

 

Temat został przeniesiony z "

Please login or register to see this link.

" do "

Please login or register to see this link.

".

  • 0
Posted

Hi @Desmo,

 

That error line that you copy/pasted, is it complete because it seem like is missing part. Anyway it doesn't seems to be related to that line of code with volume check. Sometimes debugger gives wrong code line for shown error so check the rest of the code or at least try to copy/paste complete error line and even at least part of code that it refers to.

  • 0
  • Inquirer
  • Posted (edited)

    Yep, that's the complete line of code. Like you say, it doesn't really make any sense so I'll check the rest of the code.

    This is the entire code below. It controls my Sonos speaker and slowly fades the volume to the set amount, pauses playback and then returns volume to a preset state.

    It seems to be the "Fade Volume" section that isn't working as the volume keeps going down to zero rather than stopping at the required volume

     

    IP Address and Port have only been removed for security, they're all fine in the actual script.

     

    @AutoFrank...I know you're very familiar with the Sonos setup....any ideas what might be wrong here? I'm sure all the Sonos stuff is working fine as the correct volume is being reported in the debug lines.

     

    Please login or register to see this code.

     

    Edited by Desmo
    • 0
    Posted

    Just try first with changing first line of code to:

    Please login or register to see this code.

    because function fibaro:getGlobal is always returning string value (even it contains number) while table can contain number value so it is possible that you are comparing string with numeric value.

    • 0
    Posted
    6 minutes ago, Desmo said:

    Yep, that's the complete line of code. Like you say, it doesn't really make any sense so I'll check the rest of the code.

    This is the entire code below. It controls my Sonos speaker and slowly fades the volume to the set amount, pauses playback and then returns volume to a preset state.

    It seems to be the "Fade Volume" section that isn't working as the volume keeps going down to zero rather than stopping at the required volume

     

    IP Address and Port have only been removed for security, they're all fine in the actual script.

     

    @AutoFrank...I know you're very familiar with the Sonos setup....any ideas what might be wrong here? I'm sure all the Sonos stuff is working fine as the correct volume is being reported in the debug lines.

     

    Please login or register to see this code.

     

     

     

    Hi @Desmo

     

    The code has a slight error, you're not updating the reference volume (current volume of player) to check against and as a result jsonTable.volume is always greater than volume and it iterates down to zero and actually continues to loop

    you'll need to read back the new (reduced) volume and compare that against your target volume

    I can't fix your code sample as I don't know all the variables in play but the following is working example that should show you how such a loop should work

     

    -f

    Please login or register to see this code.

    drop it into ZeroBraine or a blank scene and you'll see the results

     

    Please login or register to see this code.

     

    • 0
  • Inquirer
  • Posted
    2 hours ago, Sankotronic said:

    Just try first with changing first line of code to:

    Please login or register to see this code.

    because function fibaro:getGlobal is always returning string value (even it contains number) while table can contain number value so it is possible that you are comparing string with numeric value.

    I think I had tried that before but did it again and that first line then showed the same error....

    [ERROR] 13:33:03: line getGlobal (..."]:1

    • 0
  • Inquirer
  • Posted
    2 hours ago, AutoFrank said:

    The code has a slight error, you're not updating the reference volume (current volume of player) to check against and as a result jsonTable.volume is always greater than volume and it iterates down to zero and actually continues to loop

    you'll need to read back the new (reduced) volume and compare that against your target volume

     

    I have called the new reduced volume back in to the loop, lines 6 & 7...

    Please login or register to see this code.

    What I have noticed (and changed in the code above) is that if I use a figure instead of calling the global variable the code works perfectly.

    It's just calling that variable that's causing a problem. I might try deleting the variable and starting again....could it be corrupt in any way?

    • 0
    Posted
    10 minutes ago, Desmo said:

     

    I have called the new reduced volume back in to the loop, lines 6 & 7...

    Please login or register to see this code.

    What I have noticed (and changed in the code above) is that if I use a figure instead of calling the global variable the code works perfectly.

    It's just calling that variable that's causing a problem. I might try deleting the variable and starting again....could it be corrupt in any way?

     

    Hi @Desmo

    It sounds like a data type compare issue left

     

    @Sankotronic solution should work

    Please login or register to see this code.

    Could you drop this in and share whats in the debug window ?

    • 0
  • Inquirer
  • Posted

    Same thing again... 

    [ERROR] 14:44:06: line getGlobal ("Nursery_S..."]:11

     

    I even created a new global variable but have the same results.

     

    I could manually put the value in to the VD but I wanted it to be easily variable using a slider....this is just plain odd.

     

    • 0
    Posted
    14 minutes ago, Desmo said:

    Same thing again... 

    [ERROR] 14:44:06: line getGlobal ("Nursery_S..."]:11

     

    I even created a new global variable but have the same results.

     

    I could manually put the value in to the VD but I wanted it to be easily variable using a slider....this is just plain odd.

     

     

    @Desmo

    Thats a very odd error

     

    Could you screenshot the whole debug window ?

    • 0
  • Inquirer
  • Posted

    I've added some text to the debug lines so they make sense...

     

     

    Please login or register to see this attachment.

    • 0
    Posted

    Ok, I didn't pay attention what function you use to get value from global variable. it is still problem with number & string comparison, but if you want to convert value from global variable to number then you must use fibaro:getGlobalValue instead of fibaro:getGlobal because former one is returning two values, value of the global variable and also time of the last change.

     

    So this is correct syntax:

    Please login or register to see this code.

    and the it will work.

     

    • 0
  • Inquirer
  • Posted

    Thanks @Sankotronic, I will give that a go later on and report back.

    • 0
    Posted
    30 minutes ago, Desmo said:

    Thanks @Sankotronic, I will give that a go later on and report back.

    @Desmo 

    I missed that .. sorry :oops:

    If you are still having issues let me know and I can try and replicate on my setup at home

     

     

     

    • 0
  • Inquirer
  • Posted

    Thanks for chipping in @AutoFrank and @Sankotronic....that last fix has worked a treat :-D

    • 0
    Posted (edited)
    19 minutes ago, Desmo said:

    Thanks for chipping in @AutoFrank and @Sankotronic....that last fix has worked a treat :-D

    @Desmo

    glad it all worked out ;-)

    Edited by AutoFrank
    • 0
    Posted

    Great!

     

    Happy that it works! :) 

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