setAutoState — device automation control from script.

Description:

u8 setAutoState(ID:SUBID, u8 time);

Activates or disactivates the automation on the device for a specific time interval time.

List of parameters

SUBID

device address where the script is located.

ID:SUBID

Device address.

time

· Value more than 0 – disactivate the device automation for time seconds;

· 0 – activate the device automation;

· Value less than 0 – disactivate the device automation until it will be activated by another setAutoState or till unit will be powered off.

Example:

<!-- Example 1 -->
<item id="512" LAMP="512:8" name="Test for delayedCallR function" type="script">
V-ID/V-ADDR{
 
        	if(opt0()){      	      	
                    	// Activate automation
                    	setAutoState(8, 0);
                    	u8 strForMess[150];        	
                    	// Automation status check
                    	i8 sttOfAuto = autoState(8);
                    	// Message output to the interface
                    	if(sttOfAuto == 0) {
                               	sprintf(strForMess, "%cAutomation is activated!", 1);
                               	setStatus(@exciterId():32, &strForMess);
                    	} else if(sttOfAuto > 0){
sprintf(strForMess, "%cTill activating the automation is %d seconds", 4, sttOfAuto);
                               		setStatus(@exciterId():32, &strForMess);
                    	} else {
                               		setStatus(@exciterId():32, {8, "Automation is disactivated"});
                    	}       	
        	}
}
</item>
 
<!-- Example 2 -->
<item id="512" LAMP="512:8" name="Test for setAutoState function" type="script">
V-ID/V-ADDR{
 
        	if(opt0()){    
                    	// Disactivate automation
                    	setAutoState(8, -1);
                    	u8 strForMess[150];        	
                    	// Automation status check
                    	i8 sttOfAuto = autoState(8);
                    	// Message output to the interface
                    	if(sttOfAuto == 0) {
                               	sprintf(strForMess, "%cAutomation is activated!", 1);
                               	setStatus(@exciterId():32, &strForMess);
                    	} else if(sttOfAuto > 0){
sprintf(strForMess, "%cTill activating the automation is %d seconds", 4, sttOfAuto);
                               		setStatus(@exciterId():32, &strForMess);
                    	} else {
                               		setStatus(@exciterId():32, {8, "Automation is disactivated"});
                    	}       	
        	}
}
</item>
 
<!-- Example 3 -->
<item id="512" LAMP="512:8" name="Test for setAutoState function" type="script">
V-ID/V-ADDR{
 
        	if(opt0()){      	
                    	// Disactivate automation for 10 seconds
                    	setAutoState(8, 10);
                    	u8 strForMess[150];        	
                    	// Automation status check
                    	i8 sttOfAuto = autoState(8);
                    	// Message output to the interface
                    	if(sttOfAuto == 0) {
                               	sprintf(strForMess, "%cAutomation is activated!", 1);
                               	setStatus(@exciterId():32, &strForMess);
                    	} else if(sttOfAuto > 0){
sprintf(strForMess, "%cTill activating the automation is %d seconds", 4, sttOfAuto);
                               		setStatus(@exciterId():32, &strForMess);
                    	} else {
                               		setStatus(@exciterId():32, {8, "Automation is disactivated"});
                    	}       	
        	}
}
</item>

The result of performing the example:

The result of example 1:

“Automation is activated!”

The result of example 2:

” Automation is disactivated!”

The result of example 3:

“10 seconds till automation activation!”

Note:

Attention:
having switched off the automation that uses setAutoState(ID:SUBID, -1) function in case of changing the slave status the automation will be activated (upon the expiry of autoperiod).