xiaomipassive


Namexiaomipassive JSON
Version 2023.2.6 PyPI version JSON
download
home_page
SummaryMiFlora and LYWSD02 passive scanner
upload_time2023-03-11 09:17:19
maintainer
docs_urlNone
author
requires_python>=3.9.0
licenseMIT License
keywords home automation xiaomi lywsd02 lywsd03 flower care
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # xiaomipassive
LYWSD02, LYWSD03MMC (custom firmware ATC) and MiFlora passive scanner
## Installation
```
git clone https://github.com/afer92/xiaomipassive.git
cd xiaomipassive
pip3 install .
```
## Command line tool
```
xiaomipassivec
```
Output:
```
mac: 80:EA:CA:89:xx:yy conductivity:   54 µS/cm (2023-02-26T00:42:25)
mac: C4:7C:8D:64:xx:yyconductivity:  837 µS/cm (2023-02-26T00:42:25)
mac: C4:7C:8D:6C:xx:yy light:          26 lux   (2023-02-26T00:42:26)
...
A4:C1:38:09:xx:yy ATC_0990AB
=================
mac: A4:C1:38:09:xx:yyB rssi:          -35 dBm   (2023-02-26T00:42:39)
mac: A4:C1:38:09:xx:yy temperature:  21.6 °C    (2023-02-26T00:42:39)
mac: A4:C1:38:09:xx:yy moisture:       32 %     (2023-02-26T00:42:39)
mac: A4:C1:38:09:xx:yyB battery:        93 %     (2023-02-26T00:42:39)
mac: A4:C1:38:09:xx:yy volt:         3.04 V     (2023-02-26T00:42:39)
```
## class XiaomiPassiveScanner
```Python
loop = asyncio.get_event_loop()
scanner = XiaomiPassiveScanner(loop, callback, timeout_seconds=240)
```
### callback
Function call at each received advertissement
```Python
def callback(self, data):
    print(self.dump_result(data))
```
Output:
```
mac: C4:7C:8D:65:xx:yy conductivity: 376 µS/cm
mac: 80:EA:CA:89:xx:yy light:        283 lux
mac: 15:03:10:12:xx:yy moisture:     47.0 %
mac: C4:7C:8D:65:xx:yy temperature:  20.8 °C
mac: E7:2E:01:71:xx:yy battery:      18 %
```
Function **dump_result** format the data decoded in an advertisement

Dictionnary **data**:
```Python
{'ok': True,
 'mac': 'C4:7C:8D:6C:xx:yy',
 'sensor': 4100,
 'stype': 'temperature',
 'svalue': ListContainer([123, 0]),
 'typeCst': ListContainer([113, 32, 152, 0]),
 'num': 247,
 'tab': 13,
 'name': 'Flower care',
 'rssi': -87,
 'value': 12.3
 }
```
### timeout_seconds
Scan for **timeout_seconds**, default=240s
### devices
After **timeout_seconds** scanning, data collected for each mac address

Function **dump_device(mac)** format the data for one mac address
```
E7:2E:01:71:xx:yy LYWSD02
=================
mac: E7:2E:01:71:xx:yy rssi:          -93 dBm   (2023-02-24T19:34:19)
mac: E7:2E:01:71:xx:yy moisture:     47.0 %     (2023-02-24T19:32:44)
mac: E7:2E:01:71:xx:yy temperature:  20.6 °C    (2023-02-24T19:34:18)
mac: E7:2E:01:71:xx:yy battery:        18 %     (2023-02-24T19:33:37)

C4:7C:8D:65:B1:1D Flower care
=================
mac: C4:7C:8D:65:xx:yy rssi:          -81 dBm   (2023-02-24T19:34:19)
mac: C4:7C:8D:65:xx:yy light:         118 lux   (2023-02-24T19:33:41)
mac: C4:7C:8D:65:xx:yy moisture:       21 %     (2023-02-24T19:33:52)
mac: C4:7C:8D:65:xx:yy conductivity:  309 µS/cm (2023-02-24T19:34:04)
mac: C4:7C:8D:65:xx:yy temperature:  20.7 °C    (2023-02-24T19:34:15)
```

