View Source HAP.CharacteristicDefinition behaviour (HAP v0.6.0)
A behaviour which encapsulates the functinos required to define a characteristic.
At runtime, characteristics are modeled via the HAP.Characteristic
struct which
contains the runtime values for the characteristic itself, as well as metadata about
the characteristic. A HAP.CharacteristicDefinition
is used to provide the template
values for these fields. HAP contains definitions for many common HomeKit characteristics
already, and users may define other characteristics by providing an implementation of
this behaviour as the first value in the characteristic definition tuple in a service.
Summary
Types
The format of a characteristic as defined in Table 6.5 of Apple's HomeKit Accessory Protocol Specification.
One of bool
, uint8
, uint16
, uint32
, uint64
, int
, float
, string
, tlv8
, or data
A permission of a characteristic as defined in Table 6.4 of Apple's HomeKit Accessory Protocol Specification.
One of pr
, pw
, ev
, aa
, tw
, hd
, or wr
The type of a characteristic as defined in Section 6.6.1 of Apple's HomeKit Accessory Protocol Specification.
The unit of measure of a characrteristic's value
Callbacks
Whether or not to only return values via events. Required mostly to satisfy the somewhat oddball Programmable Switch Event characteristic as defined in section 9.75 of Apple's HomeKit Accessory Protocol Specification.
The format of this characteristic's data
The maximum value allowed for this characteristic's value
The minimum value allowed for this characteristic's value
The permissions to allow for this characteristic
The step size by which this characteristic's value may change
The HomeKit type code for this characteristic
The units of this Characteristic's value
Types
@type format() :: String.t()
The format of a characteristic as defined in Table 6.5 of Apple's HomeKit Accessory Protocol Specification.
One of bool
, uint8
, uint16
, uint32
, uint64
, int
, float
, string
, tlv8
, or data
@type perm() :: String.t()
A permission of a characteristic as defined in Table 6.4 of Apple's HomeKit Accessory Protocol Specification.
One of pr
, pw
, ev
, aa
, tw
, hd
, or wr
@type type() :: String.t()
The type of a characteristic as defined in Section 6.6.1 of Apple's HomeKit Accessory Protocol Specification.
@type unit() :: any()
The unit of measure of a characrteristic's value
Callbacks
@callback event_only() :: boolean()
Whether or not to only return values via events. Required mostly to satisfy the somewhat oddball Programmable Switch Event characteristic as defined in section 9.75 of Apple's HomeKit Accessory Protocol Specification.
@callback format() :: format()
The format of this characteristic's data
@callback max_value() :: HAP.Characteristic.value()
The maximum value allowed for this characteristic's value
@callback min_value() :: HAP.Characteristic.value()
The minimum value allowed for this characteristic's value
@callback perms() :: [perm()]
The permissions to allow for this characteristic
@callback step_value() :: HAP.Characteristic.value()
The step size by which this characteristic's value may change
@callback type() :: type()
The HomeKit type code for this characteristic
@callback units() :: unit()
The units of this Characteristic's value