| Line 1: |
Line 1: |
| − | ===Example of description in XML=== | + | <languages/> |
| | + | <translate> |
| | + | ===Example of description in XML=== <!--T:1--> |
| | | | |
| | + | <!--T:2--> |
| | <syntaxhighlight lang="xml" line> | | <syntaxhighlight lang="xml" line> |
| | <item addr="333:132" name="sensor" type="virtual" sub-type="sensor" dim="%" length="2"/> | | <item addr="333:132" name="sensor" type="virtual" sub-type="sensor" dim="%" length="2"/> |
| Line 6: |
Line 9: |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| − | ===Parameters=== | + | ===Parameters=== <!--T:3--> |
| | | | |
| | + | <!--T:4--> |
| | {|class="wikitable" | | {|class="wikitable" |
| | + | |- |
| | !Name!!type and variety!!description | | !Name!!type and variety!!description |
| | + | |- |
| | |sub-type||enum||sensor – virtual sensor<br><br>text – virtual sensor of text type (UTF8), length is to be equal to 0<br>long-text – virtual field of text type (UTF8), length is to be equal to 0<br>Devices that need script to track the status (see the example below the table):<br>lamp, dimer-lamp, rgb-lamp, jalousie, gate, gate120, jalousie120<br>prf – with formatted set of status, the description isbelow | | |sub-type||enum||sensor – virtual sensor<br><br>text – virtual sensor of text type (UTF8), length is to be equal to 0<br>long-text – virtual field of text type (UTF8), length is to be equal to 0<br>Devices that need script to track the status (see the example below the table):<br>lamp, dimer-lamp, rgb-lamp, jalousie, gate, gate120, jalousie120<br>prf – with formatted set of status, the description isbelow |
| | + | |- |
| | |length*||number||status size, bytes<br>0 – dynamic size (obvious for the elements of "sub-type=text" type) | | |length*||number||status size, bytes<br>0 – dynamic size (obvious for the elements of "sub-type=text" type) |
| | + | |- |
| | |dim||symbol||Symbol added to the end of virtual sensor value (for example, % or С) | | |dim||symbol||Symbol added to the end of virtual sensor value (for example, % or С) |
| | |} | | |} |
| | <nowiki>*</nowiki> – required fields | | <nowiki>*</nowiki> – required fields |
| | | | |
| − | ===Example of virtual device "lamp"=== | + | ===Example of virtual device "lamp"=== <!--T:5--> |
| | | | |
| | + | <!--T:6--> |
| | <syntaxhighlight lang="xml" line> | | <syntaxhighlight lang="xml" line> |
| | <item addr="142:99" length="1" name="Lamp" sub-type="lamp" type="virtual"/> | | <item addr="142:99" length="1" name="Lamp" sub-type="lamp" type="virtual"/> |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| | + | <!--T:7--> |
| | The processing of pressing in the script | | The processing of pressing in the script |
| | | | |
| | + | <!--T:8--> |
| | <syntaxhighlight lang="cpp" line> | | <syntaxhighlight lang="cpp" line> |
| | u8 state = 0; | | u8 state = 0; |
| Line 34: |
Line 45: |
| | } | | } |
| | </syntaxhighlight> | | </syntaxhighlight> |
| − | Example of virtual device "dimmable lamp": | + | |
| | + | ===Example of virtual device "dimmable lamp"=== <!--T:9--> |
| | + | <syntaxhighlight lang="xml" line> |
| | <item addr="142:99" length="2" name="Lamp" sub-type="dimer-lamp" type="virtual"/> | | <item addr="142:99" length="2" name="Lamp" sub-type="dimer-lamp" type="virtual"/> |
| | + | </syntaxhighlight> |
| | + | |
| | + | <!--T:10--> |
| | The script processing of stroke | | The script processing of stroke |
| − | u8 state[2] = {0,0}; | + | <syntaxhighlight lang="cpp" line> |
| − | V-ID/142:99 | + | u8 dim = 0; |
| − | { | + | |
| − | if (opt(0)==0xff){
| + | V-ID/Dimmer{ |
| − | if (state[0]==0) state[0] = 1;
| + | if (opt(0)==0xff) |
| − | else state[0] = 0;
| + | setStatus(Dimmer,{1,dim}); |
| − | }else (opt(0)==0xfe){
| + | else if (opt(0)==0xfe){ |
| − | state[0]=state[0];
| + | dim=opt(1); |
| − | }else { | + | setStatus(Dimmer,{1,dim}); |
| − | state[0]=opt(0);
| + | } |
| − | } | |
| − |
| |
| − | if(opt(1)==0xfe){
| |
| − | state[1]=state[1];
| |
| − | }else {
| |
| − | state[1]=opt(1);
| |
| − | }
| |
| − | setStatus(142:99,state);
| |
| | } | | } |
| | + | </syntaxhighlight> |
| | + | </translate> |