Azure IoT Edge support for IKEA Trådfri/Tradfri. The functionality is limited to lights and switches.
This IoT Edge module is available as Docker container.
This Docker module is optimized for Azure IoT Edge:
docker pull svelde/iot-edge-tradfri:0.5.8-windows-amd64
docker pull svelde/iot-edge-tradfri:0.5.9-arm32v7
docker pull svelde/iot-edge-tradfri:0.5.8-amd64
Note: This module is tested using the amd64 version. The Raspberry PI version (arm32) functionality is confirmed.
At this moment, the module supports:
This is a work in progress. Please support with:
Start by setting up an IoT Edge device. Use one of these quick starts.
Fill in the desired properties of the IoT Edge:
{
"properties.desired": {
"gatewayName": "[your gateway name]",
"ipAddress": "[the ip address of your hub]"
}
}
Then call the 'generateAppSecret' direct method. Pass the "gateway secret" key, found on the back of your Trådfri hub. The body of the Direct Method 'generateAppSecret' should look like:
{
"gatewaySecret": "[key of the back of your hub]"
}
Note: the name of the module will be used as the application name.
The returned "application secret" has to be filled in in the desired property:
The desired properties will look like:
{
"properties.desired": {
"gatewayName": "[your gateway name]",
"ipAddress": "[the ip address of your hub]",
"appSecret": "[the generated app secret]"
}
}
Once the desired properties are passed, the module will connect with the hub and collect information.
Lights can be controlled individually or as a group.
State, brightness, and color of lights can be set. Mood is not available yet in groups.
See also the methods below.
The following properties are used:
It's recommended to have the interval set to two minutes. By default, device events are disabled.
The following Direct Methods are offered:
The input is:
public class GenerateAppSecretRequest
{
public string gatewaySecret {get; set;}
}
Note: The gateway secret can be found on the back of your Trådfri hub.
The output is :
public class GenerateAppSecretResponse
{
public string appSecret {get; set;}
public string errorMessage { get; set; }
}
Fill in this appSecret in the related Desired Property.
Collection information can take up to a few minutes. Please adjust the timeout settings accordingly.
The input format is empty:
{
"filter": "[Group IDs]"
}
Note: You can pass multiple Group IDs (separated by some separator) to filter the list of groups.
The output format is:
public class CollectInformationResponse : CollectedInformation
{
public int responseState { get; set; }
}
public class CollectedInformation
{
public Dictionary<long, Group> groups {get; private set;}
}
public class Group
{
public string name { get; set; }
public long lightState { get; set; }
public long activeMood {get; set;}
public Dictionary<long, Device> devices {get; private set;}
}
public class Device
{
public string deviceType { get; set; }
public string deviceTypeExt { get; set; }
public string name { get; set; }
public long battery { get; set; }
public DateTime lastSeen { get; set; }
public string reachableState { get; set; }
public long dimmer { get; set; }
public string state { get; set; }
public string colorHex { get; set; }
public string serial { get; set; }
public string firmwareVersion { get; set; }
public string powerSource { get; set; }
}
This is an example of the response:
{
"status": 200,
"payload": {
"responseState": 0,
"groups": {
131090: {
"name": "Main room",
"lightState": 0,
"activeMood": 196659,
"devices": {
65593: {
"deviceType": "Remote",
"deviceTypeExt": "TRADFRI remote control",
"name": "Remote main room",
"battery": 34,
"lastSeen": "2019-11-12T21:33:32Z",
"reachableState": "1",
"dimmer": 0,
"state": null,
"colorHex": null,
"serial": "",
"firmwareVersion": "2.3.014",
"powerSource": "InternalBattery"
},
65594: {
"deviceType": "Light",
"deviceTypeExt": "TRADFRI bulb GU10 WS 400lm",
"name": "My mood light",
"battery": 0,
"lastSeen": "2019-11-12T19:58:08Z",
"reachableState": "0",
"dimmer": 220,
"state": "True",
"colorHex": "f1e0b5",
"serial": "",
"firmwareVersion": "2.0.022",
"powerSource": "InternalBattery"
}
}
}
}
}
}
The input is empty:
{}
The output is:
public class GatewayInfoResponse
{
public int responseState { get; set; }
public string errorMessage { get; set; }
public long commissioningMode { get; set; }
public string currentTimeISO8601 { get; set; }
public string firmware { get; set; }
public string gatewayID { get; set; }
public long gatewayTimeSource { get; set; }
public long gatewayUpdateProgress { get; set; }
public string homekitID { get; set; }
public string ntp { get; set; }
public long otaType { get; set; }
public long OtaUpdateState { get; set; }
}
The input is empty:
{}
The output is:
public class RebootResponse
{
public int responseState { get; set; }
public string errorMessage { get; set; }
}
Note: After this method is sent, the Hub is actually rebooting. This takes some time. You have to reconnect later before you can continue to work with the hub.
Sometimes other direct methods result in a timeout. The most likely reason is that another application has changed the properties of a device. In that case, reconnect using this method.
The input is empty:
{}
The output is:
public class ReconnectResponse
{
public int responseState { get; set; }
public string errorMessage { get; set; }
}
The input is:
public class SetLightRequest
{
public long id { get; set; }
public bool? turnLightOn { get; set; }
public string color { get; set; }
public int? brightness { get; set; }
}
The output is:
public class SetLightResponse
{
public int responseState { get; set; }
public string errorMessage { get; set; }
}
The input is:
public class SetLightRequest
{
public long id { get; set; }
public bool? turnLightOn { get; set; }
public int? brightness { get; set; }
}
The output is:
public class SetGroupResponse
{
public int responseState { get; set; }
public string errorMessage { get; set; }
}
Changes/events on devices are made available as messages on route 'output1'.
This is the output format:
{
"id": 65589,
"name": "Bulb living room",
"state": "True",
"brightness": 86,
"colorHex": "efd275"
"groupId": 1234,
"groupName": "Living room",
"lastSeen": "2019-11-21T18:33:46Z"
}
Note: recieving these messages is only possible when the desired property 'interval' is set.
The logic in this module is based on https://github.com/tomidix/CSharpTradFriLibrary.
This module is trying to honor all rights of Ikea regarding Trådfri.
Content type
Image
Digest
Size
129.8 MB
Last updated
almost 6 years ago
docker pull svelde/iot-edge-tradfri:0.5.21-windows-amd64