Jump to content

Sprinkler control


paulbates

Recommended Posts

Hi Benoit

 

I've been able to start customizing HAD for my HA setup. I had questions about sprinklers. I used the HAD device tab this fall to run my sprinkler zones for blowing out my system. I am hoping to have sprinkler zone devices on their own tab.

 

In looking through the docs, I see a screenshot of a sprinklers tab that I don't get when running HAD, and would love something similar to that:

  • Is that tab in response to HAD detecting the irrigation module? I have the climate module but not the irrigation module.
  • Is it possible to get a group of devices on their own tab? I would be as happy with a tab that I configured just my sprinkler zone devices.

Thanks

Paul

Link to comment
Share on other sites

Hello Paul,

 

You can have as many device tables as you want, and this sprinkler table was just an additionnal device table.

 

To do this, you need to:

 

1. Create an additionnal tab

  • In your html page, under <div id="tabs">, add a tab header like this:
<li><a href="#tabs-sprinkler">Sprinklers</a></li>
  • In your html page, copy the tab content from you main device table, and change the name of the tab to match the tab header, and change the name of the device table place holder. In my case, I also added a few toggles to control the behavior of the sprinklers, I left one in the example below.
<div id="tabs-sprinkler">  <!-- Sprinklers -->
    <div> <a feedback="tab3feedback"> <br> </a></div>  <!-- Placeholder for Status messages -->
           
    <div id="sprinklerToggle">
        <input type="radio" id="sprinklerToggle0" name="sprinklerToggle" onclick="varSetValue('1', '18', '0')" /><label for="sprinklerToggle0">Sprinkler Disabled</label>
	<input type="radio" id="sprinklerToggle1" name="sprinklerToggle" onclick="varSetValue('1', '18', '1')" /><label for="sprinklerToggle1">Enable Odd days</label> 
	<input type="radio" id="sprinklerToggle2" name="sprinklerToggle" onclick="varSetValue('1', '18', '2')" /><label for="sprinklerToggle2">Enable Any day</label> 
    </div>

    <div id="deviceList2Placeholder"></div> <!-- Placeholder for the device table --> 
    <button nicebutton onclick="devicesUpdateStatusAllTables()">Status refresh</button>
    <br /><br /><br />
</div>

2. Create an additionnal device table

  • You can copy your existing device table, and just leave the sprinklers. You may have entries here to start a manual cycle, or perhaps display the status of a rain sensor.

3. At page load time, you need to initialize your device table, and display it in it's tab.

  • Look in custom.js, in function UDFdevLoaded (This is called when /rest/nodes is loaded)
  • You need to add the following lines at the end
tableInitCustomTable(devdata, deviceList2);  
processTemplate("#deviceList2Placeholder", deviceList2, "deviceListTemplate");

In this example, deviceList2 would be your device table, and deviceList2Placeholder, the name of your place holder in the tab you created.

 

4. Furthermore, if you make use of toggles like in the example above, you need to initialize them.

Add this under function UDFvarDataLoaded()

    var radio1 = "#sprinklerToggle";
    var value = varFindValue(vars1data, "18"); // Example if you var is an Integer, ID 18
    var id = radio1 + value;    //value==0 Disabled, value==1 Odd, value==2 Always
    $(id).attr('checked', 'checked');    
    $(radio1).buttonset();    

global var loadVar1Data must be set to 1 for this to work.

 

Benoit.

Link to comment
Share on other sites

Benoit-

 

This method will help with sprinklers as well as gives me the general tools to think about additional automation.  

 

I'll confess that this is pretty deep into the technical pool for me. But with the holiday time, I can take my time and learn something while I'm at it.  :-)

 

Very well documented as well as very much appreciated.

 

Thanks

Paul

Link to comment
Share on other sites

Hello Paul,

 

It may be intimidating when you look at it by pieces, but once you open the files and see the context, it will be easier to understand. I'm sure you will say "oh, it's only that!" :-)

 

Just let me know if you need help.

 

Benoit.

Link to comment
Share on other sites

  • 2 weeks later...

Hi Benoit

I was able to start modifying HAD including getting a working sprinklers tab. Thank you again.

I have one small thing I can't figure out. I changed the order of the tab so that my modified dev custom tab is first, and that works.

 

- On the ISY, that tab populates the devices and variables on page load as expected

- On a NAS, it renders everything, but does not populate devices or variables until I click on the variables tab.

 

I can't rule out the NAS, though the software versions seem current enough:

- Debian 7.1

- Apache/2.4.9

- PHP 5.5.11

