{"id":18006530,"url":"https://github.com/jimm98y/xiaomimiapi","last_synced_at":"2025-04-04T11:40:42.044Z","repository":{"id":151640399,"uuid":"597436409","full_name":"jimm98y/XiaomiMiAPI","owner":"jimm98y","description":"Client to control Xiaomi Mi Smart LED Lamp Pro","archived":false,"fork":false,"pushed_at":"2023-04-07T23:29:53.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T21:30:51.761Z","etag":null,"topics":["lamp","netstandard","smarthome"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jimm98y.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-02-04T14:50:03.000Z","updated_at":"2023-03-04T15:06:31.000Z","dependencies_parsed_at":"2023-05-25T17:15:23.179Z","dependency_job_id":null,"html_url":"https://github.com/jimm98y/XiaomiMiAPI","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimm98y%2FXiaomiMiAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimm98y%2FXiaomiMiAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimm98y%2FXiaomiMiAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimm98y%2FXiaomiMiAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jimm98y","download_url":"https://codeload.github.com/jimm98y/XiaomiMiAPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174368,"owners_count":20896074,"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":["lamp","netstandard","smarthome"],"created_at":"2024-10-30T01:08:45.841Z","updated_at":"2025-04-04T11:40:42.019Z","avatar_url":"https://github.com/jimm98y.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XiaomiMiAPI\nA client to control the Xiaomi Mi Smart LED Lamp Pro. \n\n## Disclaimer\nIt might work with other Xiaomi Mi devices, but I have no way to test them so they are not officially supported.\n\n## Yeelight Client\nTo control the smart lamp use the YeelightClient. The client was implemented using the official documentation here: https://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf. \n\nCreate the Yeelight client:\n```cs\nvar yeelightClient = new YeelightClient();\n```\n\nConnect to the lamp using a device token:\n```cs\nawait yeelightClient.ConnectAsync(\"192.168.1.12\", \"abcd123456789\");\n```\nIn the hotspot mode when the lamp creates a Wi-Fi hotspot used for configuration, you can pass `null` instead of the token. The code can get the token from the lamp in this mode and you can also control the lamp. \n```cs\nawait yeelightClient.ConnectAsync(\"192.168.1.12\", null);\n```\nHowever, after you configure the lamp to connect to the Wi-Fi network, the lamp re-generates the initial token and it is no longer possible to retrieve it from the lamp. The new token can be only retrieved from the Mi cloud, which means you have to use the official app to link the lamp with your Mi account. To retrieve the token from the cloud, use `MiCloudClient`.\n\nControl the lamp:\n```cs\nawait yeelightClient.ToggleAsync();\n```\n## Mi Cloud Client\nTo get the token to pass into the `YeelightClient` you can use the extractor as follows:\n```cs\nvar miCloudClient = new MiCloudClient();\nvar homes = await miCloudClient.DiscoverDevicesAsync(\"+444123456789\", \"mySecretPassword\");\nstring token = homes.First().Devices.First().Token;\n```\n## Token\nOnce you retrieve the token, you can store it somewhere safe and block the lamp from accessing the Internet. The `YeelightClient` communicates with the lamp locally and the token remains valid until you reset/disconnect/reconnect the lamp to the Wi-Fi.\n\n## Credits\nThe `MiCloudClient` is just a C# port of the great work from Piotr Machowski: https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimm98y%2Fxiaomimiapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjimm98y%2Fxiaomimiapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimm98y%2Fxiaomimiapi/lists"}