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 does one get the RGBW Program ID you want to use in LUA?


Question

Posted

Hello.

So i use lua to start predefined programs in the RGBW module.

But, how do i know the ID to specify to start a perticuar program?

The numbers specified next to the RGBW program in the "device tab" does not correlate to the program ID witch is very confusing.

Example from my system is that Program 10 use ID 11!

ID 10 does not exist.

I did add and remove a program and thats when this happened.

This should never be able to happen as the device+ProgramID is connected to the specific device.

Update

-

All my LUA scenes are now not working as removing+adding a RGBW program changes all RGBW devices programID´s.

So if i want to remove a old program ex nr 10 and add a new one in the same spot (10) the new ID is "wrong" / different so you now have to change all your lua scenes to the new ID

-

Update 2

-

Now solved with virtual device json loop

-

So what would be nice is:

1. In lua mode in the "Devices list" for RGBW device the ID of the scenes should be listed

2. Looking at the device the scene ID should correspond tho the ID of the program.

3. If a program is removed ex (10) then the new added program should take its place, not get a new ID. (in my case 11)

I now have ID 1-9 + 11 (No nr 10)

@Fibaro.

Please update this in the future to ease our programming.

Thanks!

Thoughts on this?

(Yes, i know that you can use HC2 toolkit to find the ID in "ProgramSortOrder" och scripting a lua code that reviles the ID when starting the program but this to me is just backwards.

It´s not very user friendly and not everyone use windows or know how to use lua)

19 answers to this question

Recommended Posts

  • 0
Posted

Dear speedy:

Program numbers:

1-5 predefined programs

