Metadata-Version: 2.1
Name: radoneye
Version: 1.0.0
Summary: API and CLI for Ecosense RadonEye devices
Author-email: Artem Butusov <art.sormy@gmail.com>
License: MIT License
        
        Copyright (c) 2022 Artem Butusov
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/sormy/radoneye
Project-URL: Issues, https://github.com/sormy/radoneye/issues
Keywords: Ecosense,RadonEye,RD200,RD200N,RD200P
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: asyncio~=3.4.3
Requires-Dist: bleak~=0.21.1
Requires-Dist: paho-mqtt~=1.6.1

# Ecosense RadonEye CLI and API for Python

Provides simple and convinient Python API to communicate with RadonEye bluetooth devices.

Supported devices:

- RD200 (version 1) - not tested
- RD200N (version 2) - tested
- RD200P (version 2) - should work, never tested

Version 1 support is implemented using publicly available information. I have no device to test on,
if you have old RD200 device and are willing to help to build better support (beeps, history etc),
then let me know.

## Usage (API)

Scan for all available devices, beep, read status and history:

```py
import asyncio
import json
from sys import stderr

from radoneye import RadonEyeClient, RadonEyeScanner


async def main():
    for dev in await RadonEyeScanner.discover():
        print(f"Device: {dev}")

        async with RadonEyeClient(dev) as client:
            try:
                await client.beep()
                print("Beep: ok")
            except Exception:
                print("Unable to beep due to error", file=stderr)

            try:
                print(f"Status: {json.dumps(await client.status())}")
            except Exception:
                print("Unable to obtain status due to error", file=stderr)

            try:
                print(f"History: {json.dumps(await client.history())}")
            except Exception:
                print("Unable to obtain history due to error", file=stderr)


if __name__ == "__main__":
    asyncio.run(main())
```

## Usage (CLI)

```sh
$ pip3 install radoneye

$ radoneye --help

$ radoneye list --help
$ radoneye list
70C12E8A-27F6-3AEC-0BAD-95FA94BF17A9	FR:RU22201030383
3775964E-C653-C00C-7F02-7C03F9F0122D	FR:RU22204180050

$ radoneye beep --help
$ radoneye beep 70C12E8A-27F6-3AEC-0BAD-95FA94BF17A9
Beeping on 70C12E8A-27F6-3AEC-0BAD-95FA94BF17A9

$ radoneye status --help
$ radoneye status 70C12E8A-27F6-3AEC-0BAD-95FA94BF17A9
counts_current = 0
counts_previous = 1
counts_str = 0/1
day_avg_bq_m3 = 16
day_avg_pci_l = 0.43
latest_bq_m3 = 5
latest_pci_l = 0.14
model = RD200N
month_avg_bq_m3 = 0
month_avg_pci_l = 0.0
peak_bq_m3 = 32
peak_pci_l = 0.86
serial = RU22201030383
uptime_minutes = 3495
uptime_str = 2d10h1

$ radoneye history 70C12E8A-27F6-3AEC-0BAD-95FA94BF17A9
#	Bq/m3	pCi/L
1	2	0.05
2	9	0.24
3	20	0.54
4	10	0.27
5	10	0.27
6	5	0.14
7	5	0.14
8	3	0.08
9	10	0.27
10	10	0.27
...
```

NOTE: On macOS bluetooth addresses are obfuscated to UUID.

## Publishing

```sh
# install dependencices
pip3 install twine
# install locally
pip3 install -e .
# test using cli
radoneye --help
# build
python3 -m build
# view what is included into wheel
unzip -l dist/*.whl
# check wheel
twine check dist/*.whl
# upload to pypi
twine upload --repository radoneye dist/*
```

## License

MIT
