All Projects → hemtjanst → tradfri-mqtt

hemtjanst / tradfri-mqtt

Licence: Apache-2.0 License
Mirrors Trådfri gateways endpoints into MQTT and send commands to the gateway from MQTT

Programming Languages

typescript
32286 projects
Dockerfile
14818 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to tradfri-mqtt

Homepoint
Espressif ESP32 Based Smarthome screen for MQTT
Stars: ✭ 391 (+1403.85%)
Mutual labels:  home-automation, mqtt, smarthome
Awesome Home Assistant
A curated list of amazingly awesome Home Assistant resources.
Stars: ✭ 3,487 (+13311.54%)
Mutual labels:  home-automation, mqtt, smarthome
Smarthome
Device integration platform for your smart home
Stars: ✭ 92 (+253.85%)
Mutual labels:  home-automation, mqtt, smarthome
Zigbee2mqttassistant
GUI for Zigbee2Mqtt running in docker and HASS.IO
Stars: ✭ 371 (+1326.92%)
Mutual labels:  home-automation, mqtt, smarthome
Redmatic
Node-RED packaged as Addon for the Homematic CCU3 and RaspberryMatic 🤹‍♂️
Stars: ✭ 407 (+1465.38%)
Mutual labels:  home-automation, mqtt, smarthome
Hodd
Homie Device Discovery
Stars: ✭ 21 (-19.23%)
Mutual labels:  home-automation, mqtt, smarthome
Ct Smart Home
A ready-to-use Node-RED setup for home automation
Stars: ✭ 132 (+407.69%)
Mutual labels:  home-automation, mqtt, smarthome
rpi2mqtt
Connect RaspberryPi GPIOs and 1-Wire temperature sensors to MQTT 🍰🔘📡
Stars: ✭ 20 (-23.08%)
Mutual labels:  mqtt, smarthome
libzwaveip
libzwaveip - Control Z-Wave devices from your IP network
Stars: ✭ 76 (+192.31%)
Mutual labels:  home-automation, smarthome
ioBroker.cloud
Enable access to ioBroker from internet
Stars: ✭ 36 (+38.46%)
Mutual labels:  home-automation, smarthome
soma-ctrl
Node util for controlling SOMA smart shade via MQTT or HTTP
Stars: ✭ 19 (-26.92%)
Mutual labels:  home-automation, mqtt
ccu-addon-mosquitto
Mosquitto packaged as Addon for the Homematic CCU3 and RaspberryMatic
Stars: ✭ 23 (-11.54%)
Mutual labels:  mqtt, smarthome
homely
🏠 - A bunch of mosquittos. IoT wiring and notification framework, with an unix style.
Stars: ✭ 15 (-42.31%)
Mutual labels:  home-automation, mqtt
server
MyController 2.x server
Stars: ✭ 14 (-46.15%)
Mutual labels:  home-automation, mqtt
ioBroker.jarvis
jarvis - just another remarkable vis
Stars: ✭ 129 (+396.15%)
Mutual labels:  home-automation, smarthome
texecom2mqtt-hassio
Home Assistant add-on. Connect to Texecom Premier Elite alarm panels and publish updates to MQTT. Supports arming/disarming as well as zone updates and alarm events.
Stars: ✭ 15 (-42.31%)
Mutual labels:  home-automation, mqtt
ad-alexatalkingclock
Alexa (or other Smart Speakers) tell you the time without asking every hour. Please ⭐️if you like my app :)
Stars: ✭ 30 (+15.38%)
Mutual labels:  home-automation, smarthome
GoogleSpeak
No description or website provided.
Stars: ✭ 14 (-46.15%)
Mutual labels:  home-automation, mqtt
WeConnect-mqtt
MQTT Client that publishes data from Volkswagen WeConnect
Stars: ✭ 14 (-46.15%)
Mutual labels:  mqtt, smarthome
Home-Assistant-Main
My Home Assistant Configuration Be sure to ⭐ my repo so you can keep up to date on the daily progress!
Stars: ✭ 54 (+107.69%)
Mutual labels:  home-automation, smarthome

Trådfri-MQTT

This project mirrors most of the Trådfri gateways endpoints into MQTT and can be used to send commands to the Trådfri gateway over MQTT

