5. Example templates

5.1. Simple single IP relay

This simple IP relay has very basic features:

  • No authentication
  • No status request command
  • Only two commands for on and off
  • Does not answer to switching with a status reply
  • It is reachable via port 80

The command for switching the relay on:

 http://<IP-address>/control?cmd=GPIO,12,1

The command for switching the relay off:

 http://<IP-address>/control?cmd=GPIO,12,1

This command structure is implemented into this template:

<?xml version="1.0" encoding="UTF-8"?>
  <Device name="" template_version="1.1">
     <IPBox template_version="0" ip_box_is_set="true"  max_relais="1">
       <IP_Adresse editable="true" gui_is_optional="false"></IP_Adresse>
          <Port editable="true" gui_is_optional="false">80</Port>
          <Model>Simple GPIO 12</Model>
          <Company>Maker Box</Company>
          <Username editable="false" gui_is_optional="true"></Username>
          <Passwort editable="false" gui_is_optional="true"></Passwort>
          <Relays editable="true" gui_is_optional="true">
              <Relay position="1" status="true">GPIO12-Relais</Relay>
          </Relays>
          <Relaytype_CGI is_simple="true">
            <http_request name="relay_on">
                 <url_string editable="true" gui_is_optional="false">/control?cmd=GPIO,12,1</url_string>
            </http_request>
            <http_request name="relay_off">
               <url_string editable="true" gui_is_optional="false">/control?cmd=GPIO,12,0</url_string>
            </http_request>
          </Relaytype_CGI>
     </IPBox>
  </Device>

5.2. IP relay with 4 ports

This IP relay has 4 switches:

  • It uses basic authentication
  • It answers switching with a status reply
  • It supports status requests
  • It is reachable via port 80.

The command for switching the relays at position 1 and position 3 on or off:

 http://<IP-address>/cgi/control.cgi?login=p:username:password&p=1010
 Explanation: After p= the 4 relays are represented by a 1 for on or a 0 for off. Relay position 1 is on the left, relay position 4 is on the right side.
 This switching command is answered by a status reply in the http BODY:
 <html>1 0 1 0</html>
 Explanation: After <html> the 4 relays are represented by a 1 for on or a 0 for off. Relay position 1 is on the left, relay position 4 is on the right side.

The command for the status request:

 http://<IP-address>/cgi/control.cgi?login=p:username:password&port=list

This status query command is answered by a status reply in the http BODY:

 <html>1 0 1 0</html>
 Explanation: After <html> the 4 relays are represented by a 1 for on or a 0 for off. Relay position 1 is on the left, relay position 4 is on the right side.

This command structure is implemented into this template:

<?xml version="1.0" encoding="UTF-8"?>
<Device name="" template_version="1.1">
   <IPBox template_version="0" ip_box_is_set="true" max_relais="4">
       <IP_Adresse editable="true" gui_is_optional="false"></IP_Adresse>
       <Port editable="true" gui_is_optional="false">80</Port>
       <Model editable="true" gui_is_optional="true">Great 4</Model>
       <Company editable="true" gui_is_optional="true">Good Switches</Company>
       <Username editable="true" gui_is_optional="false"></Username>
       <Passwort editable="true" gui_is_optional="false"></Passwort>
       <Relays editable="true" gui_is_optional="true">
              <Relay position="1" status="true">Power-Relay 1</Relay>
              <Relay position="2" status="true">Power-Relay 2</Relay>
              <Relay position="3" status="true">Power-Relay 3</Relay>
              <Relay position="4" status="true">Power-Relay 4</Relay>
       </Relays>
       <Relaytype_CGI editable="true" gui_is_optional="true">
          <basic_auth>true</basic_auth>
          <digest_auth>false</digest_auth>
          <http_request name="schalte_relay" method="GET">
               <url_string>/cgi/control.cgi?login=p:$Username$:$Passwort$&amp;p=$Relay_STATUS_1$$Relay_STATUS_2$$Relay_STATUS_3$$Relay_STATUS_4$</url_string>
               <http_response use_body="true">&lt;html&gt; $Relay_STATUS_1$ $Relay_STATUS_2$ $Relay_STATUS_3$ $Relay_STATUS_4$ &lt;/html&gt;</http_response>
          </http_request>
          <http_request name="relay_status" response_is_in_http_body="true" method="GET">
               <url_string> /cgi/control.cgi?login=p:$Username$:$Passwort$&amp;port=list</url_string>
               <http_response>&lt;html&gt;$Relay_STATUS_1$ $Relay_STATUS_2$ $Relay_STATUS_3$ $Relay_STATUS_4$  &lt;/html&gt;</http_response>
          </http_request>
       </Relaytype_CGI>
   </IPBox>
</Device>

<- Previous Chapter