Error in getting devices
So I tried to connect my ewelink device via the example in the documentation which is import ewelink from ewelink import Client, DeviceOffline
@ewelink.login('password', '[email protected]') async def main(client: Client): print(client.region) print(client.user.info) print(client.devices)
device = client.get_device('10008ecfd9') #single channel device
device2 = client.get_device('10007fgah9') #four channel device
print(device.params)
#Raw device specific properties
#can be accessed easily like: device.params.switch or device.params['startup'] (a subclass of dict)
print(device.state)
print(device.created_at)
print("Brand Name:", device.brand.name, "Logo URL:", device.brand.logo.url)
print("Device online?", device.online)
try:
await device.on()
except DeviceOffline:
print("Device is offline!")
However, I got error telling my device become NoneType Here is the error log:
Region.AS
ClientInfo(version='4.23.0', imei='ECCD89A0-A5AE-4756-8A31-71FEC4305BDB', model='iPhone_iPhone12,8', os='iOS', rom_version='15.5')
[<Device name=Deviceede5e3 id=1000ede5e3 switch=Power.off online?=True type=DeviceType.OSPF network=Network(ssid=None, sta_mac='C8:2B:96:61:6D:31')>]
Traceback (most recent call last):
File "D:\AUTOSAFE\AUTOSAFE_WARNING_LIGHT\ewelink-api-python-master\test.py", line 5, in
Would like to ask whats the meaning of the error and how to solve them, Thanks!!
try this example I wrote . it's basicaly a refactor without using the login decorator. Region is important so change it to match yours
https://github.com/dantimofte/ewelink-api-python/blob/master/main.py
import ewelink
async def main():
client: ewelink.Client = ewelink.Client("your_username", "email_or_phone", region="eu")
await client.login()
print(f"client version {client.region}")
print(f"client user info: {client.user.info}")
print(f"client devices {client.devices}")
device = client.get_device('1000ce120a')
print(f"device params {device.params}")
# Raw device specific properties
# can be accessed easily like: device.params.switch or device.params['startup'] (a subclass of dict)
print(f"device state : {device.state}")
print(f"device created_at: {device.created_at}")
print("Brand Name: ", device.brand.name, "Logo URL: ", device.brand.logo.url)
print("Device online? ", device.online)
try:
await device.on()
except Exception as e:
print("Device is offline!")
await client.http.session.close()
if __name__ == '__main__':
asyncio.run(main())
the "your_username" is actually the "password".