## Example
```Python
#!/usr/bin/python3

from xiaomipassive import xiaomipassive as xiaomi
import asyncio

def main():

    def callback(self, result):
        print(self.dump_result(result))

    def get_data():
        loop = asyncio.get_event_loop()
        scanner = xiaomi.XiaomiPassiveScanner
        miflora_scanner = scanner(loop, callback, timeout_seconds=240)
        try:
            loop.run_until_complete(miflora_scanner.run())
        except KeyboardInterrupt as err:
            print(err)

        for mac, device in miflora_scanner.xdevices.items():
            print(device)

    get_data()


if __name__ == '__main__':
    exit(main())
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "xiaomipassive",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9.0",
    "maintainer_email": "",
    "keywords": "home,automation,xiaomi,LYWSD02,LYWSD03,Flower care",
    "author": "",
    "author_email": "Alain <afer921@mailfence.com>",
    "download_url": "https://files.pythonhosted.org/packages/7f/54/8596e827c07ad127851120c82b0c2a0f2036286ebbb74f13c992a667f708/xiaomipassive-2023.2.6.tar.gz",
    "platform": null,
    "description": "# xiaomipassive\nLYWSD02, LYWSD03MMC (custom firmware ATC) and MiFlora passive scanner\n## Installation\n```\ngit clone https://github.com/afer92/xiaomipassive.git\ncd xiaomipassive\npip3 install .\n```\n## Command line tool\n```\nxiaomipassivec\n```\nOutput:\n```\nmac: 80:EA:CA:89:xx:yy conductivity:   54 \u00b5S/cm (2023-02-26T00:42:25)\nmac: C4:7C:8D:64:xx:yyconductivity:  837 \u00b5S/cm (2023-02-26T00:42:25)\nmac: C4:7C:8D:6C:xx:yy light:          26 lux   (2023-02-26T00:42:26)\n...\nA4:C1:38:09:xx:yy ATC_0990AB\n=================\nmac: A4:C1:38:09:xx:yyB rssi:          -35 dBm   (2023-02-26T00:42:39)\nmac: A4:C1:38:09:xx:yy temperature:  21.6 \u00b0C    (2023-02-26T00:42:39)\nmac: A4:C1:38:09:xx:yy moisture:       32 %     (2023-02-26T00:42:39)\nmac: A4:C1:38:09:xx:yyB battery:        93 %     (2023-02-26T00:42:39)\nmac: A4:C1:38:09:xx:yy volt:         3.04 V     (2023-02-26T00:42:39)\n```\n## class XiaomiPassiveScanner\n```Python\nloop = asyncio.get_event_loop()\nscanner = XiaomiPassiveScanner(loop, callback, timeout_seconds=240)\n```\n### callback\nFunction call at each received advertissement\n```Python\ndef callback(self, data):\n    print(self.dump_result(data))\n```\nOutput:\n```\nmac: C4:7C:8D:65:xx:yy conductivity: 376 \u00b5S/cm\nmac: 80:EA:CA:89:xx:yy light:        283 lux\nmac: 15:03:10:12:xx:yy moisture:     47.0 %\nmac: C4:7C:8D:65:xx:yy temperature:  20.8 \u00b0C\nmac: E7:2E:01:71:xx:yy battery:      18 %\n```\nFunction **dump_result** format the data decoded in an advertisement\n\nDictionnary **data**:\n```Python\n{'ok': True,\n 'mac': 'C4:7C:8D:6C:xx:yy',\n 'sensor': 4100,\n 'stype': 'temperature',\n 'svalue': ListContainer([123, 0]),\n 'typeCst': ListContainer([113, 32, 152, 0]),\n 'num': 247,\n 'tab': 13,\n 'name': 'Flower care',\n 'rssi': -87,\n 'value': 12.3\n }\n```\n### timeout_seconds\nScan for **timeout_seconds**, default=240s\n### devices\nAfter **timeout_seconds** scanning, data collected for each mac address\n\nFunction **dump_device(mac)** format the data for one mac address\n```\nE7:2E:01:71:xx:yy LYWSD02\n=================\nmac: E7:2E:01:71:xx:yy rssi:          -93 dBm   (2023-02-24T19:34:19)\nmac: E7:2E:01:71:xx:yy moisture:     47.0 %     (2023-02-24T19:32:44)\nmac: E7:2E:01:71:xx:yy temperature:  20.6 \u00b0C    (2023-02-24T19:34:18)\nmac: E7:2E:01:71:xx:yy battery:        18 %     (2023-02-24T19:33:37)\n\nC4:7C:8D:65:B1:1D Flower care\n=================\nmac: C4:7C:8D:65:xx:yy rssi:          -81 dBm   (2023-02-24T19:34:19)\nmac: C4:7C:8D:65:xx:yy light:         118 lux   (2023-02-24T19:33:41)\nmac: C4:7C:8D:65:xx:yy moisture:       21 %     (2023-02-24T19:33:52)\nmac: C4:7C:8D:65:xx:yy conductivity:  309 \u00b5S/cm (2023-02-24T19:34:04)\nmac: C4:7C:8D:65:xx:yy temperature:  20.7 \u00b0C    (2023-02-24T19:34:15)\n```\n\n## Example\n```Python\n#!/usr/bin/python3\n\nfrom xiaomipassive import xiaomipassive as xiaomi\nimport asyncio\n\ndef main():\n\n    def callback(self, result):\n        print(self.dump_result(result))\n\n    def get_data():\n        loop = asyncio.get_event_loop()\n        scanner = xiaomi.XiaomiPassiveScanner\n        miflora_scanner = scanner(loop, callback, timeout_seconds=240)\n        try:\n            loop.run_until_complete(miflora_scanner.run())\n        except KeyboardInterrupt as err:\n            print(err)\n\n        for mac, device in miflora_scanner.xdevices.items():\n            print(device)\n\n    get_data()\n\n\nif __name__ == '__main__':\n    exit(main())\n```\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "MiFlora and LYWSD02 passive scanner",
    "version": "2023.2.6",
    "split_keywords": [
        "home",
        "automation",
        "xiaomi",
        "lywsd02",
        "lywsd03",
        "flower care"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "581311fb9dfdcfbcc8341f92b25506d7d6f3f734cae21c6ddf12082d129c5efc",
                "md5": "a27726b594a1b290dcd306ced8ccc71b",
                "sha256": "188396d48791e7b3323f7079309beca6c24e2e44695787ee9db3f3495df1eddd"
            },
            "downloads": -1,
            "filename": "xiaomipassive-2023.2.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a27726b594a1b290dcd306ced8ccc71b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9.0",
            "size": 10219,
            "upload_time": "2023-03-11T09:17:17",
            "upload_time_iso_8601": "2023-03-11T09:17:17.722397Z",
            "url": "https://files.pythonhosted.org/packages/58/13/11fb9dfdcfbcc8341f92b25506d7d6f3f734cae21c6ddf12082d129c5efc/xiaomipassive-2023.2.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7f548596e827c07ad127851120c82b0c2a0f2036286ebbb74f13c992a667f708",
                "md5": "13057663a01c89dc2ab3b27e1b4ee2dc",
                "sha256": "ab813bf19b934fcac2e2db7f06f7befc87c7e89e8614292bab854175dbf04d2d"
            },
            "downloads": -1,
            "filename": "xiaomipassive-2023.2.6.tar.gz",
            "has_sig": false,
            "md5_digest": "13057663a01c89dc2ab3b27e1b4ee2dc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9.0",
            "size": 9933,
            "upload_time": "2023-03-11T09:17:19",
            "upload_time_iso_8601": "2023-03-11T09:17:19.545323Z",
            "url": "https://files.pythonhosted.org/packages/7f/54/8596e827c07ad127851120c82b0c2a0f2036286ebbb74f13c992a667f708/xiaomipassive-2023.2.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-11 09:17:19",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "xiaomipassive"
}
        
Elapsed time: 0.05575s