-
-
Notifications
You must be signed in to change notification settings - Fork 12
feat(cloud): add support for Japanese Toshiba IOLife devices #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Important Review skippedAuto reviews are limited to specific labels. Labels to auto review (6)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Hi, thank to so much for the contribution! Please always use the correct env (devcontainer or use at least setup script) so you'll have the complete env for development and get the checks running locally. |
After a lot of effort, I've realized that the lua files aren't fetched from the API at all, they are only distributed with the app, so the downloadLua will probably never work, at least not for my appliances. It always returns 404 (when authenticated), and not 401, so that's maybe telling, and maybe it will work for someone else's Japanese Toshiba appliance. I will extract the lua files from the app and start porting the protocol. The list_appliances function work well, and I don't think there are more cloud functions needed to get local support working. Do you prefer to keep the vestigal download_lua function in case it's activated later, or should I just remove it from this PR? |
Since you renamed this to feat(cloud), then maybe I should open a separate PR for parsing the protocol? I'm looking forward to finally getting this working :) |
@audunmg if you want to add a new cloud support, you should find out the cloud URL and params for this cloud URL, also include the cloud server URL for this cloud, then you can got a expected http 200 response from the server. I'm not familar with all the detail, but just try to read all the source code and exist feature, got this per my understand. |
@audunmg these id/key maybe works for you. please check with MeijuCloud and SmartHomeCloud args, use these value for your midea-local/midealocal/cloud.py Line 31 in 498bbe2
if
thanks |
Thanks! I will try at the first opportunity! |
I was able to test, but my appliances doesn't seem to work with TSmartLife, but they work with the IOLife cloud. I'm speculating that the TSmartgLife is for Toshiba appliances outside of Japan? In any case, the IOlife cloud keys work and is able to get my list of appliances (with keys!), and I've verified that my IOLife app doesn't download lua files from the API. I've been able to extract them some other way, so I'll make a separate PR with those files. |
@audunmg thanks for the info share. |
Correction: I thought i got keys, but i see now it's using the default keys instead and is not able to communicate with my applicance. |
you can refer to config_flow, I have add a brief step description. |
ea2cefc
to
f00234b
Compare
A lot has happened since i started this PR, and i forgot where i got stuck. I did a rebase, and tested with It's able to retrieve keys, and connect, but the protocol is wrong, and that's why I needed the lua files.
|
@audunmg if you can get token and pass auth, it should finished about 70%-80%. you need to add a new query msg to trigger your device response to this query and parse the response with a body class, and update the result to HA.
|
the lua file are attached in the app. or we can try download from endpoint note: |
I have been able to decrypt the lua file attached in IOLife app 🎉 the decrypt code: from Crypto.Cipher import AES
import binascii
import hashlib
def decrypt_file(input_file, key):
# Generate MD5 hash and take first 16 chars
key_bytes = hashlib.md5(key.encode()).hexdigest()[:16].encode()
# Print the MD5 hash used as key
print(f"Using key: {hashlib.md5(key.encode()).hexdigest()[:16]}")
# Read encrypted data
with open(input_file, 'r') as f:
hex_str = f.read().strip()
# Convert hex string to bytes
encrypted_data = bytes([int(hex_str[i:i+2], 16) for i in range(0, len(hex_str), 2)])
# Create cipher object and decrypt the data
cipher = AES.new(key_bytes, AES.MODE_ECB)
# Add PKCS5 padding if needed
block_size = 16
pad_length = block_size - (len(encrypted_data) % block_size)
if pad_length < block_size:
encrypted_data += bytes([pad_length] * pad_length)
# Decrypt data
decrypted_data = cipher.decrypt(encrypted_data)
# Remove padding
padding_length = decrypted_data[-1]
decrypted_data = decrypted_data[:-padding_length]
# Convert to string
decrypted_text = decrypted_data.decode('utf-8')
# Write decrypted data
output_file = input_file + '.decrypted'
with open(output_file, 'w') as f:
f.write(decrypted_text)
print(f"Decrypted file saved as: {output_file}")
# Decrypt the file
app_key = "<app key>"
input_file = "<input file>"
decrypt_file(input_file, app_key) |
T_0008_DB_30.lua.zip this is plugin and lua for my front machine wash. I can also decrypt there files
honestly I don't know what to do next 🤔 |
@yuyuvn thank you very much for your info. and current integration still using V1 API ,it's LAN service, but we need a token to control device, and we need to got this token from midea cloud. if we can't got token, we can do nothing. |
@wuwentao
I think I already got valid token to connect my device from the cloud.
|
@yuyuvn yes, as v1 api should always exist in old firmware, and v1 api token should be get from midea cloud server, this is the root. in the same time. |
hey, I have a good news {
"status":{
"operation_wash_dryer_dry_set":1,
"rinse_mode":"off",
"over_capacity":0,
"remain_time":19882,
"hot_water_fifteen":"off",
"lock":"off",
"process_info_dry":"yes",
"dehydration_time":241,
"default_dry":"energy_saving",
"tub_high_hot":0,
"drain_filter_care":0,
"door_open":0,
"wash_rinse":"none",
"operation_wash_dryer_spin_time":0,
"tub_auto_clean":"on",
"detergent_remain":3,
"begin_process_wash":"yes",
"spin_rotate_adjust":0,
"drain_bubble_protect":"on",
"detergent_setting":"off",
"process_info_rinse":"yes",
"machine_status":"running",
"ufb":"off",
"app_course_number":0,
"version":30,
"command":"none",
"function_type":"base",
"water_high_temperature":0,
"dry":241,
"softner_name":99,
"process_info_wash":"yes",
"operation_dryer_dry_set":1,
"energy_saving":"off",
"begin_process_soft_keep":"yes",
"rinse_pour":3,
"operation_wash_time":14,
"program":"mute",
"operation_wash_spin_time":3,
"process_info_soft_keep":"yes",
"reservation_time_latest_min":40,
"reservation_time_latest_hour":0,
"begin_process_spin":"yes",
"reservation_time_earliest_hour":9,
"begin_process_dry":"yes",
"time_sec":0,
"reservation_time_earliest_min":10,
"begin_process_rinse":"yes",
"softner_measure":10,
"operation_wash_dryer_rinse_times":3,
"process_info_spin":"yes",
"detergent_measure":10,
"detergent_name":3,
"time_hour":0,
"softner_setting":"off",
"softner_remain_explanation":2,
"buzzer":"off",
"softner_remain":3,
"low_noise":"off",
"time_min":46,
"wash_time":14,
"process_detail":3,
"tub_water_exist":0,
"detergent_remain_explanation":2,
"remain_time_adjust":0,
"dry_finish_adjust":0,
"drain_filter_clean":0,
"mode":"wash_dry",
"operation_wash_dryer_time":14,
"operation_wash_rinse_times":3,
"temperature":0,
"reservation_mode":0,
"reservation_hour":6,
"dry_filter_clean":0,
"error":0,
"fungus_protect":"off",
"reservation_min":18
}
} and this is extractly what we need. so I can confirm we already have everything we need, token and message format and how to parse response message. |
@yuyuvn Thanks a lot and sorry about the long delay. I don't think I have much time to complete the AC any time soon, and I wouldn't want to block your work, so I'm setting this to ready for review, and if you need more, I added you to my branch so you can control this PR too. |
@audunmg @yuyuvn midea-local/midealocal/cloud.py Line 250 in 2b6f5c0
is this get_cloud_token API service available in IOLife cloud server? |
Not intended to be merged, but opening a PR to show this is being worked on (slowly), and maybe attract comments and help.
For now, the cloud functions are working (except the one to download lua files, and i suspect that will never work), but that's the only working thing.
The local protocol to actually communicate with the devices is not working at all (yet).