Code Monkey home page Code Monkey logo

ikea-tradfri-coap-docs's Introduction

Ikea Tradfri CoAP Docs

How can you communicate to your Ikea tradfri gateway/hub through coap-client. Tested with Tradfri hub version 1.3.0014, 1.8.0025 and 1.12.0.

Note: After 3 Years of rocking Ikea tradfri hardware I gave up. After several bugs/crashes and even several hardware failures I switched to Philips Hue (yes yes I know you get what you paid for, but waking up in the middle of the night because all lights turned on since there was a firmware update running was not fun anymore). However, I will still try to maintain these docs as much as possible, and I will also still look at new issues created on this repository to help here I can. So if you have more information you want me to add into this guide don't hesitate to open an issue, And I'm happy to add it to the docs.

Table of Contents

Install coap-client

Before you can talk to you Ikea gateway/hub you need to install the coap-client:

Linux

  1. Download the install-coap-client.sh from github (you find this script in the scripts folder of the repository).
  2. Chmod the file, so you can run it.
  3. Run the file as root.

MacOS

Note: this is pretty much the same like on Linux, except that you use 'homebrew' for the missing tools and libraries:

  1. Use 'brew install automake' and 'brew install local' to install build-tools You might need to have 'Xcode' installed which is free on the App Store
  2. Download the install-coap-client.sh from github (you find this script in the scripts folder of the repository).
  3. Open 'Terminal'-app, cd to 'Downloads' directory and type 'chmod +x install-coap-client.sh', so you can run it.
  4. Run the install-script with 'sudo ./install-coap-client.sh' (you must use a user-account with administrator privileges to do so). You will now find '/usr/local/bin/coap-client' on the system. (You may want to add '/usr/local/bin/' to your $PATH environment variable.)

Windows

With thanks to Stefan Thoolen (@Garrcomm)

  1. Download and install Visual Studio 2019 CE with workload "Desktop development with C++"
  2. Download and install OpenSSL v1.1.1k including development files
  3. Download the build-libcoap-win-x64.cmd from github (you find this script in the scripts folder of the repository).
  4. Run the file as administrator.

Authenticate

First we need to create a preshared key. This key can then be used to authenticate yourself: Please note: this key will expire if you don't use it in 6 weeks from activation. Every time you use this key the time will be extended accordingly.

coap-client -m post -u "Client_identity" -k "$TF_GATEWAYCODE" -e "{\"9090\":\"$TF_USERNAME\"}" "coaps://$TF_GATEWAYIP:5684/15011/9063"
  • $TF_USERNAME: Can be a random name as long as you use it in the other requests you want to make
  • $TF_GATEWAYCODE: Is the security code at the bottom of your Gateway/HUB. It should be 16 characters long.
  • $TF_GATEWAYIP: Is the IP of your Gateway/HUB

This will then respond something like this:

{
  "9091": "$TF_PRESHARED_KEY", // Preshared Key
  "9029": "1.3.0014" // Gateway Firmware version
}

The URL

To control a bulb you need to know it's URL. This is very easy. The URL's all begin with coaps://$TF_GATEWAYIP:5684/15001

The bulbs will have addresses beginning at 65537 for the first bulb, 65538 for the second, and so on. So, to control the first bulb, you would use the following url:

coaps://$TF_GATEWAYIP:5684/15001/65537

Devices

Get a list of all devices

To get a complete list of all devices connected to your hub use the following command:

coap-client -m get -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" "coaps://$TF_GATEWAYIP:5684/15001"

Get info about a specific device

To check the current status of a connected device and to know which device is linked to a specified id, use this command:

coap-client -m get -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID"

$TF_DEVICEID is an id from the list generated by the previous command. Ids are 5 digits long.

The result will look something similar to this:

{
  "9001": "Warm white bulb",
  "9002": 429400800,
  "9003": 65561,
  "9020": 1619068199,
  "3311": [
    {
      "5850": 0,
      "5849": 2,
      "9003": 0,
      "5851": 1
    }
  ],
  "9019": 1,
  "3": {
    "0": "IKEA of Sweden",
    "1": "TRADFRI bulb E27 WW 806lm",
    "3": "2.3.050"
  },
  "5750": 2
}

