Skip to content

Sensors

José Antonio Jiménez Campos edited this page Jan 23, 2021 · 47 revisions

Many HomeKit sensors have the same configurable options. The common sensors are defined here along with their available options.

Type Device Type
5 Contact Sensor
6 Occupancy Sensor
7 Leak Sensor
8 Smoke Sensor
9 Carbon Monoxide Sensor
10 Carbon Dioxide Sensor
11 Filter Change Sensor
12 Motion Sensor

The following configuration is available for sensors:

Section Key Description
Actions "0", "1" etc. The actions performed by the accessory
Inching Time "i" Time period before returning accessory to previous state
State & Status Inputs "f[n]" & "g[n]" Inputs that manage accessory state
Accessory Notifications "m" Notifications to send to another accessory
Actions on Boot "xa" Enable / Disable execution of accessory actions on boot

Example

{
  "c": { "l": 13},
  "a": [{
    "t": 12,
    "i": 10,
    "0": { "r": [{ "g": 16, "v": 0 }] },
    "1": { "r": [{ "g": 16, "v": 1 }] },
    "f1": [{ "g": 14 }]
  }]
}

This is an example of a Sonoff Basic unit with a motion sensor ("t": 12) connected to GPIO 14 ("f1": [{ "g": 14 }]) and an LED connected to GPIO 13 ("l": 13).

The motion sensor accessory ("t": 12) causes action "1" to be performed when activated ("f1"). 10 seconds later action "0" will be performed because of the inching time option ("i": 10)

NOTE: The following options are not needed in this example as they are the default options but are included to make the example more readable: "t": 1 & "v": 0

Actions

A sensor has two actions.

Action State Description
"0" Deactivated This action should be performed when sensor is deactivated. This is the default action on boot.
"1" Activated This action should be performed when sensor is activated

The Digital Outputs "r": [{}] for each should be configured to attain the desired state.

Accessory Notifications

The list of notifications "m" supported by a sensor are as follows:

Value Notification
0 Sensor DEACTIVATED (default)
1 Sensor ACTIVATED

See the general Accessory Notifications section for details of how to configure these notifications.

State and Status Inputs

State inputs "f[n]" & Status Inputs "g[n]" are supported by this accessory. The supported list is:

Key Action
"f0" Perform action "0" (Deactivate)
"f1" Perform action "1" (Activate)
"g0" Set accessory state to Deactivated
"g1" Set accessory state to Activated

Refer to State Inputs for more detail and examples.

ICMP Ping Inputs

ICMP Ping inputs "p[n]" and "q[n]" are supported by this accessory. The supported list is:

Key Action
"p0" Perform action "0" (Deactivate)
"p1" Perform action "1" (Activate)
"q0" Set accessory state to Deactivated
"q1" Set accessory state to Activated

Refer to ICMP Ping Inputs for more detail.

Clone this wiki locally