Skip to content

alexnederlof/tradfri-mqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tradfri to MQTT

This is a simple application that subscribes to a Tradfri gateway, and then publishes updates to MQTT.

It will push all known devices as

<prefix>/<device_type>/<device_id>/<property> = <value>

For example

ikea/plug/65539/powerFactor: 0

Currently this app supports:

  • Plugs
  • Lights
  • Air purifiers
  • Blinds

Note that motion detectors are not supported by Ikea at all at the moment.

The app also does not support scenes, and neither can you send commands to Ikea. Pull requests are welcome if people want to add this functionality.

Authenticating

When run the first time, you need to create an auth.json for this service, and re-use that every time. It seems like the gateway has a limited number of auth tokens it hands out, so others get logged out when you create new ones.

On the back of your gateway, you'll find a security code, you'll need this along side the IP or hostname to login.

To authenticate:

  • From the source code, run yarn auth <gateway_ip> <psk>
  • With docker, run docker run ghcr.io/alexnederlof/tradfri-mqtt auth <gateway_ip> <psk>

Not the identity and psk it returns, and use that in the configuration below.

Configuration

The following items need to be configured.

Key Value Required or default
MQTT_ADDRESS IP or hostname of MQTT service Required
MQTT_USER MQTT Username Default: No user/pass by default
MQTT_PASSWORD MQTT Password Default: No user/pass by default
MQTT_TOPIC_PREFIX the prefix for MQTT Topics tradfri
TRADFRI_GATEWAY hostname or IP address of your Tradfri gateway required
TRADFRI_IDENTITY The identity generated by the gateway required
TRADFRI_PSK The PSK generated by the gateway required

On startup a .env file is also read in case you want to configure by file.