The numbers translate to the following labels:

Numeric key Type Description
3.0 string Manufacturer name
3.1 string Product name
3.3 string Firmware version
3.9 integer Battery status, 0 to 100 (not available in the example above since bulbs don't have batteries)
3311 array Bulb data, see also Bulbs
5750 integer Device type (2 stands for Bulb)
9001 string Name of the device
9002 integer Creation timestamp
9003 integer Instance ID
9020 integer Last seen timestamp
9019 boolean Reachability state

Groups

Get a list of all groups

To get a complete list of all groups use the following command:

coap-client -m get -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" "coaps://$TF_GATEWAYIP:5684/15004"

Get info about a specific group

To check the current status of a group and to know which devices are linked to the specified id, use this command:

coap-client -m get -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" "coaps://$TF_GATEWAYIP:5684/15004/$TF_GROUPID"

$TF_GROUPID is an id from the list generated by the previous command. Ids are 6 digits long.

The result will look something similar to this:

{
  "9001": "Home office",
  "9018": {
    "15002": {
      "9003": [
        65558,
        65561,
        65563
      ]
    }
  },
  "5851": 254,
  "9003": 131087,
  "9002": 429400800,
  "5850": 1
}

The numbers translate to the following labels:

Numeric key Type Description
5850 boolean On/off status of the group
5851 integer Brightness status of the group
9001 string Name of the group
9002 integer Creation timestamp
9003 integer Instance ID
9018 array List of items within the group

Add device to a specific group

To add a member device to a group, use this command:

coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "9038": $TF_GROUPID, "9003": [ $TF_DEVICEID ] }' "coaps://$TF_GATEWAYIP:5684/15004/add"

Remove device from a specific group

To remove a member device from a group, use this command:

coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "9038": $TF_GROUPID, "9003": [ $TF_DEVICEID ] }' "coaps://$TF_GATEWAYIP:5684/15004/remove"

Turn on all devices in a specific group

To control a specific group, use this command:

coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "5850": 1 }' "coaps://$TF_GATEWAYIP:5684/15004/$TF_GROUPID"

$TF_GROUPID is an id from the list generated by the Get a list of all groups command. Ids are 6 digits long.

Payload

Here is an example payload for coap-client with explanation what each field does:

{
  "5850": 1, // on / off (needs to be set to 1 to switch scenes)
  "5851": 254, // dimmer (1 to 254)
  "5712": 10, // transition time (fade time)
  "9039": 196621 // scene id for activating/switching scenes (id comes from the list generated by the `Get a list of all scenes` command. Ids are 6 digits long.)
}

Scenes

Note: scenes where formerly known as moods inside the Ikea Tradfri app. This change was introduced at version 1.12.0

Get a list of all scenes

To get a complete list of all scenes use the following command:

coap-client -m get -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" "coaps://$TF_GATEWAYIP:5684/15005/$TF_GROUPID"

$TF_GROUPID is an id from the list generated by the Get a list of all groups command. Ids are 6 digits long.

Get info about a specific scene

To get the current configuration of a scene and to know which devices are linked to the specified id, use this command:

coap-client -m get -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" "coaps://$TF_GATEWAYIP:5684/15005/$TF_GROUPID/$TF_SCENEID"

$TF_SCENEID is an id from the list generated by the previous command. Ids are 6 digits long.

$TF_GROUPID is an id from the list generated by the Get a list of all groups command. Ids are 6 digits long.

The result will look something similar to this:

{
  "9001": "Home office dimmed",
  "9109": 2,
  "9003": 196630,
  "9002": 429400800,
  "9057": 1,
  "15013": [
    {
      "5850": 0,
      "9003": 65544,
      "5851": 2
    },
    {
      "5850": 0,
      "9003": 65539
    },
    {
      "5850": 0,
      "9003": 65545
    },
    {
      "5850": 1,
      "9003": 65546,
      "5851": 2
    },
    {
      "5850": 1,
      "9003": 65557,
      "5851": 2
    }
  ]
}

