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

How I get the selected icon of a relay switch with LUA?


Question

Posted

Hello,

how I get the selected icon of a relay switch with LUA?

1. the icon when the contact is closed

2. the icon if the contact is open

local icon = fibaro:getValue(deviceID, "deviceIcon")

fibaro:debug(icon)

With this LUA script I only get one ID; likely when the contact is open.

16 answers to this question

Recommended Posts

  • 0
Posted

AlexanderRi, you should check the status and not the icon

Please login or register to see this image.

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

Please login or register to see this code.

0 = Off

1 = On

  • 0
Posted

Krikroff,

Please login or register to see this image.

/emoticons/default_laugh.png" alt=":lol:" />

Please login or register to see this image.

/emoticons/default_laugh.png" alt=":lol:" />

Please login or register to see this image.

/emoticons/default_laugh.png" alt=":lol:" />

  • 0
  • Inquirer
  • Posted

    Krikroff, no your query I know.

    For my LUA script I really need the ID of the icons.

    Do you have a solution?

    • 0
    Posted

    Maby you can use a part of my lua below.

    Please login or register to see this code.

    • 0
  • Inquirer
  • Posted

    Hello,

    no one has a solution?

     

    Again, what I'm looking for:
    For the relay switch module I MANUALLY selected main icon (from FIBARO) for ON and OFF.
    Now I want to retrieve the ID with LUA for these two icons, which I have set manually.

     

    I tested the following LUA script:

    local icon = fibaro:getValue(deviceID, "deviceIcon") 
    fibaro:debug(icon)

     

    But I only get one ID for ON and OFF, not two different values.

     

    And the following LUA script always returns nil:

     

    local icon = fibaro:getValue(deviceID, "currentIcon"

     

    Has anyone a solution?

    • 0
    Posted

    If you want state you must watch for value

    deviceIcon is resource that show package  of icons

     

    List of icons pacage you can get from there

    Please login or register to see this link.

    • 0
  • Inquirer
  • Posted
    This variant (

    Please login or register to see this link.

    ) I know. But I want it to read with LUA!

    If I manually change the icon, I have just with LUA the current value and does not need manual intervention.

     

    A solution with LUA?
    • 0
    Posted

    Hi,

    i try to change the propertie "deviceIcon": "2"

    i use a PUT request but i can't change the number of the used icon.

     

    Is it possible to change that propertie ?

    • 0
    Posted

    Are you trying to change ID of a icon with ID == 2? System icons cannot be deleted or changed.

    • 0
    Posted

    Thank you for your reply, in fact i try to change the icon of one device with his json properties.

    • 0
    Posted

    Please login or register to see this code.

    This scene works for me just fine, please give it a try.

    • 0
    Posted

    Thank it's work fine but it's in a scene

     

    Can i do the same in a button of Virtual Device ?

    • 0
    Posted

    It is even shorter:

    Please login or register to see this code.

    • 0
    Posted

    Thank you, i made a mistake with two "" 

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" />

    • 0
    Posted

    Generally you can use " or ' if you wish, but sometimes you need to combine them like in 2nd line.

    • 0
    Posted

    I try to change "ip" or "port" properties but that don't work ....

    Is it possbile to change every properties in a json ?

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