rytilahti / python-miio

Python library & console tool for controlling Xiaomi smart appliances
https://python-miio.readthedocs.io
GNU General Public License v3.0
3.64k stars 550 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 3 years ago

but

water_pos_t water_pos_w water_strong_t water_strong_w water_temp_t water_temp_w

don't work if i do raw_command get_prop

i have error: -9999

syssi commented 3 years ago

Did you replace the placeholder with values?

miiocli device --ip <ip> --token <token> raw_command tunwash_on [3, 3, 2, 1, 1]
JeedHome44 commented 3 years ago

i understand!

raw_command get_prop "['water_pos_t']" don't work

we have to do:

raw_command get_prop "['status_tunwash']"

next do array and select wich information we need.

JeedHome44 commented 3 years ago

You say defauftIndex ???

What I have to write with this attribute to send command like tunwash?

syssi commented 3 years ago

I don't understand you. Could you elaborate your question?

JeedHome44 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']"

What is defaultIndex here?

What I have to write in third attribute? 0? 1? 2?

Thank you

JeedHome44 commented 3 years ago

No waterPosT and waterPosW have to send with tunwash or womenwash? I think the third attribute is waterPosT or water PosW ;)

JeedHome44 commented 3 years ago

If I want moving, what I have to sens for tunwash? [3, 3, 0, 1, 0] ? Position 0 if moving 1?

JeedHome44 commented 3 years ago

I don't understand you. Could you elaborate your question?

but how did you know all this information to send to the toilet?

syssi commented 3 years ago

I've disassembled/extracted the informations from the mihome app (react plugin).

JeedHome44 commented 3 years ago

I don't understand this:

If i do:

miiocli device --ip <ip> --token <token> raw_command get_prop "['water_pos_t']" or miiocli device --ip <ip> --token <token> raw_command get_prop "['water_pos_w']" or miiocli device --ip <ip> --token <token> raw_command get_prop "['water_strong_t']" or miiocli device --ip <ip> --token <token> raw_command get_prop "['water_strong_w']" or miiocli device --ip <ip> --token <token> raw_command get_prop "['water_temp_t']" or miiocli device --ip <ip> --token <token> raw_command get_prop "['water_temp_w']" or miiocli device --ip <ip> --token <token> raw_command get_prop "['massage']" or miiocli device --ip <ip> --token <token> raw_command get_prop "['moving']"

I have this response:

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

Why?

tykarol commented 3 years ago

@JeedHome44 I created a simple HACS addon for xjx-toilet.pro - https://github.com/tykarol/home-assistant-xjx-toilet-pro You need to also install the toiletlid base integration mentioned in the readme - https://github.com/tykarol/home-assistant-toiletlid (created by scp10011 but I separated the base integration).

Currently tested self_clean on/off services and light on/off, there is also the send_commend implemented but I don't test it yet.

JeedHome44 commented 3 years ago

@JeedHome44 I created a simple HACS addon for xjx-toilet.pro - https://github.com/tykarol/home-assistant-xjx-toilet-pro

You need to also install the toiletlid base integration mentioned in the readme - https://github.com/tykarol/home-assistant-toiletlid (created by scp10011 but I separated the base integration).

Currently tested self_clean on/off services and light on/off, there is also the send_commend implemented but I don't test it yet.

Hello,

Great job but you don't add all action and all information.

You can add it?

tykarol commented 3 years ago

I don't have time and don't need more actions but you can do it and create PR.

This is still in progress and needs to be testing and improved. Probably 10s interval is too often, also for each prop you have to ask individually and Home Assistant gets errors like:

ERROR (MainThread) [custom_components.xjx_toilet_pro.toiletlid] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

This is more important to fix this than add more actions and I don't think so you need them all in HA.

I will add more properties if the above problem will be resolved.

Edit: I currently test with 30s interval and there are fewer errors but still are. And this is not the solution if we want to add more props to get from the device.

JeedHome44 commented 3 years ago

I don't have time and don't need more actions but you can do it and create PR.

