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

VD Bluespray Irrigation Controller


Brom

Question

Hi everyone,

 

I'm having some issues with Lua code in a virtual device I am writing.

I'm getting information on the status of my Bluespray irrigation controller.

It has a basic API and reports if any of the zones are on watering. I want to just query the unit and then print out if any are detected as on.

 

When I query bluespray controller and its not watering anything I get some JSON back which looks like this.

 

Please login or register to see this code.

 

When its IS watering I get the following.

 

Please login or register to see this code.

 

To make it even more complex sometimes the system reports multiple zones operating. (This is normal and ok. I just need to pick up the first zone reported)

 

Please login or register to see this code.

 

 

My issue is detecting if I get none, one or multiple active zones. If I have a valid zone then I then want to put the first zone number into the zoneterminal variable. If I don't have a valid zone I just want to put 0 into the zoneterminal variable.

The problem is when I try something like the code below I get

[ERROR] 22:11:22: line 56: attempt to index field '?' (a nil value)

 

I cant figure out how to deal with LUA arrays correctly. (specifically detecting valid entries)

The json.null operator does not seem to work the same way on array values.

 

Please login or register to see this code.

 

 

Any help appreciated.

ps Code for the output is really extra long. Looking to understand how I can manipulate the variable name / number I am outputting to reduce the number of if statements.

 

Once I get this figured out I plan to also add in buttons to perform manual runs.

 

Brom

 

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • I think I fixed issues with variable detection.

    If anyone cares here is the vd

     

    Will try and figure out buttons to turn the unit on in the future.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    hi i have similar issue with "attempt to index field '?' (a nil value)" can you explain what did you do exactly, 

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 25 minutes ago, JacekP said:

    hi i have similar issue with "attempt to index field '?' (a nil value)" can you explain what did you do exactly, 

     

     

     

    Sorry to say.. I sold my Fibaro and moved to an alternate platform.

    I cant remember how I got it all to work.

     

    It might be you have a different number of zones.. I hard coded a fair amount in that script.

     

    Sorry..

     

     

     

    • Like 1
    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...