{"id":19426018,"url":"https://github.com/stackia/aqara-agent2mqtt","last_synced_at":"2025-02-25T05:15:31.630Z","repository":{"id":229221415,"uuid":"776159985","full_name":"stackia/aqara-agent2mqtt","owner":"stackia","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-11T09:28:23.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-07T19:35:11.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-22T19:58:18.000Z","updated_at":"2024-03-22T19:58:45.000Z","dependencies_parsed_at":"2024-03-22T21:24:46.482Z","dependency_job_id":"4bbec7cb-a83f-451f-a8a5-47ae5e46cf43","html_url":"https://github.com/stackia/aqara-agent2mqtt","commit_stats":null,"previous_names":["stackia/aqara-agent2mqtt"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackia%2Faqara-agent2mqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackia%2Faqara-agent2mqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackia%2Faqara-agent2mqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackia%2Faqara-agent2mqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackia","download_url":"https://codeload.github.com/stackia/aqara-agent2mqtt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240605842,"owners_count":19827985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T14:05:40.648Z","updated_at":"2025-02-25T05:15:31.584Z","avatar_url":"https://github.com/stackia.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ha_agent to MQTT for Aqara Gateway Hubs (M2/G3/etc.)\n\nUse [cross](https://github.com/cross-rs/cross) to build, or grab a prebuilt binary at [Releases](https://github.com/stackia/aqara-agent2mqtt/releases).\n\n```shell\ncross build --target armv7-unknown-linux-gnueabihf --release\n```\n\nUpload the built binary `target/armv7-unknown-linux-gnueabihf/release/aqara-agent2mqtt` to your Aqara Hubs (need to enable telnet first).\n\nTo start `aqara-agent2mqtt` automatically, append these to your `post_init.sh`:\n\n```shell\nif [ -f /data/bin/aqara-agent2mqtt ]; then\n  nohup /data/bin/aqara-agent2mqtt \u003e /dev/null 2\u003e\u00261 \u0026\nfi\n```\n\nAll writes to the `agent/command` MQTT topic will be send to `ha_agent`. And all responses/reports from `ha_agent` will be write to `agent/response` MQTT topic.\n\nHere are some possible commands:\n\n- Modify resources under the gateway:\n\n```jsonc\n{\n  \"_to\": 4,\n  \"id\": 123,\n  \"method\": \"auto.control\",\n  \"params\": {\n    \"name\": \"/lumi/gw/res/write\",\n    \"value\": {\n      \"data\": {\n        // e.g. emit IR sequence on G3\n        \"8.0.2092\": \"{\\\"mode\\\":0,\\\"len\\\":311,\\\"ircode\\\":\\\"nE5mk0lk0mc5m0sm0xnMsmswADKbTCWTGbTQBA5uAgk2mMzlk1mMxAHIBgprOZxLJsAoUxm0wmQCJTEBkgEFmoHxTaYTcBhgCCAQoDsphOACHAZWaziaSyazMDogZCBUKZgEFNQCDAVIBkpjNpkCIc2BdUBkgf3moRZAqSEgc2mEwCQWazkKowkDAqebgDlNgVFCIoCpAs7BlMJBwQjAgQNw5xLJpMZlMJrLJxOZrOJZMpjNwRiEKOYAAEA=\\\"}\"\n      },\n      \"did\": \"lumi1.54ef12345678\",\n      \"source\": \"\"\n    }\n  }\n}\n```\n\n- Let your gateway connect to other gateways in the LAN, so you can send `lanbox.control` commands (see below) to them.\n\n```jsonc\n{\n  \"_to\": 524288,\n  \"id\": 123,\n  \"method\": \"lanbox.event\",\n  \"params\": {\n    \"name\": \"hub_interest\",\n    \"value\": { \"hublist\": [\"lumi1.54ef12345678\"], \"task\": 0 }\n  }\n}\n```\n\n- Modify resources of another gateway in the LAN\n\n```jsonc\n{\n  \"_to\": 524288,\n  \"id\": 123,\n  \"method\": \"lanbox.control\",\n  \"params\": {\n    \"name\": \"write\",\n    \"value\": {\n      \"did\": \"lumi1.54ef12345678\", // target gateway\n      \"sdid\": \"lumi1.54ef12345678\", // subdevice\n      \"src\": \"\",\n      \"task\": 0,\n      \"value\": { \"4.3.85\": \"2\" } // e.g. toggles a switch (0 = off, 1 = on, 2 = toggle)\n    }\n  }\n}\n```\n\n- Read resources of another gateway in the LAN\n\n```jsonc\n{\n  \"_to\": 524288,\n  \"id\": 123,\n  \"method\": \"lanbox.control\",\n  \"params\": {\n    \"name\": \"read\",\n    \"value\": {\n      \"did\": \"lumi1.54ef12345678\", // target gateway\n      \"sdid\": \"lumi1.54ef12345678\", // subdevice\n      \"value\": [\"0.4.85\"] // e.g. get current lux of the FP2\n    }\n  }\n}\n```\n\nIf success, response will be reflected in `agent/response` topic:\n\n```jsonc\n// response\n{\n  \"_from\": 524288,\n  \"id\": 123,\n  \"method\": \"lanbox.event\",\n  \"params\": {\n    \"name\": \"read_done\",\n    \"value\": {\n      \"did\": \"lumi1.54ef12345678\",\n      \"result\": { \"0.4.85\": \"250\" },\n      \"sdid\": \"lumi1.54ef12345678\",\n      \"task\": 0\n    }\n  }\n}\n```\n\n- Subscribe/unsubscribe to resources of other gateways in the LAN\n  - There are some caveats - you must first have an automation rule in Aqara app that takes at least two conditions. The first condition must come from a subdevice of this gateway (or this gateway itself). The other condition must be set to any subdevice of the gateway (or the gateway itself) you want LAN control.\n\n```jsonc\n{\n  \"_to\": 524288,\n  \"id\": 123,\n  \"method\": \"lanbox.control\",\n  \"params\": {\n    \"name\": \"ifttt\",\n    \"value\": {\n      \"did\": \"lumi1.54ef12345678\", // target gateway\n      \"name\": \"/lumi/lan/sync/subscribe\",\n      \"task\": 0,\n      \"value\": {\n        \"data\": [{ \"did\": \"lumi1.54ef12345678\", \"rids\": [\"3.51.85\"] }], // subdevice\n        \"pid\": \"lumi1.54ef12345678\", // this gateway\n        \"time\": 1711109131384\n      }\n    }\n  }\n}\n```\n\n```jsonc\n{\n  \"_to\": 524288,\n  \"id\": 123,\n  \"method\": \"lanbox.control\",\n  \"params\": {\n    \"name\": \"ifttt\",\n    \"value\": {\n      \"did\": \"lumi1.54ef12345678\", // target gateway\n      \"name\": \"/lumi/lan/sync/subscribe\",\n      \"task\": 0,\n      \"value\": {\n        \"data\": [{ \"did\": \"lumi1.54ef12345678\", \"rids\": [\"0.4.85\"] }], // subdevice\n        \"pid\": \"lumi1.54ef12345678\", // this gateway\n        \"time\": 1711133350058\n      }\n    }\n  }\n}\n```\n\n```jsonc\n{\n  \"_to\": 524288,\n  \"id\": 123,\n  \"method\": \"lanbox.control\",\n  \"params\": {\n    \"name\": \"ifttt\",\n    \"value\": {\n      \"did\": \"lumi1.54ef12345678\", // target gateway\n      \"name\": \"/lumi/lan/del/subscribe\",\n      \"task\": 0,\n      \"value\": {\n        \"data\": [\"0.4.85\"],\n        \"delSubscribeDid\": \"lumi1.54ef12345678\", // subdevice\n        \"did\": \"lumi1.54ef12345678\", // this gateway\n        \"pid\": \"lumi1.54ef12345678\" // this gateway\n      }\n    }\n  }\n}\n```\n\n```jsonc\n{\n  \"_to\": 524288,\n  \"id\": 123,\n  \"method\": \"lanbox.event\",\n  \"params\": {\n    \"name\": \"res_unsubscribe\",\n    \"value\": {\n      \"did\": \"lumi1.54ef12345678\", // target gateway\n      \"reslist\": [\"lumi1.54ef12345678\"], // subdevice\n      \"task\": 0\n    }\n  }\n}\n```\n\nIf subscribed successfully, updates to subscribed resources will be reflected in `agent/response` topic (those with `\"method\": \"auto.forward\"`).\n\nBe aware that resource values for `auto.forward` are actually the UTF-8 Hex representation of the original value. So `\"0.4.85\":\"323530\"` actually means `\"0.4.85\":\"250\"`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackia%2Faqara-agent2mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackia%2Faqara-agent2mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackia%2Faqara-agent2mqtt/lists"}