This is still in progress and needs to be testing and improved. Probably 10s interval is too often, also for each prop you have to ask individually and Home Assistant gets errors like:

ERROR (MainThread) [custom_components.xjx_toilet_pro.toiletlid] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

This is more important to fix this than add more actions and I don't think so you need them all in HA.

I will add more properties if the above problem will be resolved.

Edit: I currently test with 30s interval and there are fewer errors but still are. And this is not the solution if we want to add more props to get from the device.

I want ALL actions and informations to control all properties with Google Home. I want HA change proprieties automatically if me, my wife or my children ask Google clean ass 😉

JeedHome44 commented 3 years ago

It's my YouTube channel. I add all in Jeedom:

https://youtu.be/UjIeWNsIqu4

JeedHome44 commented 3 years ago

@syssi can we send multi command with python--miio?

I think error -9999 timeout have to receive raw_command action and get_prop in same time no?

tykarol commented 3 years ago

I try to get multiple props in one command but without success, always I get only value for the first property or error. I fixed the validation of params in the send_command, this is the same as raw_command so you can do action what you want using it.

I get a timeout for property: fan_temp massage moving water_pos_t water_pos_w water_strong_t water_strong_w water_temp_t water_temp_w

also, I currently don't know how should be assigned values to state for: status_tunwash => [0, 2, 3, 2, 0, 0] status_womenwash => [0, 2, 2, 2, 0, 0] status_warmdry => [0, 2] - what is the second value? the first is 0 if off and 1 if on? seat_temp => [0] - what are possible values?

values for status_tunwash and status_womenwash are described above in the comments but the values for eg. moving is specific for mode or its globally? it should be assigned as moving or tun_wash_moving?

Does anyone know in what format is value for left_day? I get the [1109] for 109 days, so should I remove the "1" or first char from the start? What does it mean the first sign?

JeedHome44 commented 3 years ago

I have 1040 for left Day and next day 1039, so you have to can 1. I think, 1 is number of change filter 😉

I will change it in 20 days. I will say you 😉

JeedHome44 commented 3 years ago

I say in French because it's difficult in English:

J'ai testé de mettre moving sur 1 en envoyant les commandes pour le lavage mais ça ne bouge pas non plus.

Des fois, quand je demandes les informations pour le lavage, je reçois soit 4 soit 5 informations.

Je pense en recevoir 4 quand moving est sur 1.

Pour l'instant, j'envoie la commande lavage sans aucun paramétré dedans et ça prend en compte les précédents.

J'aimerai pouvoir à terme, envoyer les paramètres préférés de chaque membre de la famille.

J'arrive actuellement à changer la température de la cuvette et avoir le retour.

Lancer le stop pour les 3 actions.

Lancer le séchage.

Lancer le lavage fesses ou femmes sans paramètres.

Et bien sur la lumière s'allume dés que mon ampoule Hue s'allume dans le toilette.

J'ai fait tout ça avec des scénarios et script Jeedom.

AlexPotterOnGit commented 3 years ago

@tykarol - just wanted to let you know mate I am really appreciated your work and looking forward for further project development. Especially interested in seat/water temperature control and sensor for someone seating on it so I can turn on ceiling fan. Happy to buy you few coffee if you share the way to do it.

tykarol commented 3 years ago

@AlexPotterOnGit currently, I don't have time too much for developing this addon, but if you have time I think you can try to add seat/water temperature control based on methods eg. for led and self_clean or you can use the raw send_command service to send method directly to python-miio something like this:

service: 'xjx_toilet_pro.send_command'
data:
  entity_id: toiletlid.xxx
  command: 'tunwash_on'
  params: ['2', '2', '2', '0', '0']

More you can find here: https://github.com/rytilahti/python-miio/issues/815#issuecomment-761827867

I don't test this, maybe params should be in the other format.

As for the status, if someone is sitting, you can check it based on the seating property or occupied status.

tykarol commented 3 years ago

I checked the value of the left_day, if 0 days left then the value is [1000], after reset the value is [1180] (180 days left).