See hemtjan.st/tradfri-mqtt for more information

Using NPM

Installing via NPM:

npm install -g tradfri-mqtt

To start the service:

# 192.168.0.99 = Your trådfri gateway
# abcdefgh = The pre-shared key printed under the gateway
# tcp://127.0.0.1:1883 = Address to MQTT

tradfri-mqtt -g 192.168.0.99 -p abcdefgh -a tcp://127.0.0.1:1883

Using docker

docker volume create tradfri-mqtt-data
docker run -d \
  --name tradfri-mqtt \
  --volume tradfri-mqtt-data:/data \
  --env TRADFRI_GATEWAY=192.168.0.99 \
  --env TRADFRI_PSK=abcdefgh \
  --env MQTT_ADDRESS=tcp://127.0.0.1:1883 \
  hemtjanst/tradfri-mqtt

For armv7 (i.e. raspberry pi 3+), use hemtjanst/tradfri-mqtt:arm7

Arguments

Argument Alias Environment Var Description Default
--gateway <ip> -g TRADFRI_GATEWAY IP Address of Trådfri Gateway Required
--psk <key> -p TRADFRI_PSK Pre-shared key of gateway
--mqtt tcp://mqtt-broker:1883 -a MQTT_ADDRESS Address of MQTT broker Required
--mqttUsername foo -n MQTT_USERNAME Username of MQTT broker
--mqttPassword bar -w MQTT_PASSWORD Password of MQTT broker
--topicPrefix <topic> -x MQTT_TOPIC_PREFIX Topic prefix tradfri-raw
--topicCommand <topic> -c MQTT_TOPIC_CMD Topic for commands tradfri-cmd
--username <username> -u TRADFRI_USERNAME Username for authentication token
--token <token> -t TRADFRI_TOKEN Authentication token (not the same as PSK!)
--storage <path> -s TRADFRI_STORAGE Path to store data in

Getting updates

tradfri-mqtt will try to observe everything that's being published from the gateway, and mirror the messages into MQTT with the prefix tradfri-raw/.

For example, if the trådfri pushes and update for the lightbulb 65554, the raw json message will be published to the MQTT topic tradfri-raw/15001/65554.

Subscribing to tradfri-raw/# will give you all messages, tradfri-raw/15001/# all accessory updates and tradfri-raw/15004/# all group updates.

Sending commands

Commands to the trådfri gateway can be sent by publishing them to the MQTT topic tradfri-cmd. The payload should be a json-encoded string matching the definition:

export declare type TfCommand = {
    // CoAP Method
    method: "get" | "post" | "put" | "delete" | "reset",
    // URL without any prefixes, i.e. "15001/65540"
    url: string,
    // Optional id of the request, will be included in the reply
    id?: string,
    // Replies will be sent to this MQTT topic
    replyTopic?: string,
    // Payload of the request (for POST or PUT)
    payload?: object|string,
}

If replyTopic is set, a reply will be sent to that topic. The definition of the reply:

export declare type TfReply = {
    // ID of the request as set in TfCommand
    id?: string,
    // Response code, for example "2.04"
    code: string,
    // Format of the response, 50 = json
    format: number,
    // Payload, if format is json the payload is decoded into an object,
    // otherwise it will be a raw string
    payload: string|object,
}

Sample requests

Put request

Sent to the tradfri-cmd topic:

{
  "method": "put",
  "url": "15004/162515",
  "id": "group-set-on",
  "replyTopic": "tradfri-reply/xyz",
  "payload": {
    "5850": 1
  }
}

Received from the tradfri-reply/xyz topic:

{
  "id": "group-set-on",
  "code": "2.04",
  "format": null,
  "payload": ""
}

Get request

Sent to the tradfri-cmd topic:

{
  "method": "get",
  "url": "15004/162515",
  "id": "group-get",
  "replyTopic": "tradfri-reply/xyz"
}

Received from the tradfri-reply/xyz topic:

{
  "id": "group-get",
  "code": "2.05",
  "format": 50,
  "payload": {
    "5850": 1,
    "5851": 0,
    "9001": "Name of group",
    "9002": 1498068278,
    "9003": 162515,
    "9018": {
      "15002": {
        "9003": [65546,65547,65548]
      }
    },
    "9039": 220248
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].