device = client.get_device('XXXXX') #single 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!")
I was able to print the device param but when it comes to changing the device state (device.on) it generates a timeout error:
Params(
version = 8
demNextFetchTime = 1711404000000
current = 11
voltage = 23227
power = 823
fwVersion = '1.1.0'
uiActive = 60
ssid = '!#%$#%^&$#^&^%#@#$&'
bssid = 'a0:f3:c1:35:60:16'
timeZone = 2
dayKwh = 7
monthKwh = 10
switches = [Object(
switch = 'on'
outlet = 0
)]
configure = [Object(
startup = 'off'
outlet = 0
)]
pulses = [Object(
pulse = 'off'
switch = 'off'
outlet = 0
width = 500
)]
sledOnline = 'on'
staMac = '08:D1:F9:E4:73:AC'
rssi = -38
getHoursKwh = Gethourskwh(
start = 0
end = 0
)
threshold = Threshold(
actPow = Actpow(
min = 10
max = 500000
)
voltage = Voltage(
min = 16500
max = 27700
)
current = Current(
min = 10
max = 2100
)
)
overload_00 = Overload_00(
minAP = Minap(
en = 0
val = 10
)
maxAP = Maxap(
en = 1
val = 500000
)
minV = Minv(
en = 0
val = 16500
)
maxV = Maxv(
en = 0
val = 27700
)
maxC = Maxc(
en = 1
val = 2100
)
minC = Minc(
en = 0
val = 10
)
)
operSide = 1
)
Traceback (most recent call last):
File "C:\Users\ElioChedid\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 456, in wait_for
return fut.result()
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\Users\ElioChedid\Desktop\sonoffff\ewelink-api-python\test.py", line 7, in
async def main(client: Client):
File "c:\Users\ElioChedid\Desktop\sonoffff\ewelink-api-python\ewelink\client.py", line 94, in decorator
result = asyncio.get_event_loop().run_until_complete(f(client))
File "C:\Users\ElioChedid\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
return future.result()
File "c:\Users\ElioChedid\Desktop\sonoffff\ewelink-api-python\test.py", line 23, in main
await device.on()
File "c:\Users\ElioChedid\Desktop\sonoffff\ewelink-api-python\ewelink\models\device.py", line 86, in edit
await self._state.ws.update_device_status(self.id, **params)
File "c:\Users\ElioChedid\Desktop\sonoffff\ewelink-api-python\ewelink\ws.py", line 82, in update_device_status
result = await asyncio.wait_for(fut, timeout = 10)
File "C:\Users\ElioChedid\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 458, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
I cloned the repo into my directory and executed the code: import ewelink from ewelink import Client, DeviceOffline
@ewelink.login('password', 'user.address@email.com') async def main(client: Client): print(client.region) print(client.user.info) print(client.devices)
I was able to print the device param but when it comes to changing the device state (device.on) it generates a timeout error: Params( version = 8 demNextFetchTime = 1711404000000 current = 11 voltage = 23227 power = 823 fwVersion = '1.1.0' uiActive = 60 ssid = '!#%$#%^&$#^&^%#@#$&' bssid = 'a0:f3:c1:35:60:16' timeZone = 2 dayKwh = 7 monthKwh = 10 switches = [Object( switch = 'on' outlet = 0 )] configure = [Object( startup = 'off' outlet = 0 )] pulses = [Object( pulse = 'off' switch = 'off' outlet = 0 width = 500 )] sledOnline = 'on' staMac = '08:D1:F9:E4:73:AC' rssi = -38 getHoursKwh = Gethourskwh( start = 0 end = 0 ) threshold = Threshold( actPow = Actpow( min = 10 max = 500000 ) voltage = Voltage( min = 16500 max = 27700 ) current = Current( min = 10 max = 2100 ) ) overload_00 = Overload_00( minAP = Minap( en = 0 val = 10 ) maxAP = Maxap( en = 1 val = 500000 ) minV = Minv( en = 0 val = 16500 ) maxV = Maxv( en = 0 val = 27700 ) maxC = Maxc( en = 1 val = 2100 ) minC = Minc( en = 0 val = 10 ) ) operSide = 1 ) Traceback (most recent call last): File "C:\Users\ElioChedid\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 456, in wait_for return fut.result() asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "c:\Users\ElioChedid\Desktop\sonoffff\ewelink-api-python\test.py", line 7, in
async def main(client: Client):
File "c:\Users\ElioChedid\Desktop\sonoffff\ewelink-api-python\ewelink\client.py", line 94, in decorator
result = asyncio.get_event_loop().run_until_complete(f(client))
File "C:\Users\ElioChedid\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
return future.result()
File "c:\Users\ElioChedid\Desktop\sonoffff\ewelink-api-python\test.py", line 23, in main
await device.on()
File "c:\Users\ElioChedid\Desktop\sonoffff\ewelink-api-python\ewelink\models\device.py", line 86, in edit
await self._state.ws.update_device_status(self.id, **params)
File "c:\Users\ElioChedid\Desktop\sonoffff\ewelink-api-python\ewelink\ws.py", line 82, in update_device_status
result = await asyncio.wait_for(fut, timeout = 10)
File "C:\Users\ElioChedid\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 458, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError