TCP/IP - Remote Switch Bricklet

This is the description of the TCP/IP protocol for the Remote Switch Bricklet. General information and technical specifications for the Remote Switch Bricklet are summarized in its hardware description.

API

A general description of the TCP/IP protocol structure can be found here.

Basic Functions

BrickletRemoteSwitch.switch_socket
Function ID:
  • 1
Request:
  • house_code – Type: uint8, Range: [0 to 31]
  • receiver_code – Type: uint8, Range: [0 to 31]
  • switch_to – Type: uint8, Range: See meanings
Response:
  • no response

This function is deprecated, use switch_socket_a instead.

The following meanings are defined for the elements of this function:

For switch_to:

  • 0 = Off
  • 1 = On
BrickletRemoteSwitch.get_switching_state
Function ID:
  • 2
Request:
  • empty payload
Response:
  • state – Type: uint8, Range: See meanings

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 switch_socket until the state changes to ready.

How long the switching takes is dependent on the number of repeats, see set_repeats.

The following meanings are defined for the elements of this function:

For state:

  • 0 = Ready
  • 1 = Busy
BrickletRemoteSwitch.switch_socket_a
Function ID:
  • 6
Request:
  • house_code – Type: uint8, Range: [0 to 31]
  • receiver_code – Type: uint8, Range: [0 to 31]
  • switch_to – Type: uint8, Range: See meanings
Response:
  • 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.

A detailed description on how you can figure out the house and receiver code can be found here.

The following meanings are defined for the elements of this function:

For switch_to:

  • 0 = Off
  • 1 = On

New in version 2.0.1 (Plugin).

BrickletRemoteSwitch.switch_socket_b
Function ID:
  • 7
Request:
  • address – Type: uint32, Range: [0 to 67108863]
  • unit – Type: uint8, Range: [0 to 15, 255]
  • switch_to – Type: uint8, Range: See meanings
Response:
  • 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.

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 here.

The following meanings are defined for the elements of this function:

For switch_to:

  • 0 = Off
  • 1 = On

New in version 2.0.1 (Plugin).

BrickletRemoteSwitch.dim_socket_b
Function ID:
  • 8
Request:
  • address – Type: uint32, Range: [0 to 67108863]
  • unit – Type: uint8, Range: [0 to 15, 255]
  • dim_value – Type: uint8, Range: [0 to 255]
Response:
  • 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.

A detailed description on how you can teach a dimmer the address and unit can be found here.

New in version 2.0.1 (Plugin).

BrickletRemoteSwitch.switch_socket_c
Function ID:
  • 9
Request:
  • system_code – Type: char, Range: ['A' to 'P']
  • device_code – Type: uint8, Range: [1 to 16]
  • switch_to – Type: uint8, Range: See meanings
Response:
  • 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.

A detailed description on how you can figure out the system and device code can be found here.

The following meanings are defined for the elements of this function:

For switch_to:

  • 0 = Off
  • 1 = On

New in version 2.0.1 (Plugin).

Advanced Functions

BrickletRemoteSwitch.set_repeats
Function ID:
  • 4
Request:
  • repeats – Type: uint8, Range: [0 to 255], Default: 5
Response:
  • no response

Sets the number of times the code is send when of the 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.

BrickletRemoteSwitch.get_repeats
Function ID:
  • 5
Request:
  • empty payload
Response:
  • repeats – Type: uint8, Range: [0 to 255], Default: 5

Returns the number of repeats as set by set_repeats.

BrickletRemoteSwitch.get_identity
Function ID:
  • 255
Request:
  • empty payload
Response:
  • uid – Type: char[8]
  • connected_uid – Type: char[8]
  • position – Type: char, Range: ['a' to 'h', 'i', 'z']
  • hardware_version – Type: uint8[3]
    • 0: major – Type: uint8, Range: [0 to 255]
    • 1: minor – Type: uint8, Range: [0 to 255]
    • 2: revision – Type: uint8, Range: [0 to 255]
  • firmware_version – Type: uint8[3]
    • 0: major – Type: uint8, Range: [0 to 255]
    • 1: minor – Type: uint8, Range: [0 to 255]
    • 2: revision – Type: uint8, Range: [0 to 255]
  • device_identifier – Type: uint16, Range: [0 to 216 - 1]

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', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet connected to an Isolator Bricklet is always as position 'z'.

The device identifier numbers can be found here

Callbacks

BrickletRemoteSwitch.CALLBACK_SWITCHING_DONE
Function ID:
  • 3
Response:
  • empty payload

This callback is triggered whenever the switching state changes from busy to ready, see get_switching_state.