Skip to content
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

Add custom sound/voice package functionality for dreame.vacuum.mc1808 (Mijia 1C) #1181

Closed
luismeruje opened this issue Nov 6, 2021 · 11 comments · Fixed by #1457
Closed

Add custom sound/voice package functionality for dreame.vacuum.mc1808 (Mijia 1C) #1181

luismeruje opened this issue Nov 6, 2021 · 11 comments · Fixed by #1457

Comments

@luismeruje
Copy link

luismeruje commented Nov 6, 2021

Is your feature request related to a problem? Please describe.
No.

Describe the solution you'd like
I would like to be able to install custom sound packages on my dreame.vacuum.mc1808.

Device information:
If the enhancement is device-specific, please include also the following information.

miiocli device --ip 192.168.1.103 --token 5662576b644d7369686a566838786c4c info

Model: dreame.vacuum.mc1808
Hardware version: Linux
Firmware version: 4.1.8_1118

Additional context
I see the device is supported here:
https://github.com/rytilahti/python-miio/blob/master/miio/integrations/vacuum/dreame/dreamevacuum_miot.py

However, setting custom voice packs is not currently supported. From other issues I found this repository:
http://miot-spec.org/miot-spec-v2/instances?status=all

From here I got to two possible types for my vacuum, and corresponding commands (I've seen mentions of one being a release, and the other a debug version):
https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:vacuum:0000A006:dreame-mc1808:1
https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:vacuum:0000A006:dreame-mc1808:2

They both provide a "set-voice" service, with siid=24, aiid=2.

I learned how to send raw_commands from here:
#901

I can get the voice pack currently being used by running:
miiocli device --ip 192.168.1.103 --token 5662576b644d7369686a566838786c4c raw_command get_properties "[{'did': 'MYDID', 'siid': 24, 'piid': 3 }]"

However for changing the voice pack, I do not know what the "payload" should be here:
miiocli device --ip 192.168.1.103 --token 5662576b644d7369686a566838786c4c raw_command set_properties "[{'did': 'MYDID', 'siid': 24, 'aiid': 2 '<??...??>' }]"

I was also hoping that it is URL based, similar to the dreame F9, so that it supports custom audio packs:
#812

I've tried running mi home on bluestacks, and then doing a packet capture with wireshark. However, I don't have a way to parse that capture to get the actual exchanged commands. Plus, I don't see any traffic from or to a UDP port 54321 when changing voice language on the app running on blue stacks (I can try it again).

Finally, I've also found a reference to the following command on other repositories in github, for this vacuum:
action{"did":"audio-set-voice","siid":24,"aiid":2,"in":[]}
(again, no payload shown)
e.g. https://github.com/mksway/openhab-addons/blob/c668f77f92eb261c18315efcdf6bdee2c9466904/bundles/org.openhab.binding.miio/src/main/resources/database/dreame.vacuum.mc1808-miot.json

Any help would be appreciated, and I would be glad to attempt a PR to add this functionality if someone could provide the correct parameters for the call.

P.S. I also see that for some reason the miiocli throws a "WARNING:miio.device:Found an unsupported model 'dreame.vacuum.mc1808' for class 'Device'. If this is working for you, please open an issue at https://github.com/rytilahti/python-miio/". I can open a separate issue on that, or I can also correct it myself if I end up doing a PR.

@rezmus
Copy link

rezmus commented Nov 8, 2021

{
   "id":12345,
   "method":"action",
   "params":{
      "did":"DID",
      "siid":24,
      "aiid":2,
      "in":[
         {
            "piid":3,
            "value":"ID"
         },
         {
            "piid":4,
            "value":"URL"
         },
         {
            "piid":5,
            "value":"MD5"
         },
         {
            "piid":6,
            "value":"SIZE"
         }
      ]
   }
}

@luismeruje
Copy link
Author

@rezmus running:

raw_command action "[{'did':'DID','siid':24,'aiid':2,'in':[{'piid':3, 'value':'DE'},{'piid':4,'value':'https://awsde0.fds.api.xiaomi.com/dreame-product/dreame.vacuum.p2008/voices/package/deyu.tar.gz'},{'piid':5,'value':'96ab843008bb4d19480ac8a07d648aa7'},{'piid':6,'value':'1391385'}]}]"

runs for a bit, but then shows a

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

@rezmus
Copy link

rezmus commented Nov 9, 2021

action params are object, not an array. set/get_properties are array.

@luismeruje
Copy link
Author

luismeruje commented Nov 9, 2021

@rezmus, I've also tried that way, but it instantly throwed a {'did': 'DID', 'siid': 24, 'aiid': 2, 'code': -1}.
Command:
raw_command action "{'did':'DID','siid':24,'aiid':2,'in':[{'piid':3, 'value':'DE'},{'piid':4,'value':'https://awsde0.fds.api.xiaomi.com/dreame-product/dreame.vacuum.p2008/voices/package/deyu.tar.gz'},{'piid':5,'value':'96ab843008bb4d19480ac8a07d648aa7'},{'piid':6,'value':'1391385'}]}"

@rezmus
Copy link

rezmus commented Nov 9, 2021

iirc some actions can't be invoked via local api while work fine via cloud api (miotspec/action). maybe it's the case.

@luismeruje
Copy link
Author

@rezmus any pointers on how I could make the call go through the cloud?

@rezmus
Copy link

rezmus commented Nov 11, 2021

check this HA component it can make cloud calls, you will find code there.

https://github.com/al-one/hass-xiaomi-miot

@DeutscheGabanna
Copy link

Where can I get a mapping of filenames to certain sounds?
For example, in the deyu.tar.gz file @luismeruje mentions, there are files named 1.ogg or 2.ogg. How did you know what to name each file?
If I compress all my custom .OGG files into a .tar.gz file and upload it somewhere, will I be able to run this command and install it as a custom VALUE:WH for whatever?

@DeutscheGabanna
Copy link

In the spec for dreamevacuum1808 there's nothing in the JSON that would indicate any sound-mapping whatsoever: https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:vacuum:0000A006:dreame-mc1808:2

@luismeruje
Copy link
Author

luismeruje commented Apr 19, 2023

@DeutscheGabanna
As you can see above, soundpack install support has been added, so there is no need to execute any raw commands anymore.

You can now install soundpacks for this vaccuum with the following command:

miiocli dreamevacuum --ip <ip> --token <token> set_voice https://github.com/Findus23/voice_pack_dreame/raw/main/voice_pack.tar.gz 8ebfabb9e23e169a5c9b867266f9d1ef 4325024

The "ip" and "token" fields should be filled in accordingly. The example URL points to a GLADOS voice pack (from the Portal game). Yes, you can upload your own voice pack somewhere, and then use that as your own custom voice pack. The two values after the URL are a checksum (MD5 I believe) of the voice pack, and its size in bytes.

As for the sound mappings, my best advice would be to open the example voice pack in that URL, listen to each sound, and build your own mapping by hand from there.

@sverdlyuk
Copy link

Where can I get a mapping of filenames to certain sounds? For example, in the deyu.tar.gz file @luismeruje mentions, there are files named 1.ogg or 2.ogg. How did you know what to name each file? If I compress all my custom .OGG files into a .tar.gz file and upload it somewhere, will I be able to run this command and install it as a custom VALUE:WH for whatever?

mapping of filenames https://github.com/oleksandr-belei/dreame-vacuum-uk-voice-packs/blob/main/en_voice_mapping.csv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants