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

OpenSprinkler/Virtual Device with LUA


Question

Posted

I've created a simple virtual device to integrate opensprinkler into HC2. It allows me to toggle from auto to manual to off and turn each zone on and off. I'm having a heck of a time building on the basic functionality like getting feedback of the status to update the icon and more complicated actions in buttons. Looking at the LUA reference manual, I'm not really sure where to start and searches on this forum don't really yield any results that help.

What I'm looking for is how to retrieve a status into a variable to update the state of the icon. I understand if nobody has used this, but just wonder how to handle a return value from an HTTP get to retrieve a state. Also, currently, you have to ensure all zones are off before manually turning another on or else water pressure is too low to pop up the sprinkler heads. Trying to add multiple lines to shutoff all other zones before turning one on does not run anything. I suspect running LUA code to execute or get zone states and loop will be more elegant, but beyond my knowledge.

Any help would be appreciated. Below are some samples of calls to opensprinkler:

Auto: GET /cv?pw=opendoor&en=1&rd=0&rbt=0&mm=0

Manual: GET /cv?pw=opendoor&en=1&rd=0&rbt=0&mm=1

Off: GET /cv?pw=opendoor&en=0

Turn a zone on for 10 minutes: GET /sn1=1&t=600

Turn a zone off: GET /sn1=0

Thanks in advance!

8 answers to this question

Recommended Posts

  • 0
Posted

If you just put the http request to get status into a browser, what response do you get? If you post it here, it is easier to help you out with how to handle the response.

  • 0
  • Inquirer
  • Posted

    If you send

    Please login or register to see this link.

    it returns a binary value for the status.

    • 0
    Posted

    So a 1 is an active zone and a 0 is an inactive zone? Because then it will be pretty easy to decode that string of ones and zeros into a functioning scene. But I'm not sure if fibaro will handle a binary value as a number by default, so you probably need to decode it for the box. Then just create an array with a value for each digit. You can do it by means of a simple loop and a short pieces of seek-and destroy code which takes the first digit out of the binary string, checks if the number is a one or a zero and then updates the zone status, then it removes that digit and starts over until there are no more digits in the binary string.

    • 0
    Guest bozman
    Posted

    Interesting,

    I'm about to start same process.

    What Software solution are you using for the OpenSprinkler there are a couple of them?

    • 0
  • Inquirer
  • Posted
    So a 1 is an active zone and a 0 is an inactive zone? Because then it will be pretty easy to decode that string of ones and zeros into a functioning scene. But I'm not sure if fibaro will handle a binary value as a number by default, so you probably need to decode it for the box. Then just create an array with a value for each digit. You can do it by means of a simple loop and a short pieces of seek-and destroy code which takes the first digit out of the binary string, checks if the number is a one or a zero and then updates the zone status, then it removes that digit and starts over until there are no more digits in the binary string.

    Yes, 1 is on and 0 is off. Any example code of other virtual devices would help. I've done a bunch searches, but just can't find where to start as far as the coding this. I don't think it'll be terribly difficult, but reference is non-existent.

    Interesting,

    I'm about to start same process.

    What Software solution are you using for the OpenSprinkler there are a couple of them?

    I am using the Rayshobby.net kit v2.1 with the original board, not the Pi or Beagle. One challenge I've run into that you should be aware of is manual mode on the app is treated differently from the web interface. If you kick off a zone manually on the web interface, it defaults to 10 minutes and runs. On the mobile app, it just turns it on with no run time. That is a little scary considering water costs and the amount of damage you can do with that much water!

    • 0
    Guest bozman
    Posted

    Ok, I have the raspberry PI version.

    I'll see how far I can get with that option.

    I'll let you know.

    • 0
    Posted
    So a 1 is an active zone and a 0 is an inactive zone? Because then it will be pretty easy to decode that string of ones and zeros into a functioning scene. But I'm not sure if fibaro will handle a binary value as a number by default, so you probably need to decode it for the box. Then just create an array with a value for each digit. You can do it by means of a simple loop and a short pieces of seek-and destroy code which takes the first digit out of the binary string, checks if the number is a one or a zero and then updates the zone status, then it removes that digit and starts over until there are no more digits in the binary string.

    Yes, 1 is on and 0 is off. Any example code of other virtual devices would help. I've done a bunch searches, but just can't find where to start as far as the coding this. I don't think it'll be terribly difficult, but reference is non-existent.

    You need. To use the LUA "string." Functions. So a string.len function to find the length of your binary string then a string.sub to extract each individual value. Then you just use the extracted value to define if that exact nozzle is activated and based on that do something.

    • 0
    Posted

    I have a fibre home centre 2 system and just bought a opensprinkler system

     

    Can anybody assist me to integrate this with my Fibaro

     

    Please note I am not too technical (meaning on the programming side) and would appreciate it if I can be assisted with code etc

     

    Kind regards

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