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


HC3 Scenes (not QA) - fibaro:args - how?


Recommended Posts

Hi All,

 

Please guide me to right way to get args in scene on HC3

 

HC2 code to get scene args was:

    local args = fibaro:args()
 

on HC3 it not working now :(

 

Tried:

 

    local args = fibaro.args()    -> got error:  attempt to call a nil value (field 'args')
    local args = fibaro:args().   -> got error: attempt to call a nil value (method 'args')

 

LUA editor don't show any functions containing "args".... 

 

Help, please...

 

Thanks

 

  • Thanks 1
Link to post
Share on other sites
  • 9 months later...

Is this still not possible?
A lot of my HC2 scenes use arguments to pass from one to another scene.
Is there an alternative?

Link to post
Share on other sites
2 hours ago, SDeath said:

Is this still not possible?
A lot of my HC2 scenes use arguments to pass from one to another scene.
Is there an alternative?

The alternative is to write the scenes as QAs.

If the scene was a "shared function" like Logging scene or Message scene it is best replaced by a QA.

QAs can react to fibaro.call(<QA_ID>,<action>,<args...>) so it makes them very convenient to carry out shared functionality.

If you scene also triggered on devices etc it's a bit more work in a QA, but there are lots of examples in the forum how to poll for events within a QA.

The other problem is that QA's can't return values (fibaro.call doesn't return values), but that was kind of a problem with scenes to. However there are ways around that too with some coding,

  • Like 1
Link to post
Share on other sites

So why does that work from another QA and not from a scene?
The arguments don't get passed on, but the QA method gets called, just the arguments are empty.

Link to post
Share on other sites
4 hours ago, SDeath said:

So why does that work from another QA and not from a scene?
The arguments don't get passed on, but the QA method gets called, just the arguments are empty.

It should work. How does your call look like?

(There are some strange marshaling going on for some types but there are ways around that too...)

Link to post
Share on other sites
5 hours ago, jgab said:

It should work. How does your call look like?

(There are some strange marshaling going on for some types but there are ways around that too...)

QA device type is generic.
The same as in my other QA call:

Please login or register to see this code.

 

And in the QA the method looks like

Please login or register to see this code.

 

Edited by SDeath
Link to post
Share on other sites
17 minutes ago, SDeath said:

The same as in my other QA call:

Please login or register to see this code.

 

And in the QA the method looks like

Please login or register to see this code.

 

 

Well, that's the kind of string arguments you can't send. The way they encode the api.call from the scene to the QA makes them interpret them as key/values of the api.call...

The QA implementation of fibaro.call is better (don't ask me why they have different implementations)

The way around it is probably to url encode the string. Unfortunately urlencode is not built-in...

Please login or register to see this code.

 

on the other hand I can think that it's strange that the caller of Pushoverleaf needs to put together the url to pushover as the argument.

Alternatively create the url in the QA

 

Please login or register to see this code.

 

 
  • Like 1
Link to post
Share on other sites
5 minutes ago, jgab said:

 

Well, that's the kind of string arguments you can't send. The way they encode the api.call from the scene to the QA makes them interpret them as key/values of the api.call...

The QA implementation of fibaro.call is better (don't ask me why they have different implementations)

The way around it is probably to url encode the string. Unfortunately urlencode is not built-in...

Please login or register to see this code.

 

on the other hand I can think that it's strange that the caller of Pushoverleaf needs to put together the url to pushover as the argument.

Alternatively create the url in the QA

 

Please login or register to see this code.

 

 

 

Yes you are correct, I should put the link together in the QA, I will change the code, it looks cleaner.
Thanks for your help!

Link to post
Share on other sites

 

Quote

Yes you are correct, I should put the link together in the QA, I will change the code, it looks cleaner.
Thanks for your help!

 

Works great!

Link to post
Share on other sites

...but it is an issue that they fail encoding the parameters correctly from the scene's implementation. If you are unlucky and an argument string has the wrong format you get unexplainable bugs...

Link to post
Share on other sites
6 minutes ago, jgab said:

...but it is an issue that they fail encoding the parameters correctly from the scene's implementation. If you are unlucky and an argument string has the wrong format you get unexplainable bugs...

Yes true because I saw no error in the LUA itself, just the response from the Pushover API that there was no message.

Link to post
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
Reply to this topic...

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