>6 users' programs

  • 0
  • Inquirer
  • Posted
    Dear speedy:

    Program numbers:

    1-5 predefined programs

    >6 users' programs

    Yes i know.

    But this doesn't help me.

    How do i get the correct ID when creating a lua scene?

    The number next to the program in the "Device" tabs are not the RGBW ProgramID.

    My ID 10 is actually ID 11.

    • 0
    Posted

    speedy, list of programs RGBW you can find there

    Please login or register to see this code.

    • 0
  • Inquirer
  • Posted
    speedy, list of programs RGBW you can find there

    Please login or register to see this code.

    Hi, thats nice but it doesn't help.

    I can't use the program name to execute a scene only the scene ID.

    the ID still changes and one has to rewrite all lua scenes.

    I now have scene 1 to 9 + 11. No nr 10.

    So if i delete a scene and then add new scene in its place no LUA scene using ID 10 works.

    How come ID 10 is skipped?

    • 0
    Posted

    speedy, why it doesn't help?

    Once created program got always that same ID

    full list of programs you can saw there

    to start program in LUA you use command

    Please login or register to see this code.

    • 0
  • Inquirer
  • Posted
    speedy, why it doesn't help?

    Once created program got always that same ID

    full list of programs you can saw there

    to start program in LUA you use command

    Please login or register to see this code.

    Yes that is true and it works fine, if you don't want to change a program.

    I deleted Device Program 10 (ID10) from programs to replace with a new program.

    But what happened was the the new program got ID 11.

    (Program number in RGBW devices tab is 10)

    So i have ID 1 to 9 and 11.

    It skipped nr 10 in /api/RGBPrograms

    • 0
    Posted

    speedy, please remember that when you delete position in database with auto incremident it always go +1

    Please login or register to see this link.

    • 0
    Posted
    speedy, please remember that when you delete position in database with auto incremident it always go +1

    Please login or register to see this link.

    And that's the reason you shouldn't use autoincrement as row ID... it's learned in 'Databases 101'

    Please login or register to see this image.

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

    • 0
  • Inquirer
  • Posted
    speedy, please remember that when you delete position in database with auto incremident it always go +1

    Please login or register to see this link.

    And that's the reason you shouldn't use autoincrement as row ID... it's learned in 'Databases 101'

    Please login or register to see this image.

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

    This makes me laugh actually

    Please login or register to see this image.

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

    How I'm i supposed to respond? Its not up to me how the database acts.

    Well for me, if you program a system for a customer and he one day wants to change his scenes with different colors etc, witch is very easy and a typical costumer usage model, he also have to call the installer (me) to reprogram all of his scenes with new ID´s.

    So now he have to pay for a programmer as his system doesn't "work" any more.

    Just because he wanted to change the color scheme of the ceiling.

    And before this i get a support call from the customer saying the system is broken and doesn't work.

    I guess a workaround would be to use the ProgramID "Name" but thats not available to us.

    Anyway

    To me, this is a "bug".

    • 0
    Posted

    I deliberately bought an HCL so as to prevent myself spending/wasting lots of time coding LUA, so I'm not sure I am entitled to an opinion, but isn't it handy that once you've created a program it will always have the same ID? Look at it this way: your code calls for program 20, 6 months later you delete program 19 because you never use it -- this way your code still works. If it wasn't designed this way, you'd spend ages finding the error, and then changing your code.

    • 0
    Posted

    speedy, then don't use delete action - use edit action we not planning fixing that for Us that is not a bug

    • 0
  • Inquirer
  • Posted

    [ Added: 2014-09-19, 14:59 ]

    I deliberately bought an HCL so as to prevent myself spending/wasting lots of time coding LUA, so I'm not sure I am entitled to an opinion, but isn't it handy that once you've created a program it will always have the same ID? Look at it this way: your code calls for program 20, 6 months later you delete program 19 because you never use it -- this way your code still works. If it wasn't designed this way, you'd spend ages finding the error, and then changing your code.

    I say everyone is entitled to an opinion.

    Well there is a problem to the statement.

    Lets say you have a lua code Calling RGBW program 10 and you the delete 10 and replace 10 with new colors.

    Now it doesn't work becomes the real ID is 11

    (so why have numbers in front of the programs anyhow?).

    I understand what you are saying and this really applies to programs using lua executing lua programs.

    But with this situation i have to find the "errors" anyhow in the lua code.

    The RGBW is a fixed situation with programs always going from 1 to XX.

    With this situation you can tell the customer:

    "Scene 10 is for you Room 1"

    "Scen X is for Room Y"

    "If you delete the scene X it doesn't work."

    If you want a new scene, just replace the scene with the new one and it works.

    This is a strength of the Fibaro system, the ease of use and change for the customers.

    Most customers doesn't want to know what the code does, just change a color program.

    Anyhow, i guess i have to adapt, find a workaround with variables and virtual devices so the ID gets auto configured.

    [ Added: 2014-09-19, 15:01 ]

    speedy, then don't use delete action - use edit action we not planning fixing that for Us that is not a bug

    Ok, thank you for the support!

    • 0
    Posted
    [ Added: 2014-09-19, 14:59 ]

    (so why have numbers in front of the programs anyhow?).

    This discrepancy is cumbersome, yes.

    • 0
    Posted
    speedy, then don't use delete action - use edit action we not planning fixing that for Us that is not a bug

    I have the same problem.

    Fibaro, sorry but your answer is not satisfactory.

    "You can delete a user program, but do not do it!"

    THIS IS A BUG.

    Also if you install more than one module, the user programs are shared and there are 5 programs for the whole box.

    If you have deleted 5 programs you no longer have a chance to run a user program with your box, even if you buy 10 or 100 additional modules.

    There must be a way to reset the ID of the user programs.

    • 0
    Posted

    specimen, let me make it clear: you will be able to use programs but they will have higher ID's.

    • 0
    Posted

    I'm sure that customized programs didn't work with html interface nor with LUA script if ID>10.

    Anyway the problem is solved with v4.018 beta!

    My first customized program have ID=139 and it works!

    Thanks Fibaro.

    • 0
  • Inquirer
  • Posted

    Yeah, the programs work its just the changing of the IDs that was the problem.

    But a solution could be:

    My thinking is to load all the actual program IDs into an array and then use the array to identify the programs.

    Simplified program idea

    Create array:

    a = {} -- new array to hold program actual id

    for i=1, 10 do

    a = 0

    end

    parse and load all the actual program ID´s into an array with answer from

    Please login or register to see this link.

    in the same order that they are displayed.

    Load the program you need from ex 1 to 10.

    fibaro:call(RGBW_device, "startProgram", "a[7]")

    The array now corresponds with 1 to 10 from what we see in the web interface.

    And will always do so even if we remove or add programs.

    • 0
    Posted

    Sort of old thread, I know, I just thought it might be useful for others to know how I solved this.

    speedy: your approach looks good, too, I had already done this differently when I saw you last post.

    I have an HCL, so no LUA. I use a raspberry pi running domoticz to do lots of script jobs for me. In the bathroom I have a NEXA RF remote control I had lying around that I use to change RGBW colors, change sonos radio stations and volume. (One button scrolls through colours/programs and another scrolls through radio stations, first using TTS to announce which station).

    To get the correct RGB program ID, I first used this code (probably not to elegant, but it does the job:)

    Please login or register to see this code.

    Now I have the variable ID containg the correct ID, retrieved based on program name. This is bash, not LUA, but I am sure it would be easy to do something similar in LUA.

    (Now, I've removed the code because I never change the programs anyway...)

    • 0
  • Inquirer
  • Posted

    Well, i solved it in a different way, looping the table.

    This way i always get the correct placement and ID in a table no matter what.

    I know, very crude and no error checking on the connection, don't complain..

    Please login or register to see this image.

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

    It must be made in a virtual device (scenes doesn't have full LUA... oh why Fibaro?!)

    And then use answer to start correct program ID.

    Please login or register to see this code.

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