rytilahti / python-miio

Python library & console tool for controlling Xiaomi smart appliances
https://python-miio.readthedocs.io
GNU General Public License v3.0
3.82k stars 564 forks source link

Add Xiaomi Mijia Whale Smart Toilet Cover (xjx.toilet.pro) support #815

Open JeedHome44 opened 4 years ago

JeedHome44 commented 4 years ago

Hello,

I find the token with Mi Home and IP.

I wish add this smart toilet seat in Hassio. Can you help me?

JeedHome44 commented 4 years ago

Hello,

It's possible to have this actions?

RearClean FrontClean (woman) Stop Dry SelfClean NightLed On/Off AirFilter SeatTemp WaterTemp

And this informations:

SeatTemp WaterTemp NightLed Filter

If i can have this, I can command this seat with Google Home! It will be great!

Thank you so much if it's possible

JeedHome44 commented 4 years ago

This is the screenshot in Mi Home

https://nsa40.casimages.com/img/2020/09/13/200913110620703584.png

JeedHome44 commented 4 years ago

Personne ne sait le faire?

JeedHome44 commented 4 years ago

Hello,

I just tried add scp10011/xiaomi_toiletlid in my Hassio with my token and ip but nothing appear in entity or service.

JeedHome44 commented 3 years ago

Can someone give me the encryption key Mi home uses? I managed to capture but it's encrypted

JeedHome44 commented 3 years ago

nobody want to help me?

syssi commented 3 years ago

What do you need to implement the device support?

JeedHome44 commented 3 years ago

I want to add all action and information to control completely in Hassio.

I need the RC4 key

syssi commented 3 years ago

You could use this tool to retrieve your individual device token from the cloud: https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor

JeedHome44 commented 3 years ago

I already have my token with VEVS apps. Now, I need to encrypt RC4 Packet Capture

syssi commented 3 years ago

Why do you want to decrypt your capture? To get to know the supported properties and methods?

JeedHome44 commented 3 years ago

For that:

Hello,

It's possible to have this actions?

RearClean FrontClean (woman) Stop Dry SelfClean NightLed On/Off AirFilter SeatTemp WaterTemp

And this informations:

SeatTemp WaterTemp NightLed Filter

If i can have this, I can command this seat with Google Home! It will be great!

Thank you so much if it's possible

JeedHome44 commented 3 years ago

Why do you want to decrypt your capture? To get to know the supported properties and methods?

I can add my device Tuya in local with dps JSON in packet capture. So, I need to add local control with my toilet seat too!

syssi commented 3 years ago

If you want to use this library this infos could be helpful:

Supported methods

get_prop
func_off
tun_wash_on
women_wash_on
warm_dry_on
seat_temp_on
air_filter_on
self_clean_on
night_led_on
set_water_temp_t
set_water_strong_t
set_water_pos_t
set_water_temp_w
set_water_strong_w
set_water_pos_w
set_moving
set_massage
set_fan_temp
set_seat_temp
reset_left_day
set_seat_time1
set_seat_time2
stop_seat_time1
stop_seat_time2
set_auto_filter
set_auto_led
set_freq_self_clean
set_auto_clean

Supported properties retrievable by get_prop

fan_temp
left_day
massage
moving
seating
seat_temp
status_airfilter
status_led
status_selfclean
status_tunwash
status_warmdry
status_womenwash
water_pos_t
water_pos_w
water_strong_t
water_strong_w
water_temp_t
water_temp_w
fw_ver

Internal properties

Some of there properties a return valus of the methods above.

air_filter
all_day
auto_filter
auto_led
error_code
fan_temp
freq_self_clean
fw_ver
left_day
massage
moving
night_led
seating
seat_temp
seat_temp_ctrl
seat_timer1
seat_timer2
self_clean
status_airfilter
status_led
status_selfclean
status_tunwash
status_warmdry
status_womenwash
time_air_filter
time_self_clean
tun_wash
warm_dry
water_pos_t
water_pos_w
water_strong_t
water_strong_w
water_temp_t
water_temp_w
women_wash

f.e.

func_tunwash_on returns [att_water_temp_t, att_water_strong_t, att_water_pos_t, att_moving, att_massage] func_women_wash_on returns [att_water_temp_w, att_water_strong_w, att_water_pos_w, att_moving, att_massage] func_seat_temp_on returns [att_seat_temp]

syssi commented 3 years ago

https://github.com/scp10011/xiaomi_toiletlid doesn't support your device. It supports tinymu.toiletlid.v1.

JeedHome44 commented 3 years ago

I am not a developer and I have no knowledge. I wanted to help by making a packet capture of my wc.

JeedHome44 commented 3 years ago

Yes no support mine

syssi commented 3 years ago

You could help by making some miiocli calls. Please install python-miio by pip install python-miio. This will provide a command line tool called miiocli. Now use this command to retrieve some/all properties:

miiocli device --ip <ip> --token <token> info
miiocli device --ip <ip> --token <token> raw_command get_prop "['fan_temp']"
miiocli device --ip <ip> --token <token> raw_command get_prop "['left_day']"

Please provide the output of any property listed above. As soon we understand each property we can try to control the device via

# turn the night light on
miiocli device --ip <ip> --token <token> raw_command night_led_on "[]"
# turn the night light off
miiocli device --ip <ip> --token <token> raw_command func_func_off "['night_led']"
JeedHome44 commented 3 years ago

Ok i will try this thank you

