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

getselfid problem


Question

Posted

This code isn't working

local selfId = fibaro:getSelfId()
fibaro:debug("SelfID")

I get "Unknown exception: /opt/fibaro/scenes/139.lua:7:attempt to call method 'getSelfId' (a nil value)"

I know almost no coding and googling has not provided a clue, nor chatgpt.

Does this code not work in your HC2? or is mine not well

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

local selfId=fibaro:getSelfId()
fibaro:debug(selfId) -- not SelfID

Edited by Bodyart
  • 0
  • Inquirer
  • Posted (edited)
    4 hours ago, Bodyart said:

    local selfId=fibaro:getSelfId()
    fibaro:debug(selfId) -- not SelfID


    No, not even that works.

    I got here because I was getting this error when trying to run something Sankotronic had provided to us. I tried pulling that bit of his code and testing it and looking elsewhere for a clean version of the above, just those two lines to simplify things.

    So this is the scene in total
     

    --[[
    %% properties
    %% events
    %% globals
    --]]
     

    local selfId=fibaro:getSelfId()
    fibaro:debug(selfId)

    But I still get this error [DEBUG] (error time/date - my words) [fatal] Unknown exception: /opt/fibaro/scenes/139.lua:7:attempt to call method 'getSelfId' (a nil value)

    Line 7 being -> local selfId=fibaro:getSelfId()

    Edited by MartW
    • 0
    Posted (edited)

    getSelfId() works for virtual devices, not for scenes. You didn't mention, that it is a scene you're using.
     

    For the scenes you can use:
     

    Please login or register to see this code.

     

    BTW For what do you need the scene ID?

    Edited by Bodyart
    • 0
  • Inquirer
  • Posted
    19 minutes ago, Bodyart said:

    getSelfId() works for virtual devices, not for scenes. You didn't mention, that it is a scene you're using.
     

    For the scenes you can use:
     

    Please login or register to see this code.

     

    BTW For what do you need the scene ID?


    Ah, so in trying to problem solve, I ended up using the wrong code for the area I was using it.

    I was getting an error code while following Sankotronics install instructions for a VD he had provided us, so thought copy/pasting it into a scene would help problem solve

    That code does work in the main loop of a VD. I can now go and try sankotronics VD again and at least have an example of code that I know does work.

    Thanks Bodyart, I may be one step closer to wherever it was I was going, lol

     

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