Skip to content

TV Service

David Dix edited this page May 5, 2020 · 20 revisions

A HomeKit TV service.

Type Device Type
60 TV Service

The following configuration is available for TVs:

Section Key Description
Actions "a" The actions performed by the accessory
Digital Inputs "b" GPIOs that invoke specific actions
State & Status Inputs "f[n]" or "g[n]" Inputs that trigger a fixed event
ICMP Ping Inputs "q[n]" Ping input to set a state
Accessory Notifications "m" Notifications to send to another accessory
Initial State "s" State a switch accessory enters on boot

Example

{
  "c": { "l": 13, "b": [{ "g": 0, "t": 5 }] },
  "a": [{
    "t": 1,
    "s": 5,
    "0": { "r": [{ "g": 12, "v": 0 }] },
    "1": { "r": [{ "g": 12, "v": 1 }] },
    "b": [{ "g": 0 }]
  }]
}

This is an example of a Sonoff Basic unit configured as a switch ("t": 1), using GPIO 12 as the digital output to control the power relay in the device. The LED is defined as being connected to GPIO 13. A button is also defined for entering Setup Mode when the button on GPIO 0 is pressed for longer then 8 seconds.

A digital input is configured as being connected to GPIO 0 and two button actions are defined; "0" & "1". The first press of the button invokes action "0" and sets the pin to a logic low ("v": 0). The second press of the button invokes action "1" and sets the output to a logic high ("v": 1).

Set the type to 2 ("t": 2) if you would prefer the switch to appear in HomeKit as an Outlet e.g. when you have the device controlling a power socket or power strip.

The switch also has a maximum use time of 1 hour ("d": 3600) and its initial state when the accessory is powered on or rebooted will be the last state before it was rebooted (`"s":5').

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

Key Action Description
"0" Off The default action after boot unless the Initial State has been set
"1" On

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

Accessory Notifications

The list of Accessory Notifications "m" values supported by a switch are:

Key Value Notification
"v" 0 Switch OFF (default)
1 Switch ON

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

Digital Inputs

Digital Inputs "b" are supported by this accessory.

See Digital Inputs for details on how to define this mandatory option.

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" (Off)
"f1" Perform action "1" (On)
"g0" Set accessory state to Off
"g1" Set accessory state to On

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. Refer to ICMP Ping Inputs for more detail.

Initial State

Initial state is defined by the "s" key contained within the accessory object.

Key State Description
"s" 0 OFF (default)
1 ON
4 Defined by fixed state inputs
5 Last state before restart
6 Opposite to last state before restart

The initial state that a switch enters on boot can be set using the "s" option.

Clone this wiki locally