{"analyzedAt":"2022-06-28T02:52:10.209Z","collected":{"metadata":{"name":"tradfri-mqtt","scope":"unscoped","version":"0.1.4","description":"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","keywords":["tradfri","mqtt","hemtjanst"],"date":"2021-07-05T13:31:18.436Z","author":{"name":"bonan","email":"npm@bonan.se","username":"bonan"},"publisher":{"username":"bonan","email":"npm@bonan.se"},"maintainers":[{"username":"bonan","email":"npm@bonan.se"}],"contributors":[{"name":"bonan","email":"npm@bonan.se"}],"repository":{"type":"git","url":"git+https://github.com/hemtjanst/tradfri-mqtt.git"},"links":{"npm":"https://www.npmjs.com/package/tradfri-mqtt","homepage":"https://github.com/hemtjanst/tradfri-mqtt","repository":"https://github.com/hemtjanst/tradfri-mqtt","bugs":"https://github.com/hemtjanst/tradfri-mqtt/issues"},"license":"Apache-2.0","dependencies":{"command-line-args":"^5.1.1","command-line-usage":"^6.1.1","debug":"^4.1.1","mqtt":"^4.2.8","node-coap-client":"^2.0.1"},"devDependencies":{"@types/node":"^16.0.0","typescript":"^4.3.5"},"releases":[{"from":"2022-05-29T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":1},{"from":"2022-03-30T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":1},{"from":"2021-12-30T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":1},{"from":"2021-06-28T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":2},{"from":"2020-06-28T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":2}],"readme":"# Trådfri-MQTT\nThis project mirrors most of the Trådfri gateways endpoints into MQTT and can be\nused to send commands to the Trådfri gateway over MQTT\n\nSee [hemtjan.st/tradfri-mqtt](https://hemtjan.st/tradfri-mqtt) for more information\n\n## Using NPM\nInstalling via NPM:\n\n```bash\nnpm install -g tradfri-mqtt\n```\n\nTo start the service:\n```bash\n# 192.168.0.99 = Your trådfri gateway\n# abcdefgh = The pre-shared key printed under the gateway\n# tcp://127.0.0.1:1883 = Address to MQTT\n\ntradfri-mqtt -g 192.168.0.99 -p abcdefgh -a tcp://127.0.0.1:1883\n```\n\n## Using docker\n\n```bash\ndocker volume create tradfri-mqtt-data\ndocker run -d \\\n  --name tradfri-mqtt \\\n  --volume tradfri-mqtt-data:/data \\\n  --env TRADFRI_GATEWAY=192.168.0.99 \\\n  --env TRADFRI_PSK=abcdefgh \\\n  --env MQTT_ADDRESS=tcp://127.0.0.1:1883 \\\n  hemtjanst/tradfri-mqtt\n```\n\nFor armv7 (i.e. raspberry pi 3+), use hemtjanst/tradfri-mqtt:arm7\n\n## Arguments\n\n|Argument                       |Alias|Environment Var  |Description                                |Default      |\n|-------------------------------|-----|-----------------|-------------------------------------------|-------------|\n|`--gateway <ip>`               |`-g` |TRADFRI_GATEWAY  |IP Address of Trådfri Gateway              |**Required** |\n|`--psk <key>`                  |`-p` |TRADFRI_PSK      |Pre-shared key of gateway                  |             |\n|`--mqtt tcp://mqtt-broker:1883`|`-a` |MQTT_ADDRESS     |Address of MQTT broker                     |**Required** |\n|`--mqttUsername foo`           |`-n` |MQTT_USERNAME    |Username of MQTT broker                    |             |\n|`--mqttPassword bar`           |`-w` |MQTT_PASSWORD    |Password of MQTT broker                    |             |\n|`--topicPrefix <topic>`        |`-x` |MQTT_TOPIC_PREFIX|Topic prefix                               |`tradfri-raw`|\n|`--topicCommand <topic>`       |`-c` |MQTT_TOPIC_CMD   |Topic for commands                         |`tradfri-cmd`|\n|`--username <username>`        |`-u` |TRADFRI_USERNAME |Username for authentication token          |             |\n|`--token <token>`              |`-t` |TRADFRI_TOKEN    |Authentication token (not the same as PSK!)|             |\n|`--storage <path>`             |`-s` |TRADFRI_STORAGE  |Path to store data in                      |             |\n\n\n## Getting updates\n\ntradfri-mqtt will try to observe everything that's being published from the gateway, and mirror the messages into\nMQTT with the prefix `tradfri-raw/`.\n\nFor example, if the trådfri pushes and update for the lightbulb `65554`, the raw json message will be published\nto the MQTT topic `tradfri-raw/15001/65554`.\n\nSubscribing to `tradfri-raw/#` will give you all messages, `tradfri-raw/15001/#` all accessory\nupdates and `tradfri-raw/15004/#` all group updates.\n\n## Sending commands\n\nCommands to the trådfri gateway can be sent by publishing them to the MQTT topic `tradfri-cmd`.\nThe payload should be a json-encoded string matching the definition:\n\n```typescript\nexport declare type TfCommand = {\n    // CoAP Method\n    method: \"get\" | \"post\" | \"put\" | \"delete\" | \"reset\",\n    // URL without any prefixes, i.e. \"15001/65540\"\n    url: string,\n    // Optional id of the request, will be included in the reply\n    id?: string,\n    // Replies will be sent to this MQTT topic\n    replyTopic?: string,\n    // Payload of the request (for POST or PUT)\n    payload?: object|string,\n}\n```\n\nIf `replyTopic` is set, a reply will be sent to that topic. The definition of the reply:\n```typescript\nexport declare type TfReply = {\n    // ID of the request as set in TfCommand\n    id?: string,\n    // Response code, for example \"2.04\"\n    code: string,\n    // Format of the response, 50 = json\n    format: number,\n    // Payload, if format is json the payload is decoded into an object,\n    // otherwise it will be a raw string\n    payload: string|object,\n}\n```\n\n### Sample requests\n\n#### Put request\nSent to the `tradfri-cmd` topic:\n```json\n{\n  \"method\": \"put\",\n  \"url\": \"15004/162515\",\n  \"id\": \"group-set-on\",\n  \"replyTopic\": \"tradfri-reply/xyz\",\n  \"payload\": {\n    \"5850\": 1\n  }\n}\n```\n\nReceived from the `tradfri-reply/xyz` topic:\n```json\n{\n  \"id\": \"group-set-on\",\n  \"code\": \"2.04\",\n  \"format\": null,\n  \"payload\": \"\"\n}\n```\n\n#### Get request\n\nSent to the `tradfri-cmd` topic:\n```json\n{\n  \"method\": \"get\",\n  \"url\": \"15004/162515\",\n  \"id\": \"group-get\",\n  \"replyTopic\": \"tradfri-reply/xyz\"\n}\n```\n\nReceived from the `tradfri-reply/xyz` topic:\n```json\n{\n  \"id\": \"group-get\",\n  \"code\": \"2.05\",\n  \"format\": 50,\n  \"payload\": {\n    \"5850\": 1,\n    \"5851\": 0,\n    \"9001\": \"Name of group\",\n    \"9002\": 1498068278,\n    \"9003\": 162515,\n    \"9018\": {\n      \"15002\": {\n        \"9003\": [65546,65547,65548]\n      }\n    },\n    \"9039\": 220248\n  }\n}\n```"},"npm":{"downloads":[{"from":"2022-06-27T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":0},{"from":"2022-06-21T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":0},{"from":"2022-05-29T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":15},{"from":"2022-03-30T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":95},{"from":"2021-12-30T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":164},{"from":"2021-06-28T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":450}],"starsCount":0},"github":{"homepage":"https://hemtjan.st/tradfri-mqtt","starsCount":27,"forksCount":8,"subscribersCount":7,"issues":{"count":20,"openCount":1,"distribution":{"3600":0,"10800":3,"32400":3,"97200":4,"291600":1,"874800":0,"2624400":1,"7873200":4,"23619600":3,"70858800":1,"212576400":0},"isDisabled":false},"contributors":[{"username":"rjbez17","commitsCount":1},{"username":"cipher2k","commitsCount":1},{"username":"daenney","commitsCount":3},{"username":"benochsson","commitsCount":3},{"username":"bonan","commitsCount":18},{"username":"dependabot[bot]","commitsCount":2}],"commits":[{"from":"2022-06-21T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":0},{"from":"2022-05-29T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":0},{"from":"2022-03-30T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":0},{"from":"2021-12-30T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":0},{"from":"2021-06-28T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":4}],"statuses":[{"context":"github/pages","state":"success"}]},"source":{"files":{"readmeSize":4752,"testsSize":0,"hasNpmIgnore":true},"linters":["tslint"]}},"evaluation":{"quality":{"carefulness":0.45999999999999996,"tests":0.25,"health":1,"branding":0},"popularity":{"communityInterest":48,"downloadsCount":31.666666666666668,"downloadsAcceleration":-0.26366057838660584,"dependentsCount":0},"maintenance":{"releasesFrequency":0.7745719178082191,"commitsFrequency":0.046027397260273974,"openIssues":1,"issuesDistribution":0.6267207228535354}},"score":{"final":0.5338725633381824,"detail":{"quality":0.6779346412297937,"popularity":0.06916752707593463,"maintenance":0.875095818550478}}}