# asyncio-orvibo

Control Orvibo devices with Python 3 using asyncio (single threaded with event loop). Currently supports the S20 WiFi Smart Switch and AllOne IR.

## Usage

```python
from asyncio_orvibo import s20
import asyncio
import traceback
async def test_switch_all_off_on():
    dict_devices = await s20.S20.discovery()
    for _,s in dict_devices.items():
        if await s.state_change(0):
            print("State off OK %s",s)
        else:
            print("State off FAIL %s",s)
    await asyncio.sleep(5)
    for _,s in dict_devices.items():
        if await s.state_change(1):
            print("State on OK %s",s)
        else:
            print("State on FAIL %s",s)
loop = asyncio.get_event_loop()
try:
    loop.run_until_complete(test_switch_all_off_on())
except:
    traceback.print_exc()
    
################################################

from asyncio_orvibo import allone
import asyncio
import traceback
import binascii
async def test_emit(k):
    dict_devices = await allone.AllOne.discovery()
    payload = binascii.unhexlify(k)
    for _,a in dict_devices.items():
        rv = await a.emit_ir(payload)
        if rv:
            print("Emit OK %s %s",a,binascii.hexlify(rv).decode('utf-8'))
        else:
            print("Emit failed")
loop = asyncio.get_event_loop()
try:
    loop.run_until_complete(test_emit(' '))
except:
    traceback.print_exc()
```

## Contributions

Pull requests are welcome. Possible areas for improvement:

* Additional Orvibo devices (CT10 for example, I have reverse engineered this device I only need time to write the code).
* Expand S20 functions: Timers, configuration, etc

## Disclaimer

Not affiliated with Shenzhen Orvibo Electronics Co., Ltd.