Ding:Tradfri
This page is a collection of findings while fiddling around with Ikea Tradfri devices, mostly with the gateway interface. As there is no public documentation for this, most of this was found by me or other people on the interwebs through try and error or reverse engineering of code. This page and the information on it is not affiliated with Ikea of Sweden AB.
You can reach me through IRC: IVI053 in #fln on freenode.
General Notes
- Devices should be powered when operations are performed on them, otherwise you could end up in an inconsistent state.
- After moving a device to a group you need to press the pairing button on all remotes in this group.
- To add multiple remotes to a group simply pair it with a remote that is already in that group.
CoAP Communication
I use libcoap for all examples. Replace $GWIP with your gateway's IP-Address.
For more information on CoAP see RFC7252.
Gateway
Authenticate / Get key for new identity
Since gateway version 1.1.15 you need to get an individual identity and key for all requests you make.
#> coap-client -m post -u "Client_identity" -k SecurityCode -e "{\"9090\":\"Identity\"}" coaps://$GWIP:5684/15011/9063
{ "9091":"A0bcDeF12g3hIJkL", "9029":"1.3.0014" }
The identity you choose is referred as $IDENT in all further examples. The answer 9091 has to be used as $PSK.
General informations
#> coap-client -m get -u $IDENT -k $PSK coaps://$GWIP:5684/15011/15012
...
Get valid endpoints
#> coap-client -m get -u $IDENT -k $PSK coaps://$GWIP:5684/.well-known/core
Activate commisioning mode
#> coap-client -m put -u $IDENT -k $PSK -e '{"9061":Timeout}' coaps://$GWIP:5684/15011/15012
Puts the gateway in a state in which it accepts pairings for up to Timeout seconds.
Reboot
#> coap-client -m post -u $IDENT -k $PSK coaps://$GWIP:5684/15011/9030
Factory defaults
#> coap-client -m post -u $IDENT -k $PSK coaps://$GWIP:5684/15011/9031
Devices
List IDs
#> coap-client -m get -u $IDENT -k $PSK coaps://$GWIP:5684/15001
[ 65574, 65576, 65586 ]
Groups
List IDs
#> coap-client -m get -u $IDENT -k $PSK coaps://$GWIP:5684/15004
[ 131080, 131079, 131092 ]
Create
#> coap-client -m post -u $IDENT -k $PSK -e '{"9001":"NewName"}' coaps://$GWIP:5684/15004
Add device to group
#> coap-client -m put -u $IDENT -k $PSK -e '{"9038":GroupID,"9003":[DeviceID]}' coaps://$GWIP:5684/15004/add
Remove device from group
#> coap-client -m put -u $IDENT -k $PSK -e '{"9038":GroupID,"9003":[DeviceID]}' coaps://$GWIP:5684/15004/remove
Without 9038 you can remove a device from all groups at once.
Delete
#> coap-client -m delete -u $IDENT -k $PSK coaps://$GWIP:5684/15004/GroupID
Key Reference
Key | Value |
---|---|
1001 | NEW_FIRMWARE_AVAILABLE |
1002 | SMART_TASK_TRIGGERED_EVENT |
1003 | GATEWAY_REBOOT_NOTIFICATION |
2051 | OPTION_APP_TOKEN |
3300 | SENSOR |
3311 | LIGHT |
3312 | PLUG |
5001 | LOSS_OF_INTERNET_CONNECTIVITY |
5601 | MIN_MSR_VALUE |
5602 | MAX_MSR_VALUE |
5603 | MIN_RNG_VALUE |
5604 | MAX_RNG_VALUE |
5605 | RESET_MIN_MAX_MSR |
5700 | SENSOR_VALUE |
5701 | UNIT |
5706 | COLOR |
5707 | HUE |
5708 | SATURATION |
5709 | COLOR_X |
5710 | COLOR_Y |
5711 | COLOR_TEMPERATURE |
5712 | TRANSITION_TIME |
5750 | TYPE |
5751 | SENSOR_TYPE |
5805 | CUM_ACTIVE_POWER |
5820 | POWER_FACTOR |
5850 | ONOFF |
5851 | DIMMER |
5852 | ON_TIME |
9001 | NAME |
9002 | CREATED_AT |
9003 | INSTANCE_ID |
9009 | SCENE_LINK |
9014 | NOTIFICATION_STATE |
9015 | NOTIFICATION_EVENT |
9016 | SMART_TASK_TEMPLATE |
9017 | NOTIFICATION_NVPAIR |
9018 | HS_ACCESSORY_LINK |
9019 | REACHABILITY_STATE |
9020 | LAST_SEEN |
9023 | NTP_SERVER |
9024 | TIME_REMAINING_IN_SECONDS |
9029 | VERSION |
9030 | REBOOT |
9031 | RESET |
9032 | FORCE_CHECK_OTA_UPDATE |
9033 | SESSION_ID |
9034 | UPDATE_FIRMWARE |
9035 | GATEWAY_NAME |
9036 | MASTER_TOKEN_TAG |
9037 | OTA_UPDATE |
9038 | GROUP_ID |
9039 | SCENE_ID |
9040 | SMART_TASK_TYPE |
9041 | REPEAT_DAYS |
9042 | START_ACTION |
9043 | END_ACTION |
9044 | TRIGGER_TIME_INTERVAL |
9045 | GROUP_SETTINGS |
9046 | START_TIME_HR |
9047 | START_TIME_MN |
9048 | END_TIME_HR |
9049 | END_TIME_MN |
9050 | SMART_TASK_ACTION |
9051 | SHORTCUT_ICON_REFERENCE_TYPE |
9052 | GATEWAY_REBOOT_NOTIFICATION_TYPE |
9054 | OTA_UPDATE_STATE |
9055 | GATEWAY_UPDATE_PROGRESS |
9056 | GATEWAY_UPDATE_DETAILS_URL |
9057 | SCENE_INDEX |
9058 | SCENE_ACTIVATE_FLAG |
9059 | CURRENT_TIMESTAMP |
9061 | COMMISSIONING_MODE |
9063 | AUTH_PATH |
9064 | SESSION_LENGTH |
9066 | OTA_TYPE |
9068 | IKEA_MOODS |
9069 | UPDATE_ACCEPTED_TIMESTAMP |
9070 | USE_CURRENT_LIGHT_SETTINGS |
9071 | GATEWAY_TIME_SOURCE |
9090 | CLIENT_IDENTITY_PROPOSED |
9091 | NEW_PSK_BY_GW |
9092 | CERTIFICATE_PROV |
9093 | ALEXA_PAIR_STATUS |
9094 | SEND_CERT_TO_GATEWAY |
9095 | SEND_COGNITO_ID_TO_GATEWAY |
9096 | CERTIFICATE_PEM |
9097 | KEY_PAIR |
9098 | PUBLIC_KEY |
9099 | PRIVATE_KEY |
9100 | GATEWAY_ID |
9101 | COGNITO_ID |
9103 | IOT_ENDPOINT |
9104 | SEND_GH_COGNITO_ID_TO_GATEWAY |
9105 | GOOGLE_HOME_PAIR_STATUS |
9994 | TIME_ARRAY |
9995 | GROUP_LINK_ARRAY |
15001 | DEVICES |
15002 | HS_LINK |
15004 | GROUPS |
15005 | SCENE |
15006 | NOTIFICATIONS |
15009 | SWITCH |
15010 | SCHEDULES |
15011 | GATEWAY |
15012 | GATEWAY_DETAILS |
15013 | LIGHT_SETTING |