Midea/midea.py

76 lines
2 KiB
Python
Raw Normal View History

2023-09-22 12:14:46 +00:00
import security;
2023-09-22 16:06:37 +00:00
import cloud;
import aiohttp;
import asyncio;
import discover;
import device;
2023-09-26 17:42:50 +00:00
import devicee1;
2023-09-29 13:10:47 +00:00
import packet_builder;
import datetime;
2023-09-22 16:06:37 +00:00
2023-10-03 07:19:19 +00:00
# async def test():
# cl = cloud.MSmartHomeCloud(
# "MSmartHome",
# aiohttp.ClientSession(),
# "michaelh.95@t-online.de",
# "Hoda.semi1"
# )
# devices = discover.discover()
# if len(devices) > 0:
# if await cl.login():
# for device_id in devices:
# keys = await cl.get_keys(device_id)
# for k in keys:
# token = keys[k]['token']
# key = keys[k]['key']
# device_info = devices[device_id]
# dev = devicee1.MideaE1Device(
# name="",
# device_id=device_id,
# ip_address=device_info['ip_address'],
# port=device_info['port'],
# token=token,
# key=key,
# protocol=3,
# model=device_info['model'],
# customize=""
# )
# if dev.connect(True):
# return dev
key = b"V\x103\xba\xa0W\x85\xaa\x0c\x01q\xb7\x94\t\x7f\xd4\xe7=L\x91\x02\x14\x8d`\xf7~\xc6\xfd\x99?\x14\xbc"
chunk = bytearray([77, 15, 242, 219, 218, 33, 185, 171, 8, 35, 207, 179, 31, 179, 75, 165])
chunk_ref = bytearray([49, 19, 2, 10, 23, 20, 2, 134, 2, 0, 0, 139, 0, 0, 0, 0])
sec = security.LocalSecurity()
chunk_res = sec.aes_cbc_decrypt(chunk, key)
print(chunk_ref)
print(chunk_res)
dev = devicee1.MideaE1Device(
name="",
device_id=152832116426242,
ip_address="192.168.178.94",
port=6444,
token="dead840607856a4b84c1a9d94ce8f553b50c037b65fa1ca22126de339c367eb765b231b4525d5b8336c48fe5dae38439bbb5e31282ed3790ff98a48049401dca",
key="50e77947dc63426db3883c7616613410044b02567f5240a5baf789391b2e5a79",
protocol=3,
model="760EY015",
customize=""
)
dev.connect(True)
2023-09-22 16:06:37 +00:00
print(dev)
2023-09-22 05:45:40 +00:00