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

Button to turn OFF/ON my subwoofer


Question

Posted

Hi all LUA professional !

Please login or register to see this image.

/emoticons/default_icon_biggrin.gif" alt=":-D" />

i'm trying to make my first LUA code to a button of a virtual devices to turn OFF/ON my subwoofer (connected to a fibaro wallplug).

but it's not working and i don't understand why (sorry i'm a big newbie with LUA.)

Please login or register to see this image.

/emoticons/default_icon_redface.gif" alt=":oops:" />

i tryed to update a variable "Night" to set the state ON or OFF.

here is my code :

Please login or register to see this code.

anyone can help a newbie like me ?

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

7 answers to this question

Recommended Posts

  • 0
Posted

Your condition is not good, how do you want activate it????

  • 0
  • Inquirer
  • Posted

    hi shad,

    i just want to activate it when pressing the button from my virtual device where is this lua code.

    the condition is just to switch to the opposite state (ON / OFF) when pressing to the button.

    • 0
    Posted

    elmips, why you use getGlobal / setGlobal ? do you want only check when it's night or not ? I can try to help you, but détails all your needs

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

    • 0
  • Inquirer
  • Posted
    elmips, why you use getGlobal / setGlobal ? do you want only check when it's night or not ? I can try to help you, but détails all your needs

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

    Thanks Krikroff, yes, i will explain the all idea.

    1) i have a lua script that check if my XBMC's IP is pinging well and if yes set a global "XBMC" to "1".

    2) I have a block scene that trigger the XBMC global every minute and if it is "1" it power on the receiver and the subwoofer. (2 fibaro wall plug)

    the problem is i can't poweroff the subwoffer when XBMC is poweron because the XBMC global is set to "1" and every minute it poweron again the subwoofer.

    to solve that, i create 2 new block scene :

    the fist say : XBMC = 1 and Night = 0 then poweron receiver + subwoofer

    the second say : XBMC = 1 and Night = 1 then poweron receiver

    it work but it's a bit long to setup manually and to manage well if i want to change this setting while watching a movie.

    My idea is to create a new button on my XBMC virtual device (i allready have to play/pause, ping or send an information message to XBMC).

    This button should :

    switch off the subwoffer if on

    or

    switch on the subwoofer if off

    so i try to setup a lua script on this button to change the state of global "Night" and switch the subwoffer to the opposite state.

    the idea is to check the actual state of "night".

    if it's "0" then change the state to "1" and poweroff the subwoofer.

    else set it to "0" and poweron the subwoffer

    do you think it could be possible ?

    • 0
    Posted

    elmips, to switch the wallplug to the opposite state in LUA you can do that

    Please login or register to see this code.

    If I understand you want to add the notion of "priority to manual control" ? If i switch off my subwoffer, my main scene does not turn on it ...

    You can add a variable "subwofferManualPowerOff" set to true when you turn off it manually. Create a scene that reset this variable to false at 02:00 AM for exemple. Use this variable in your XBMC scene and check if variable is set tot true then do not change the state of your wallplug, if is set to false: lets go !

    This can be optimized but I think this is the right approach.

    • 0
    Posted

    Try that, but scene is going to be easier than virtual device to debug, and you could use virtual device to activate scene:

    Please login or register to see this code.

    EDit: Better to use the way of krikroff

    • 0
  • Inquirer
  • Posted

    @Shad, thanks it work fine with your "if condition" !

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" />

    @krikroff, yes, i will try your way. I have to think about it and to progress with my understanding of LUA to be honest. Perhaps, i will try with scenes before virtual device because it way help me to move forward more efficently.

    thanks again for your precious help guys !

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

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