The numbers translate to the following labels:

Numeric key Type Description
9001 string Name of the scene
9002 integer Creation timestamp
9003 integer Instance ID
9057 integer Scene index
9109 integer Icon index
15013 array Light settings

Activating a scene

A scene can be activated by controlling a specific group. From this endpoint you are able to set a scene on the specified group. A detailed payload can be found in the Groups > Payload chapter. The following command can be used to activate a scene in a group:

coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "5850": 1, "9039": $TF_SCENEID }' "coaps://$TF_GATEWAYIP:5684/15004/$TF_GROUPID"

$TF_GROUPID is an id from the list generated by the Get a list of all groups command. Ids are 6 digits long.

$TF_SCENEID is an id from the list generated by the Get a list of all scenes command. Ids are 6 digits long.

Endpoints

List all available endpoints

To get a complete list of available endpoints on your gateway use the following command:

coap-client -m get -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" "coaps://$TF_GATEWAYIP:5684/.well-known/core"

Sensor

The (motion) sensor is unsupported at the moment, since the gateway doesn't receive any useful information from the sensor. The cause of this could be since the device is running of batteries. And if the sensor needs to send data back constantly to the gateway it would run out of them pretty quickly. If someone has more information about the sensor please open an issue of create a pull request to update the documentation.

Remote

The remote is unsupported at the moment, since the gateway doesn't receive any useful information from the remote. The cause of this could be since the device is running of batteries. And if the remote needs to send data back constantly to the gateway it would run out of them pretty quickly. If someone has more information about the remote please open an issue of create a pull request to update the documentation.

Shortcut button

The Ikea shortcut button was introduced around november 2020.

The button is unsupported at the moment, since the gateway doesn't receive any useful information from the button. The cause of this could be since the device is running of batteries. And if the button needs to send data back constantly to the gateway it would run out of them pretty quickly. If someone has more information about the button please open an issue of create a pull request to update the documentation.

Bulbs

Note: It seems that in bulb firmware v2.3.086 the default behaviour for a non-existing hue color changed. Previously the bulb would go to the default warm color, but now the bulb turns off while reporting it's still on. See more details in issue #31

Your first bulb

To set the brightness of your first bulb to 50% use the following command:

coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "3311": [{ "5851": 127 }] }' "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID"

Payload

Here is an example payload for coap-client with explanation what each field does:

{
  "3311": [
    {
      "5850": 1, // on / off
      "5851": 254, // dimmer (1 to 254)
      "5706": "f1e0b5", // color in HEX (Don't use in combination with: color X and/or color Y)
      "5709": 65535, // color X (Only use in combination with color Y)
      "5710": 65535, // color Y (Only use in combination with color X)
      "5712": 10 // transition time (fade time)
    }
  ]
}

Colors

The following colors where taken from the Ikea Android app (these could be used in field "5706"):

Please note: If you are using another HEX value then these the lamp will default to the Warm Glow color.

Cold / Warm Bulbs

Lightbulbs running on firmware less then ±2.3.087

"f5faf6": "White",
"f1e0b5": "Warm",
"efd275": "Glow"

Lightbulbs running on firmware ±2.3.087 and up:

"efd275": "Glow"
"f1e0b5": "Warm"
"f2eccf": "LightWarm"
"f3f3e3": "LightWhite"
"f5faf6": "White"

RGB Bulbs

"4a418a": "Blue",
"6c83ba": "Light Blue",
"8f2686": "Saturated Purple",
"a9d62b": "Lime",
"c984bb": "Light Purple",
"d6e44b": "Yellow",
"d9337c": "Saturated Pink",
"da5d41": "Dark Peach",
"dc4b31": "Saturated Red",
"dcf0f8": "Cold sky",
"e491af": "Pink",
"e57345": "Peach",
"e78834": "Warm Amber",
"e8bedd": "Light Pink",
"eaf6fb": "Cool daylight",
"ebb63e": "Candlelight",
"efd275": "Warm glow",
"f1e0b5": "Warm white",
"f2eccf": "Sunrise",
"f5faf6": "Cool white"

