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:
IRDevice.GetStatusto obtain the component's statusIRDevice.GetConfigto obtain the component's configurationIRDevice.SetConfigto update the component's configurationIRDevice.LearnCodeto start learning an IR codeIRDevice.StopLearnCodeto cancel an active learning sessionIRDevice.StoreCodeto store a raw IR code from an external sourceIRDevice.DeleteCodeto delete a code by name
Methods
IRDevice.GetStatus
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance. Required |
Find more about the status response properties in status section
IRDevice.GetConfig
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance. Required |
Find the IRDevice.GetConfig response properties in config section
IRDevice.SetConfig
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance. Required |
| 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:
| Property | Type | Description |
|---|---|---|
| number | Id of the IRDevice instance. Required |
| string | Name for the new code (e.g., "power", "vol_up"). |
| string or null | What the new code does (e.g., "power_on", "volume_up"). See IRCode configuration. |
| number | Learning timeout in seconds. Accepted range: |
IRDevice.StopLearnCode
Cancel an active learning session. Returns an error if the device is not currently learning.
Parameters:
| Property | Type | Description |
|---|---|---|
| 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:
| Property | Type | Description |
|---|---|---|
| number | Id of the IRDevice instance. Required |
| string | Name for the new code (e.g., "power", "vol_up"). Must be unique under the parent device. |
| string or null | What the new code does (e.g., "power_on", "volume_up"). See IRCode configuration. |
| array | List of signed pulse durations in microseconds. Positive values are marks (carrier on), negative values are spaces (carrier off). Same format as |
| number | Carrier frequency in Hz. Accepted range: |
Response
The result is a JSON object with the newly assigned component ID.
| Property | Type | Description |
|---|---|---|
| number | Id of the created IRCode component |
IRDevice.DeleteCode
Delete a learned code by name.
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the IRDevice instance. Required |
| 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:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance |
| string | Device name (e.g., "Living Room TV", "Bedroom AC"). |
| string or null | Kind of appliance the device controls (e.g., "tv", "ac", "fan"). |
| 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. |
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:
| Property | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| number | Id of the component instance | ||||||||||||
| 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 | ||||||||||||
| object or null | Present only during an active learning session
| ||||||||||||
| array of objects | Last codes of this device emitted with
|
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'scode_id,nameandfunction(nullif not set)learning_timeout- produced when learning times out without receiving a signal
Examples
IRDevice.GetConfig example
- IRDevice.GetConfig HTTP GET Request
- IRDevice.GetConfig Curl Request
- IRDevice.GetConfig Mos Request
http://192.168.33.1/rpc/IRDevice.GetConfig?id=200
curl -X POST -d '{"id":1,"method":"IRDevice.GetConfig","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call IRDevice.GetConfig '{"id":200}'
Response
- IRDevice.GetConfig HTTP GET Response
- IRDevice.GetConfig Curl Response
- IRDevice.GetConfig Mos Response
{
"id": 200,
"name": "Living Room TV",
"type": "tv",
"model": "BN59-01199F"
}
{
"id": 1,
"src": "shellyirctrlg4-xxx",
"params": {
"id": 200,
"name": "Living Room TV",
"type": "tv",
"model": "BN59-01199F"
}
}
{
"id": 200,
"name": "Living Room TV",
"type": "tv",
"model": "BN59-01199F"
}
IRDevice.SetConfig example
- IRDevice.SetConfig HTTP GET Request
- IRDevice.SetConfig Curl Request
- IRDevice.SetConfig Mos Request
http://192.168.33.1/rpc/IRDevice.SetConfig?id=200&config={"name":"Bedroom TV","type":"tv"}
curl -X POST -d '{"id":1,"method":"IRDevice.SetConfig","params":{"id":200,"config":{"name":"Bedroom TV","type":"tv"}}}' http://${SHELLY}/rpc
mos --port ${PORT} call IRDevice.SetConfig '{"id":200,"config":{"name":"Bedroom TV","type":"tv"}}'
Response
- IRDevice.SetConfig HTTP GET Response
- IRDevice.SetConfig Curl Response
- IRDevice.SetConfig Mos Response
{
"restart_required": false
}
{
"id": 1,
"src": "shellyirctrlg4-xxx",
"params": {
"restart_required": false
}
}
{
"restart_required": false
}
IRDevice.GetStatus example
- IRDevice.GetStatus HTTP GET Request
- IRDevice.GetStatus Curl Request
- IRDevice.GetStatus Mos Request
http://192.168.33.1/rpc/IRDevice.GetStatus?id=200
curl -X POST -d '{"id":1,"method":"IRDevice.GetStatus","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call IRDevice.GetStatus '{"id":200}'
Response
- IRDevice.GetStatus HTTP GET Response
- IRDevice.GetStatus Curl Response
- IRDevice.GetStatus Mos 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
}
]
}
{
"id": 1,
"src": "shellyirctrlg4-xxx",
"params": {
"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
}
]
}
}
{
"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
- IRDevice.LearnCode HTTP GET Request
- IRDevice.LearnCode Curl Request
- IRDevice.LearnCode Mos Request
http://192.168.33.1/rpc/IRDevice.LearnCode?id=200&name="power"&function="power_toggle"&timeout=15
curl -X POST -d '{"id":1,"method":"IRDevice.LearnCode","params":{"id":200,"name":"power","function":"power_toggle","timeout":15}}' http://${SHELLY}/rpc
mos --port ${PORT} call IRDevice.LearnCode '{"id":200,"name":"power","function":"power_toggle","timeout":15}'
Response
- IRDevice.LearnCode HTTP GET Response
- IRDevice.LearnCode Curl Response
- IRDevice.LearnCode Mos Response
null
{
"id": 1,
"src": "shellyirctrlg4-xxx",
"params": null
}
null
IRDevice.StopLearnCode example
- IRDevice.StopLearnCode HTTP GET Request
- IRDevice.StopLearnCode Curl Request
- IRDevice.StopLearnCode Mos Request
http://192.168.33.1/rpc/IRDevice.StopLearnCode?id=200
curl -X POST -d '{"id":1,"method":"IRDevice.StopLearnCode","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call IRDevice.StopLearnCode '{"id":200}'
Response
- IRDevice.StopLearnCode HTTP GET Response
- IRDevice.StopLearnCode Curl Response
- IRDevice.StopLearnCode Mos Response
null
{
"id": 1,
"src": "shellyirctrlg4-xxx",
"params": null
}
null
IRDevice.StoreCode example
- IRDevice.StoreCode HTTP GET Request
- IRDevice.StoreCode Curl Request
- IRDevice.StoreCode Mos Request
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
curl -X POST -d '{"id":1,"method":"IRDevice.StoreCode","params":{"id":200,"name":"vol_up","function":"volume_up","timings":[9000,-4500,560,-1690,560,-560,560,-40000],"freq":40000}}' http://${SHELLY}/rpc
mos --port ${PORT} call IRDevice.StoreCode '{"id":200,"name":"vol_up","function":"volume_up","timings":[9000,-4500,560,-1690,560,-560,560,-40000],"freq":40000}'
Response
- IRDevice.StoreCode HTTP GET Response
- IRDevice.StoreCode Curl Response
- IRDevice.StoreCode Mos Response
{
"id": 202
}
{
"id": 1,
"src": "shellyirctrlg4-xxx",
"params": {
"id": 202
}
}
{
"id": 202
}
IRDevice.DeleteCode example
- IRDevice.DeleteCode HTTP GET Request
- IRDevice.DeleteCode Curl Request
- IRDevice.DeleteCode Mos Request
http://192.168.33.1/rpc/IRDevice.DeleteCode?id=200&name="power"
curl -X POST -d '{"id":1,"method":"IRDevice.DeleteCode","params":{"id":200,"name":"power"}}' http://${SHELLY}/rpc
mos --port ${PORT} call IRDevice.DeleteCode '{"id":200,"name":"power"}'
Response
- IRDevice.DeleteCode HTTP GET Response
- IRDevice.DeleteCode Curl Response
- IRDevice.DeleteCode Mos Response
null
{
"id": 1,
"src": "shellyirctrlg4-xxx",
"params": null
}
null