JeedHome44 commented 3 years ago

ip 160 is toilet seat. ip 162 is a test with my vacuum s50 v2

Capture

syssi commented 3 years ago

Could you try to retrieve your token from the mi cloud to make sure your token is correct? https://github.com/rytilahti/python-miio/issues/815#issuecomment-761761970

JeedHome44 commented 3 years ago

it's ok :) Capture

JeedHome44 commented 3 years ago

raw_command night_led_on "[]" :+1: ['ok'] raw_command func_func_off "['night_led']" :-1: ['error'] raw_command get_prop "['fan_temp']" :-1: Error: {'code': -9999, 'message': 'user hack timeout'} raw_command get_prop "['left_day']" :+1: [1044]

JeedHome44 commented 3 years ago

i think the seat go hibernate after x minutes and don't ping. do you know command to wakeup it? thank you

syssi commented 3 years ago

I don't think so. Is this device powered by battery? If not please try to move your access point next to the toilet. ;-)

JeedHome44 commented 3 years ago

no it is plugged into the wall I did several tests and if nothing is asked of the toilet after a certain time, the "IP ping" test does not work. I just have to put my hand on the toilet and there the ping works. So I think this model goes to sleep. My access point is right on the other side of the wall so the wc picks up very well. knowing that the Mi Home app does wake up the toilet, so I think there is a command to wake it up. If I try python-miio commands while the WC is on standby, it doesn't work and it works as soon as I wake it up.

JeedHome44 commented 3 years ago

there is no stop and drying function in the controls? I do not see them

syssi commented 3 years ago

If the device (wifi modem) does deep-sleep waking it up remotely won't be possible.

JeedHome44 commented 3 years ago

the mi home application does well. why wouldn't that be possible?

it is not my wifi which goes on standby but the Japanese toilet

syssi commented 3 years ago

Drying should be controllable by:

# turn warm dry on (without temperature?!)
miiocli device --ip <ip> --token <token> raw_command warm_dry_on "[1]"
# 50°C?
miiocli device --ip <ip> --token <token> raw_command warm_dry_on "[2]"
# 100°C?
miiocli device --ip <ip> --token <token> raw_command warm_dry_on "[3]"

# turn warm dry off
miiocli device --ip <ip> --token <token> raw_command func_func_off "['warm_dry']"
syssi commented 3 years ago

May be the ESP8266 / firmware crashs if you send incomplete/strange/unsupported commands.

JeedHome44 commented 3 years ago

no if i do no command. after x minutes, the seat can't ping... i don't know why...

JeedHome44 commented 3 years ago

i can do raw_command func_func_off "['tun_wash_on']" ? why gig you write func_func_off? it's not func_off only??

syssi commented 3 years ago

My fault. It's func_off. Please use the property names as value. Don't use method names here.

JeedHome44 commented 3 years ago

raw_command night_led_on "[]" ok raw_command func_off "['night_led']" ok raw_command warm_dry_on "[]" ok raw_command func_off "['warm_dry']" ok

syssi commented 3 years ago
# waterTempT: 3, 2, 1
# waterStrongT: 3, 2, 1
# defaultIndex: ??? 
# moving: 0, 1
# massage: 0 (off), 2 (massageType 2)

miiocli device --ip <ip> --token <token> raw_command women_wash_on [waterTempT, waterStrongT, defaultIndex, moving, massage]
miiocli device --ip <ip> --token <token> raw_command tunwash_on [waterTempT, waterStrongT, defaultIndex, moving, massage]

miiocli device --ip <ip> --token <token> raw_command func_off "['women_wash']"
miiocli device --ip <ip> --token <token> raw_command func_off "['tun_wash']"
JeedHome44 commented 3 years ago

what is 3 2 1 for watertemp please?

syssi commented 3 years ago

1: 100 °C 2: 50 °C 3: 0 (none?)

The same applies to waterStrongT. defaultIndex is probably 2. The value can be controlled by up/down buttons at the mi home app.

JeedHome44 commented 3 years ago

Lot of thank! I know to do a home assistant addon?

JeedHome44 commented 3 years ago

raw_command get_prop "['status_tunwash']" Running command raw_command [0, 3, 2, 2, 0, 0]

what is this respons?

syssi commented 3 years ago
status_tunwash: 0
water_temp_t: 3
water_strong_t: 2
water_pos_t: 2
moving: 0
massage: 0
syssi commented 3 years ago

You could try to extend the mentioned custom component to support your device.

JeedHome44 commented 3 years ago

can't we have a live status feedback?

syssi commented 3 years ago

You have to poll / call get_prop repeatedly to get status updates. The is no push communication.

JeedHome44 commented 3 years ago

Hello!

water_pos_t water_pos_w

don't work with:

miiocli device --ip 192.168.100.160 --token XXXXXXXXX raw_command get_prop \"['water_pos_w']\"

why? Response:

Error: {'code': -9999, 'message': 'user ack timeout'}

JeedHome44 commented 3 years ago

can we send http request to toilet seat to control it or have to ssh only?

syssi commented 3 years ago

The device doesn't understand HTTP. This library implements the device protocol.

JeedHome44 commented 3 years ago

Hello,

If I do tun_wash on with "[]".

What attribute use? The previous set?

syssi commented 3 years ago

Take a look at https://github.com/rytilahti/python-miio/issues/815#issuecomment-761827867

JeedHome44 commented 3 years ago

yes but it's work with "[]"