More Colors

Ikea RGB bulbs can produce more colors than the list above.

They can produce all colors in the xyY color space.

To understand how this color space works take a look at the diagram below:

xyY Color Space

To create your own color you need define two values (x and y) from 0 to 65535 with this command:

coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "3311": [{"5709": 65535, "5710": 65535}] }' "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID"

Plug

The Ikea plug was introduced around October 2018.

Also this device can be controlled with the same api.

Your first plug

To turn on a plug use the following command:

coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "3312": [{ "5850": 1 }] }' "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID"

Payload

Here is an example payload for coap-client with explanation what each field does:

{
  "3312": [
    {
      "5850": 1, // on / off
      "5851": 254 // dimmer (0 to 254) (As of writing there arn't any dimmable plugs. Value's above 0 will simply turn on the plug)
    }
  ]
}

Blind

The Ikea blinds where introduced around August 2019.

Also, this device can be controlled with the same api.

Your first blind

To change position of a blind use the following command:

coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "15015": [{ "5536": 0.0 }] }' "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID"

Payload

Here is an example payload for coap-client with explanation what each field does:

{
  "15015": [
    {
      "5536": 0.0 // position (0 to 100)
    }
  ]
}

Air Purifier

The Ikea Air Purifier was introduced around April 2021.

Also, this device can be controlled with the same api.

Your first air purifier

To change the fan mode of the air purifier use the following command:

coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "15025": [{ "5900": 50 }] }' "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID"

Payload

Here is an example payload for coap-client with explanation what each field does:

{
  "15025": [
    {
      "5900": 50, // fan mode (0 = Off, 1 = Auto, 10 = Level 1, 20 = Level 2, 30 = Level 3, 40 = Level 4, 50 = Level 5)
      "5908": 10, // fan speed
      "5905": false, // lock/unlock control buttons
      "5906": false // enables/disables the status LED's
    }
  ]
}

Endpoints

Global

URL Description
coaps://$TF_GATEWAYIP:5684/15001 Devices endpoint
coaps://$TF_GATEWAYIP:5684/15004 Groups endpoint
coaps://$TF_GATEWAYIP:5684/15005 Scenes endpoint
coaps://$TF_GATEWAYIP:5684/15006 Notifications endpoint
coaps://$TF_GATEWAYIP:5684/15010 Smart Tasks endpoint

Gateway

URL Description
coaps://$TF_GATEWAYIP:5684/15011/9030 Reboot gateway endpoint
coaps://$TF_GATEWAYIP:5684/15011/9031 Reset gateway endpoint
coaps://$TF_GATEWAYIP:5684/15011/9034 UpdateFirmware gateway endpoint
coaps://$TF_GATEWAYIP:5684/15011/15012 Gateway details endpoint

Please note: You need to use -m post for the reboot command to work.

Codes

Devices

Code Description Type
3300 Motion Sensor Array
3311 Light/Bulb Array
3312 Plug Array
15015 Blind Array
15025 Air Purifier Array

General parameters

Code Description Type
9001 Name String
9002 Creation date Int
9003 Instance ID Int

Group parameters

Code Description Type
5712 Transition Time Int
5850 On/Off Boolean
5851 Brightness Int
9018 Accessory Link (Remote) Array
9039 Scene ID Int

Scene parameters

Code Description Type
9058 Scene Active State Boolean
9057 Device Index ID Int
9068 Is Scene Predefined Boolean
15013 Light Settings Array

Bulb parameters

Code Description Type
5706 Color HEX String HEX String
5707 Hue Int
5708 Saturation Int
5709 colorX Int
5710 colorY Int
5711 Color Temperature Int
5712 Transition Time Int
5850 On/Off Boolean
5851 Brightness Int

Plug parameters

Code Description Type
5850 On/Off Boolean
5851 Brightness Int

Blind parameters

Code Description Type
5536 Position Float

Air Purifier parameters

