Skip to content

Sensors

José Antonio Jiménez Campos edited this page Oct 11, 2021 · 47 revisions

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

Type Service 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 service
Inching Time "i" Time period before returning service to previous state
State & Status Inputs "f[n]" & "g[n]" Inputs that manage service state
Service Notifications "m" Notifications to send to another service
Initial Lock State "ks" Lock state at boot
Actions on Boot "xa" Enable / Disable execution of service actions on boot
Historical Data Characteristics

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 service ("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.

Service 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 Service Notifications section for details of how to configure these notifications.

Initial Lock State

The Initial Lock State about Service and Physical controls.

Key Value Notification
"ks" 0 All locked
1 Service unlocked. Physical controls locked
2 Service locked. Physical controls unlocked
3 All unlocked (default)

State and Status Inputs

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

Key Action
"f0" Perform action "0" (Deactivate)
"f1" Perform action "1" (Activate)
"g0" Set service state to Deactivated
"g1" Set service 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 service. The supported list is:

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

Refer to ICMP Ping Inputs for more detail.

Historical Data Characteristics

Characteristic Description
0 Sensor State
Clone this wiki locally