Skip to main content
Version: 1.0

IRDevice

IRDevice components represent logical remote controls. Each device can hold multiple learned codes.

IRDevice instances are identified with irdevice:<id> where <id> is in the dynamic range (200-299).

Methods:

Methods​

IRDevice.GetStatus​

Parameters:

PropertyTypeDescription

id

number

Id of the component instance. Required

Find more about the status response properties in status section

IRDevice.GetConfig​

Parameters:

PropertyTypeDescription

id

number

Id of the component instance. Required

Find the IRDevice.GetConfig response properties in config section

IRDevice.SetConfig​

PropertyTypeDescription

id

number

Id of the component instance. Required

config

object

Configuration that the method takes

Find more about the config properties in config section

IRDevice.LearnCode​

Start learning an IR code. Point the physical remote at the device and press a button within the timeout period. On success, an IRCode component is created automatically and a code_learned event is emitted.

Parameters:

PropertyTypeDescription

id

number

Id of the IRDevice instance. Required

name

string

Name for the new code (e.g., "power", "vol_up"). name length should not exceed 64 chars. Required

function

string or null

What the new code does (e.g., "power_on", "volume_up"). See IRCode configuration. function length should not exceed 64 chars. Optional

timeout

number

Learning timeout in seconds. Accepted range: [1..30]. Optional, default: 15

IRDevice.StopLearnCode​

Cancel an active learning session. Returns an error if the device is not currently learning.

Parameters:

PropertyTypeDescription

id

number

Id of the IRDevice instance. Required

IRDevice.StoreCode​

Store a raw IR code from an external source (e.g., Home Assistant IR code database) as a persistent IRCode component under this device. The stored code is identical to a learned code and can be emitted via IRCode.Emit. The code ID is auto-assigned.

Parameters:

PropertyTypeDescription

id

number

Id of the IRDevice instance. Required

name

string

Name for the new code (e.g., "power", "vol_up"). Must be unique under the parent device. name length should not exceed 64 chars. Required

function

string or null

What the new code does (e.g., "power_on", "volume_up"). See IRCode configuration. function length should not exceed 64 chars. Optional

timings

array

List of signed pulse durations in microseconds. Positive values are marks (carrier on), negative values are spaces (carrier off). Same format as IR.EmitRaw. Accepted length: [1..1024]. Required

freq

number

Carrier frequency in Hz. Accepted range: [20000..60000]. Optional, default: 38000

Response​

The result is a JSON object with the newly assigned component ID.

PropertyTypeDescription

id

number

Id of the created IRCode component

IRDevice.DeleteCode​

Delete a learned code by name.

Parameters:

PropertyTypeDescription

id

number

Id of the IRDevice instance. Required

name

string

Name of the code to delete. Required

Configuration​

The configuration of the IRDevice component contains the device name, type and model. To Get/Set the configuration of the IRDevice component its id must be specified.

Properties:

PropertyTypeDescription

id

number

Id of the component instance

name

string

Device name (e.g., "Living Room TV", "Bedroom AC"). name length should not exceed 64 chars

type

string or null

Kind of appliance the device controls (e.g., "tv", "ac", "fan"). type length should not exceed 64 chars. Optional, set to null to clear. Recommended values (not enforced): tv, ac, fan, light, audio, projector, media_player, heater

model

string or null

Model of the device the codes are imported from (e.g., from an IR library), so more codes for the same model can be imported later. Not changed when codes are learned, stored or deleted. model length should not exceed 64 chars. Optional, set to null to clear

Status​

The status of the IRDevice component contains its unique identifier, information about active learning sessions and the last emitted codes. To obtain the status of the IRDevice component its id must be specified.

Properties:

PropertyTypeDescription

id

number

Id of the component instance

uid

string

Unique identifier of the IR device (UUID). Generated when the IR device is created and never reused: a new IR device gets a new uid even when it gets the id of a deleted one

learning

object or null

Present only during an active learning session

PropertyTypeDescription

started_at

number

Timestamp when learning started

timeout

number

Learning timeout in seconds

name

string

Name of the code being learned

last_emitted

array of objects

Last codes of this device emitted with IRCode.Emit, most recent first. Up to 15 entries, the oldest is removed when a new code is emitted. Empty array if no code has been emitted yet

PropertyTypeDescription

id

number

Id of the emitted IRCode

function

string or null

Function of the IRCode, null if not set

ts

number

Unix timestamp of the emit (in UTC)

Notifications​

Instances of the IRDevice component can send notifications for the following events:

  • code_learned - produced when a code is successfully learned. The event carries the new code's code_id, name and function (null if not set)
  • learning_timeout - produced when learning times out without receiving a signal

Examples​

IRDevice.GetConfig example​

http://192.168.33.1/rpc/IRDevice.GetConfig?id=200

Response

{
"id": 200,
"name": "Living Room TV",
"type": "tv",
"model": "BN59-01199F"
}

IRDevice.SetConfig example​

http://192.168.33.1/rpc/IRDevice.SetConfig?id=200&config={"name":"Bedroom TV","type":"tv"}

Response

{
"restart_required": false
}

IRDevice.GetStatus example​

http://192.168.33.1/rpc/IRDevice.GetStatus?id=200

Response

{
"id": 200,
"uid": "3f2a9c1e-7b4d-4e0a-9c55-1d2e3f4a5b6c",
"last_emitted": [
{
"id": 203,
"function": "cool_22",
"ts": 1794906020.33
},
{
"id": 201,
"function": "power_on",
"ts": 1794906009.35
}
]
}

IRDevice.LearnCode example​

http://192.168.33.1/rpc/IRDevice.LearnCode?id=200&name="power"&function="power_toggle"&timeout=15

Response

null

IRDevice.StopLearnCode example​

http://192.168.33.1/rpc/IRDevice.StopLearnCode?id=200

Response

null

IRDevice.StoreCode example​

http://192.168.33.1/rpc/IRDevice.StoreCode?id=200&name="vol_up"&function="volume_up"&timings=[9000,-4500,560,-1690,560,-560,560,-40000]&freq=40000

Response

{
"id": 202
}

IRDevice.DeleteCode example​

http://192.168.33.1/rpc/IRDevice.DeleteCode?id=200&name="power"

Response

null