Code Description Type
5907 Air Quality Number
5905 Controls Locked Boolean
5900 Fan Mode Number
5908 Fan Speed Number
5904 Total Filter Lifetime Number
5902 Filter Runtime Number
5910 Filter Remaining Lifetime Number
5903 Filter Status Number
5906 Status LEDs Boolean
5909 Total Motor Runtime Number

CoAP Protocol

CoAP Response Codes

Below is a snippet from https://tools.ietf.org/html/rfc7252 containing the default CoAP response codes:

+------+------------------------------+-----------+
| Code | Description                  | Reference |
+------+------------------------------+-----------+
| 2.01 | Created                      | [RFC7252] |
| 2.02 | Deleted                      | [RFC7252] |
| 2.03 | Valid                        | [RFC7252] |
| 2.04 | Changed                      | [RFC7252] |
| 2.05 | Content                      | [RFC7252] |
| 4.00 | Bad Request                  | [RFC7252] |
| 4.01 | Unauthorized                 | [RFC7252] |
| 4.02 | Bad Option                   | [RFC7252] |
| 4.03 | Forbidden                    | [RFC7252] |
| 4.04 | Not Found                    | [RFC7252] |
| 4.05 | Method Not Allowed           | [RFC7252] |
| 4.06 | Not Acceptable               | [RFC7252] |
| 4.12 | Precondition Failed          | [RFC7252] |
| 4.13 | Request Entity Too Large     | [RFC7252] |
| 4.15 | Unsupported Content-Format   | [RFC7252] |
| 5.00 | Internal Server Error        | [RFC7252] |
| 5.01 | Not Implemented              | [RFC7252] |
| 5.02 | Bad Gateway                  | [RFC7252] |
| 5.03 | Service Unavailable          | [RFC7252] |
| 5.04 | Gateway Timeout              | [RFC7252] |
| 5.05 | Proxying Not Supported       | [RFC7252] |
+------+------------------------------+-----------+

CoAP Method Codes

Below is a snippet from https://tools.ietf.org/html/rfc7252 containing the default CoAP method codes:

+------+--------+-----------+
| Code | Name   | Reference |
+------+--------+-----------+
| 0.01 | GET    | [RFC7252] |
| 0.02 | POST   | [RFC7252] |
| 0.03 | PUT    | [RFC7252] |
| 0.04 | DELETE | [RFC7252] |
+------+--------+-----------+

More documentation

Debugging COAPS with IKEA Tradfri gateway | @Jan21493

License

MIT

ikea-tradfri-coap-docs's People

Contributors

108174 avatar glenndehaan avatar kapstok avatar lennartgrunau avatar raupinger avatar rikudousage avatar rob4t avatar sauerbi avatar snigel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ikea-tradfri-coap-docs's Issues

Coap not working

When I use a command like this:
coap-client -m put -u "USER" -k "KEY" -e '{ "3311": [{ "5850": 1 }] }' "coaps://192.168.2.1:5684/15004/195019"

The response is always just:
v:1 t:CON c:PUT i:8894 {} [ ] decrypt_verify(): found 24 bytes cleartext decrypt_verify(): found 4 bytes cleartext

And nothing happens....
Getting the data from my light does work:
{"9001":"NAME","9002":1542748695,"9003":195019,"9039":226934,"5850":1,"5851":0,"9108":0,"9018":{"15002":{"9003":[65579,65581,65580]}}}

Does somebody have an idea to try?

reboot returns 4.05

coap-client v4.1.2 -- a small CoAP implementation

GW Version: 1.11.51

Hi,
calling "coaps://$IP:5684/15011/9030" (gateway reboot) returns a 4.05 which is from my understanding a Method Not Allowed Error.
Calling other methods like /15011/15012 works fine.

Please let me know, if you need any kind of other output or other information.

Thanks & cheers,
Lennart

Group key numbers

I had a question regarding the numbers that are as key mentioned in the retrieval of the groups.
For instance I've got the following list already:

{
    5850: "status"
    5851: "brightness"
    9001: "name"
    9002: "???"
    9003: "group_id"
    9018: { // items in group
        15002: {…} // 15002 is what then? Sub group? No endpoint for that
    }
    9039: "???"
    9108: "???"
}

