..
 #############################################################
 # This file was automatically generated on 2015-05-08.      #
 #                                                           #
 # If you have a bugfix for this file and want to commit it, #
 # please fix the bug in the generator. You can find a link  #
 # to the generators git repository on tinkerforge.com       #
 #############################################################


:breadcrumbs: <a href="../../index.html">Home</a> / <a href="../../index.html#software-tcpip">Software</a> / TCP/IP - Remote Switch Bricklet

.. |device_identifier_constant| unicode:: 0xA0
   :trim:

.. _remote_switch_bricklet_tcpip:

TCP/IP - Remote Switch Bricklet
===============================

This is the description of the :ref:`TCP/IP protocol <llproto_tcpip>` for the :ref:`Remote Switch Bricklet <remote_switch_bricklet>`. General information and technical
specifications for the Remote Switch Bricklet are summarized in its :ref:`hardware description
<remote_switch_bricklet_description>`.

.. _remote_switch_bricklet_tcpip_api:

API
---

A general description of the TCP/IP protocol structure can be found
:ref:`here <llproto_tcpip>`.




Basic Functions
^^^^^^^^^^^^^^^



.. tcpip:function:: BrickletRemoteSwitch.switch_socket

 :functionid: 1
 :request house_code: uint8
 :request receiver_code: uint8
 :request switch_to: uint8

 :noresponse: no response

 This function is deprecated, use :tcpip:func:`switch_socket_a <BrickletRemoteSwitch.switch_socket_a>` instead.
 
.. tcpip:function:: BrickletRemoteSwitch.get_switching_state

 :functionid: 2
 :emptyrequest: empty payload

 :response state: uint8

 Returns the current switching state. If the current state is busy, the
 Bricklet is currently sending a code to switch a socket. It will not
 accept any calls of :tcpip:func:`switch_socket <BrickletRemoteSwitch.switch_socket>` until the state changes to ready.
 
 How long the switching takes is dependent on the number of repeats, see
 :tcpip:func:`set_repeats <BrickletRemoteSwitch.set_repeats>`.
 
.. tcpip:function:: BrickletRemoteSwitch.switch_socket_a

 :functionid: 6
 :request house_code: uint8
 :request receiver_code: uint8
 :request switch_to: uint8

 :noresponse: no response

 To switch a type A socket you have to give the house code, receiver code and the
 state (on or off) you want to switch to.
 
 The house code and receiver code have a range of 0 to 31 (5bit).
 
 A detailed description on how you can figure out the house and receiver code
 can be found :ref:`here <remote_switch_bricklet_type_a_house_and_receiver_code>`.
 
 .. versionadded:: 2.0.1~(Plugin)
 
.. tcpip:function:: BrickletRemoteSwitch.switch_socket_b

 :functionid: 7
 :request address: uint32
 :request unit: uint8
 :request switch_to: uint8

 :noresponse: no response

 To switch a type B socket you have to give the address, unit and the state
 (on or off) you want to switch to.
 
 The address has a range of 0 to 67108863 (26bit) and the unit has a range
 of 0 to 15 (4bit). To switch all devices with the same address use 255 for
 the unit.
 
 A detailed description on how you can teach a socket the address and unit can
 be found :ref:`here <remote_switch_bricklet_type_b_address_and_unit>`.
 
 .. versionadded:: 2.0.1~(Plugin)
 
.. tcpip:function:: BrickletRemoteSwitch.dim_socket_b

 :functionid: 8
 :request address: uint32
 :request unit: uint8
 :request dim_value: uint8

 :noresponse: no response

 To control a type B dimmer you have to give the address, unit and the
 dim value you want to set the dimmer to.
 
 The address has a range of 0 to 67108863 (26bit), the unit and the dim value
 has a range of 0 to 15 (4bit).
 
 A detailed description on how you can teach a dimmer the address and unit can
 be found :ref:`here <remote_switch_bricklet_type_b_address_and_unit>`.
 
 .. versionadded:: 2.0.1~(Plugin)
 
.. tcpip:function:: BrickletRemoteSwitch.switch_socket_c

 :functionid: 9
 :request system_code: char
 :request device_code: uint8
 :request switch_to: uint8

 :noresponse: no response

 To switch a type C socket you have to give the system code, device code and the
 state (on or off) you want to switch to.
 
 The system code has a range of 'A' to 'P' (4bit) and the device code has a
 range of 1 to 16 (4bit).
 
 A detailed description on how you can figure out the system and device code
 can be found :ref:`here <remote_switch_bricklet_type_c_system_and_device_code>`.
 
 .. versionadded:: 2.0.1~(Plugin)
 


Advanced Functions
^^^^^^^^^^^^^^^^^^

.. tcpip:function:: BrickletRemoteSwitch.set_repeats

 :functionid: 4
 :request repeats: uint8

 :noresponse: no response

 Sets the number of times the code is send when of the :tcpip:func:`switch_socket <BrickletRemoteSwitch.switch_socket>`
 functions is called. The repeats basically correspond to the amount of time
 that a button of the remote is pressed.
 
 Some dimmers are controlled by the length of a button pressed,
 this can be simulated by increasing the repeats.
 
 The default value is 5.
 
.. tcpip:function:: BrickletRemoteSwitch.get_repeats

 :functionid: 5
 :emptyrequest: empty payload

 :response repeats: uint8

 Returns the number of repeats as set by :tcpip:func:`set_repeats <BrickletRemoteSwitch.set_repeats>`. 
 
.. tcpip:function:: BrickletRemoteSwitch.get_identity

 :functionid: 255
 :emptyrequest: empty payload

 :response uid: char[8]
 :response connected_uid: char[8]
 :response position: char
 :response hardware_version: uint8[3]
 :response firmware_version: uint8[3]
 :response device_identifier: uint16

 Returns the UID, the UID where the Bricklet is connected to, 
 the position, the hardware and firmware version as well as the
 device identifier.
 
 The position can be 'a', 'b', 'c' or 'd'.
 
 The device identifier numbers can be found :ref:`here <device_identifier>`.
 |device_identifier_constant|
 


.. _remote_switch_bricklet_tcpip_callbacks:

Callbacks
^^^^^^^^^

.. tcpip:function:: BrickletRemoteSwitch.CALLBACK_SWITCHING_DONE

 :functionid: 3

 :emptyresponse: empty payload


 This callback is called whenever the switching state changes
 from busy to ready, see :tcpip:func:`get_switching_state <BrickletRemoteSwitch.get_switching_state>`.
 