- I loaded the rest folder (only) from proxy per the directions, I don't have cameras

 

Its more likely something I did. Does this sound familiar and are there places you suggest to look? I tried some things in custom.js, including what runs when the variables tab is opened, but no luck. 

 

One final question: Do you have a paypal site for HAD?

 

Paul

 

 

Link to comment
Share on other sites

Hi Benoit

I was able to start modifying HAD including getting a working sprinklers tab. Thank you again.

I have one small thing I can't figure out. I changed the order of the tab so that my modified dev custom tab is first, and that works.

 

- On the ISY, that tab populates the devices and variables on page load as expected

- On a NAS, it renders everything, but does not populate devices or variables until I click on the variables tab.

 

I can't rule out the NAS, though the software versions seem current enough:

- Debian 7.1

- Apache/2.4.9

- PHP 5.5.11

- I loaded the rest folder (only) from proxy per the directions, I don't have cameras

 

Its more likely something I did. Does this sound familiar and are there places you suggest to look? I tried some things in custom.js, including what runs when the variables tab is opened, but no luck. 

 

One final question: Do you have a paypal site for HAD?

 

Paul

 

Hi Paul,

 

Look at the top of custom.js, there are a few vars to control when various rest calls are made, and more specifically these 2:

var loadVar1Defs = 2; // Set to 1 if some integer variable names are used in a custom table. Set to 0 or 2 for better performance.

var loadVar2Defs = 2; // Set to 1 if some state variable names are used in a custom table. Set to 0 or 2 for better performance.

var loadVar1Data = 2; // Set to 1 to load integer variable data and run UDFvarDataLoaded at page load time.

var loadVar2Data = 2; // Set to 1 to load state variable data and run UDFvarDataLoaded at page load time.

 

The default is 2, meaning that these rest calls are made only when switching to the generic variables tab.

 

If you need vars on page load (if you use them in custom tables), then you need to set loadVar1Data or loadVar2Data to 1, or both.

If you refer to variable names, instead of IDs, you also need to load variable definitions loadVar1Defs or loadVar2Defs to 1, or both.

 

What happen is that when /rest/nodes is finished, control is passed to UDFdevLoaded. From there, there is logic to load additionnal rest calls. The table gets initialized and displayed without waiting for the result of these rest calls. However, when they do finish, the page gets updated nevertheless.

 

Just in case you did modifications to UDVdevLoaded, here's a copy of the default one:

// This is run when /rest/node is loaded successfully
function UDFdevLoaded(devdata)
{
    var deferredVarsDefWhen=0;
        
    //We wait until /rest/nodes is loaded before initiating other rest calls    
    if (loadVar1Defs==1 || loadVar2Defs==1)
    {
        deferredVarsDefWhen = restCallVarsDef(loadVar1Defs==1, loadVar2Defs==1);
        // UDFvarsDefLoaded will be called when rest calls are complete.
    }

    if (loadPgms==1) // If enabled, start this Ajax request ASAP, it will run in parallel with the current thread.
    {
        restCallPgms(deferredVarsDefWhen);
        // UDFpgmLoaded will be called when rest call is complete.
    }
        
    if (loadVar1Data==1 || loadVar2Data==1)
    {
        restCallVarsData(loadVar1Data==1, loadVar2Data==1, deferredVarsDefWhen)
        // UDFvarDataLoaded will be called when rest calls are complete.        
    }

    // Buils the generic table list
    // tableBuilddeviceList can be called with specific folder names, for each folders wanted.
    // Use "" to get devices without folders. Use "All" to get everything.
    tableBuildDeviceList(devdata, devListDefault, "All");

    // Updates custom user tables with data from /rest/nodes
    tableInitCustomTable(devdata, deviceList);
//    tableInitCustomTable(devdata, deviceList2)

    // Process templates without waiting for programs and variable data. It takes too long. The page gets updated later automatically.        
    processTemplate("#defaultDeviceListPlaceholder", devListDefault, "deviceListTemplate");
    processTemplate("#deviceListPlaceholder", deviceList, "deviceListTemplate");        
//    processTemplate("#deviceList2Placeholder", deviceList2, "deviceListTemplate");
}

You are also saying that the result on ISY vs your NAS is different. That is very surprising. I would check to make sure you have the same files on both. If your NAS do load the rest call, but at the wrong moment, I am conviced this is not a NAS configuration issue, but rather a difference in the programs on ISY vs NAS.

 

 

 

One final question: Do you have a paypal site for HAD?

 

 

 

That's very kind of you, but no, I don't.

 

Thanks,

 

Benoit.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...