Maybe you can clearify some data? It's sad that there's no proper documentation for this yet.

aws connection

Hi,

I discovered that the google assistance can turn on/off bulbs even if the wifi is off. And the outside internet shouldn't have a direct connection into my home network. So there seems to exist a connection from the gateway into internet. Otherwise I cannot think of how the google assistance can access my bulbs.

I found out that there is a amazonaws url in the coaps://$TF_GATEWAYIP:5684/15011/15012 | Gateway details endpoint. Did you by chance had a look?

Best
Dongha

Another guide about IKEA Tradfri gateway communication

Hi Glenn,
at first I'd like to thank you for this excellent guide. It helped me a lot to understand how the Tradfri gateway works, the meaning of the properties and how to send values!

I've written an "add-on" guide about Debugging COAPS with IKEA Tradfri gateway - my first work on Github!

In the last part of that guide there is a section that explains how to get the pre-shared key from the IKEA Home Smart app to be able to read all CoAP communication between the IKEA Home Smart app and the Tradfri gateway with Wireshark in clear text.

Documentation for Air purifier

Example for a air purifier status:

{
  "3": {
    "0": "IKEA of Sweden",
    "1": "STARKVIND Air purifier",
    "2": "",
    "3": "1.0.033",
    "6": 1,
    "7": 4364,
    "8": 0
  },
  "9001": "Luftreiniger",
  "9003": 65545,
  "9002": 1643891791,
  "9020": 1644770699,
  "9054": 0,
  "5750": 10,
  "9019": 1,
  "15025": [
    {
      "5900": 20,  # mode: 0: off, 1: auto, 10 to 50: power levels
      "5902": 6992,  # unknown
      "5903": 0,  # unknown, (completely guessed: maybe filter lifetime LED?)
      "9003": 0, 
      "5904": 259200,  # Filter maximum lifetime minutes (= 180 d)
      "5910": 252208,  # Minutes until filter replacement
      "5908": 20,  # effective mode of operation
      "5905": 0,  # 0: Control panel enabled, 1: control panel locked
      "5906": 0,  # 0: Control panel light: 0: enabled, 1: disabled
      "5907": 9,  # Air quality, turns to 65535 when device is disabled
      "5909": 7021 # unknown, similar value to 5902
    }
  ]
}

Wrong string interpolation of TF_USERNAME

Thank you for sharing your work!!

The string interpolation of $TF_USERNAME in section Authenticate of README does not work because of it is wrapped by a single quote.

It should like following:
% coap-client -m post -u "Client_identity" -k "$TF_GATEWAYCODE" -e "{\"9090\":\"$TF_USERNAME\"}" "coaps://$TF_GATEWAYIP:5684/15011/9063"

Notification when status of light changes

Hi,

Is there a way to get "notified" when the status (scene, on/of, dimmer) of a lightbulb change. Or is it necessary to constantly ask the endpoint what the status is?

Want to use this on my smart mirror to display the light status, I have seen some apps where it updates almost immediately after you press the hardware IKEA button.

Possible to get the Bulb Type?

Hello Glenn,

I'm still working on my module.
In the category there are Bulb with different white, Bulb with Colors or transformers.

