SonoffBasic allows to control Sonoff switches via the Ewelink cloud, with a very basic features.
- Sonoff switch must be connected to ewelink app SONOFF Basic USER GUIDE.
- Username is email address.
- Ewelink account region must be one of 'us', 'eu' or 'cn'.
- install SonoffBasic (https://pypi.org/project/SonoffBasic/)
-
Create an instance of Sonoff with ewelink. available params (all values in string format):
- username - email address (required)
- password (required)
- region (optional) default 'us'
- timezone (optional) default 'US/Pacific'
>>> from SonoffBasic.sonoff import Sonoff >>> sonoff = Sonoff(username='[email protected]', password='my_pass', timezone='US/Pacific', region='us')
-
Search the required device
>>> print(sonoff.devices) [{'name': 'taco', 'deviceid': '1000157898', 'outletid': 0, 'status': 'on'}, {'name': 'Irrigation', 'deviceid': '100015b23r', 'outletid': 0, 'status': 'off'}]
-
Control the device
>>> sonoff.change_device_status(deviceid = '1000157898', new_status = 'off', outletid = 0 ) deviceid: 1000157898 status successfully changed to off
Thanks to @AlexxIT. cloud connection to eWeLink was inspired by SonoffLAN project.