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 to get name of a device in LUA


richo

Question

Anyone knows how to get the "name" of a device (not type) in LUA - i.ex.

"id": 166,

"name": "Kamerka wolny",

I want to use it in messages as a local variable based on Device ID.

Link to comment
Share on other sites

17 answers to this question

Recommended Posts

  • 0
Guest b95_lun

I think you could use http APIs to get a JSON string and then decode it in lua and you would then have the name in the array.

Link to comment
Share on other sites

  • 0

richo, or in virtual devices, scenes from version 3.490

Please login or register to see this code.

Link to comment
Share on other sites

  • 0
Guest Lode

I don't know wich value i should expect here but it gives me an empty string.

Please login or register to see this code.

Is this a bug in LUA or is it something else ?

Link to comment
Share on other sites

  • 0
Guest deraaij
I don't know wich value i should expect here but it gives me an empty string.

Please login or register to see this code.

Is this a bug in LUA or is it something else ?

Device Description on the advanced tab of a z-wave device.

Link to comment
Share on other sites

  • 0

look on printscreen Lode

Please login or register to see this attachment.

Link to comment
Share on other sites

  • 0
Guest Lode

I know but it gives no value (string) in LUA

This could help richo out

Sorry A.Socha, i saw your post to late.

Thx.

Please login or register to see this image.

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

Link to comment
Share on other sites

  • 0

Lode, when is empty give nill

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

if you gonna write there something you will get it

Please login or register to see this code.

Link to comment
Share on other sites

  • 0
Guest deraaij
I know but it gives no value (string) in LUA

This could help richo out

Sorry A.Socha, i saw your post to late.

Thx.

Please login or register to see this image.

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

If you put text in it, it works. I use it.

Link to comment
Share on other sites

  • 0
Guest Lode

Yep, i understand.

I tought it had to give the name of the device.

Thx Mark and A.Socha

Link to comment
Share on other sites

  • 0

he can use json to find string or use in next beta

in virtual devices, scenes from version 3.490

Please login or register to see this code.

Link to comment
Share on other sites

  • 0
Guest deraaij
he can use json to find string or use in next beta

in virtual devices, scenes from version 3.490

Please login or register to see this code.

Cool! (The fibaro:getname)

Link to comment
Share on other sites

  • 0
Guest Lode

VERY COOL !!

Please login or register to see this image.

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

Link to comment
Share on other sites

  • 0
  • Inquirer
  • or in virtual devices, scenes from version 3.490

    This is exactly what I need, can't wait for 3.490

    Please login or register to see this image.

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

    PS

    Why only in virtual device?

    Link to comment
    Share on other sites

    • 0

    in virtual devices, scenes

    Link to comment
    Share on other sites

    • 0
    Guest deraaij

    BTW I was trying to give an examle using json.decode. But because of the nested additional json string (properties) this code is not working:

    Please login or register to see this code.

    If i test it with:

    response = '{"id":4,"name":"Bedlamp Floris","roomID":1,"type":"binary_light"}'

    it works, if i do with the total returned json string:

    {"id":4,"name":"Bedlamp Floris","roomID":1,"type":"binary_light","properties":{"UIMessageSendTime":"0000-00-00 00:00:00","classConfigure":"0,0,0,2,2,2,2,2","classGeneric":"37","classSupport":"32,37,39,50,112,114,133,134","classVersion":"1,1,1,2,1,1,2,1","dead":"0","deviceControlType":"2","deviceIcon":"1","disabled":"0","emailNotificationID":"2","emailNotificationType":"0","endPoint":"0","isBatteryOperated":"0","isLight":"1","liliOffCommand":"","liliOnCommand":"","meterSupport":"{\"vMeterSupport\":[{\"meterType\":1,\"sMeterType\":\"kWh\",\"meterScale\":0,\"sMeterScale\":\"\",\"value\":0,\"enable\":true,\"lastPolling\":1355559336,\"configuration\":true,\"retryConfig\":0},{\"meterType\":1,\"sMeterType\":\"W\",\"meterScale\":2,\"sMeterScale\":\"\",\"value\":0,\"enable\":true,\"lastPolling\":1355559337,\"configuration\":true,\"retryConfig\":0}]}","needConfigure":"5","type":"binary_light","nodeID":"3","parametersTemplate":"25","parentID":"1","pollingRetryError":"","pollingTime":"1362683844","pollingTimeNext":"1362684957","pollingTimeSec":"0","productInfo":"0,96,0,4,0,2,1,1","pushNotificationID":"1","pushNotificationType":"0","requestNodeNeighborState":"0","requestNodeNeighborStateTimeStemp":"0","sensorSupport":"","showChildren":"1","smsNotificationID":"1","smsNotificationType":"0","sortOrder":"999","type":"16","unit":"","unitMeter":"kWh","unitSensor":"W","userDescription":"Bedlamp Floris;Bedroom Floris","value":"0","valueMeter":"0","valueSensor":"0","zwaveCompany":"Everspring","zwaveInfo":"6,2,64","zwaveVersion":"","parameters":[],"associationView":[{"groupID":1,"devices":[1]},{"groupID":2,"devices":[1]}],"associationSet":[{"groupID":1,"devices":[1]},{"groupID":2,"devices":[1]}]},"actions":{"pollingTimeSec":1,"requestNodeNeighborUpdate":0,"resetMeter":0,"turnOff":0,"turnOn":0},"created":1362688420,"modified":1362688420}'

    It doesn't work,

    any idea why.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Socha sorry i must have eaten scenes , as I was just having a dinner

    Please login or register to see this image.

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

    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.

    ×
    ×
    • Create New...