Is it possible to find out, which device is connected without analyze the parameter from device Info:
[3] => stdClass Object
(
[0] => IKEA of Sweden
[1] => TRADFRI bulb E14 CWS opal 600lm
Maybe I can read the "CWS" to know this bulb can colors and the "WS" when it is only different white but that look not very professional.
I want to change the controls dependent of the exact device...
Here a big list: http://sprunge.us/CCQF
But I don't find what I'm searching for, do you know whats the best way?

Joachim

Documentation for the DEVICE (3) key

Hi Glenn,

I was wondering if you have ever looked into the DEVICE (3) key; each device has an extra data array 3, with some device data.
By looking at different sources and common sense I documented the following items myself;

    // 3.0 = Manufacturer
    // 3.1 = Product name
    // 3.2 = always empty?
    // 3.3 = firmware version
    // 3.6 = 1 or 3? (looks to be 3 always whenever a battery is present on my devices. 1 when not)
    // 3.7 = Product group ID? (this is a guess)
    // 3.9 = Battery level

If you like I can give you some additional data about my smart home devices.

HEX colors

Hello,

The HEX colors doesn't work by me. How can I fix this?

lib-coap error on install on WIndows

Hey, I'm trying to install libcoap on Windows right now. I have VisualStudio 2019 and OpenSSL installed. Unfortunately, I always get the error that the following file is missing.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(240,5):

Probably the error is on my side. Can someone help me with this? Thanks a lot

Possible Bug in RGB Bulb Firmware (v. 2.3.086)

There may be a bug in the latest firmware of the RGB Bulb "TRADFRI bulb E14 CWS opal 600lm" that causes it to completely turn off when setting red colours via HSV (as used by the Home Assistant Tradfri integration). I'm not sure how they calculate the HSV values but I suspect that they use the UINT16 range as a scale (0 = 0%, 65535 = 100%). However, when passing any value above 65278 for Hue ("5707"), it just turns off. I detected that because Home Assistant always uses HSV values and passes e.g. '5708': 65279, '5707': 65535 for full red colour.

My assumption is that they use this convention to calculate HSV values:

HUE = VAL_5707 / 65535 * 360
SAT = VAL_5708 / 65535 * 100

Example:

$ coap-client -m put -u "$COAP_USER" -k "$COAP_PW" "coaps://$TF_GATEWAY/15001/65540" -e '{"3311": [{"5850": 1, "5708": 65535, "5707": 65279}]}'

Ideally this would set the bulb to a deep red, instead it will lead to the bulb being physically off but reporting as on ("5850": 1):

$ coap-client -m get -u "$COAP_USER" -k "$COAP_PW" "coaps://$TF_GATEWAY/15001/65540"
{
  "9001": "TRADFRI bulb 3",
  "3": {
    "0": "IKEA of Sweden",
    "1": "TRADFRI bulb E14 CWS opal 600lm",
    "2": "",
    "3": "2.3.086",
    "6": 1,
    "7": 10243,
    "8": 3
  },
  "9003": 65540,
  "9002": 1629536890,
  "9020": 1644754054,
  "9054": 0,
  "9019": 1,
  "5750": 2,
  "3311": [
    {
      "5710": 0,
      "5850": 1,
      "5849": 2,
      "5851": 224,
      "5707": 65279,
      "5708": 65535,
      "5709": 0,
      "5706": "f1e0b5",
      "9003": 0
    }
  ]
}

Also note the HEX color code "5706": "f1e0b5", which is something like beige (maybe a default colour).

They must have introduced this behaviour in the last FW update because until then my automations were working.

Maybe this would be worth mentioning in the documentation?

Possible to get the Preshared Key?

Hello Glenn,

many thanks for your very good documentation and the examples!

Is it possible to get the Preshared Key for a given Username or to control if the Preshared Key for the given Username is still guilty?

Joachim

Limited colors

Awesome, thanks for this info.
I found that unfortunately only the hex values listed seen to be supported - writing any other value defaults to 'efd275': 'Warm glow',

But querying the bulb also gives changing values for 5707, 5708, 5709, 5710 - using a "remote control"'s )>) button to change color, I get these 9 settings:

"3311":[{"5850":1,"5851":254,"5707":5309, "5708":52400,"5709":32886,"5710":27217,"5706":"efd275","9003":0}]
"3311":[{"5850":1,"5851":254,"5707":4980, "5708":62974,"5709":35848,"5710":26214,"5706":"ebb63e","9003":0}]
"3311":[{"5850":1,"5851":254,"5707":4137, "5708":65279,"5709":38011,"5710":24904,"5706":"e78834","9003":0}]
"3311":[{"5850":1,"5851":254,"5707":1490, "5708":61206,"5709":40632,"5710":22282,"5706":"da5d41","9003":0}]
"3311":[{"5850":1,"5851":254,"5707":59789,"5708":65279,"5709":32768,"5710":15729,"5706":"d9337c","9003":0}]
"3311":[{"5850":1,"5851":254,"5707":55784,"5708":44554,"5709":22282,"5710":12452,"5706":"c984bb","9003":0}]
"3311":[{"5850":1,"5851":254,"5707":47324,"5708":51774,"5709":13107,"5710":6554, "5706":"6c83ba","9003":0}]
"3311":[{"5850":1,"5851":254,"5707":5427, "5708":42596,"5709":30015,"5710":26870,"5706":"f1e0b5","9003":0}]
"3311":[{"5850":1,"5851":254,"5707":5800, "5708":24394,"5709":25022,"5710":24884,"5706":"f5faf6","9003":0}]

Changing 5707 and 5708 does not seem to have an effect.
5709 seems to affect warmth, i.e. higher values approach red.
5710 seems to affect green, i.e. higher values approach green.

The app "Hue Essentials" must have figured it out, as it allows specifying a (HEX) color, achieving what could be a full red (#ff0000):

"3311":[{"5850":1,"5851":254,"5707":0,"5708":65279,"5709":45914,"5710":19615,"5706":"0","9003":0}]


From http://sprunge.us/CCQF via http://jaimejim.github.io/tradfri/:
    public static final String COLOR = "5706";
    public static final String COLOR_X = "5709";
    public static final String COLOR_Y = "5710";

Which probably is CIE xy chromaticity - https://en.wikipedia.org/wiki/CIE_1931_color_space#CIE_xy_chromaticity_diagram_and_the_CIE_xyY_color_space


Also see https://github.com/ffleurey/ThingML-Tradfri

Transition Time is not a Float

Hi,

Transitions are ignored when sending commands to Tradfri lights with transition times as float values eg. 10.5 - the light jumps to the specified setting instantly. Integer values work fine.

This leads me to believe that the Transition Time (key 5712) is of type Int and not Float (as written in the documentation), like most of the other parameters.

Scenes use clarification

Hello @glenndehaan,

That you for the docs, they have been very useful!

A bit of context: I have 2 scenes, both belong to the "SuperGroup". First of all, the status of the scenes always comes as "active - true", which when all lights are off, I would assume that is wrong. But I have the idea that you have mentioned this somewhere in the docs that is a common bug.

The problem that i am encountering is that when i activate one scene, all devices seem to be affected, not only the ones listed in the scene... But when I activate the scene from the IKEA app, the scene behaves as expected.

In your experience, do you know what could be happening?

Key expires in spite of using it

Please note: this key will expire if you don't use it in 6 weeks from activation. Every time you use this key the time will be extended accordingly.

Although I use the key twice each day, every 6 weeks I get

Jun 30 11:09:28 ALRT 115 invalidate peer
Jun 30 11:09:28 WARN received alert, peer has been invalidated
Aug 18 12:00:00 ALRT 115 invalidate peer
Aug 18 12:00:00 WARN received alert, peer has been invalidated

and I have to add another user. Am I missing something?

Try RGB-Colors but failed

Hello Glenn,

may be you see want is wong, but for me the RGB-command failed.
I try your example:
coap-client -m put -u "$TF_USERNAME" -k "$TF_PRESHARED_KEY" -e '{ "3311": ["5709": 65535, "5710": 65535] }' "coaps://$TF_GATEWAYIP:5684/15001/$TF_DEVICEID"
to adapt for me:
coap-client -m put -u "myusername" -k "mykey" -e '{ "3311": ["5709": 65535, "5710": 65535] }' "coaps://192.168.178.52:5684/15001/65538"
but I get this return:
v:1 t:CON c:PUT i:2312 {} [ ] decrypt_verify(): found 24 bytes cleartext decrypt_verify(): found 15 bytes cleartext 5.00 {"r":"07"}
I think that 5.00 {"r":"07"} should show me that something is wrong, but I don't see it...

Joachim

Build with 4.3.0 final?

I tried changing the link to the 4.3.0 release.
But the script doesn't work with that version.
Building the RC version works fine.
Can the script be changed to work with the 4.3.0 final version?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.