Xiaomi Gateway custom MP3
Moderator: leecollings
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Xiaomi Gateway custom MP3
Hi All,
I'm trying to upload a custom made MP3 to my Xiaomi gateway to be used as notification sound.
Took a while to figure out that I needed a Android device to do that, iOS only support recording voice messages.
Anyway, the voice recordings work, the uploaded MP3 works, but plays at double the speed getting a voice like the Chipmunks.
What are the requirements for the MP3?
I'm trying to upload a custom made MP3 to my Xiaomi gateway to be used as notification sound.
Took a while to figure out that I needed a Android device to do that, iOS only support recording voice messages.
Anyway, the voice recordings work, the uploaded MP3 works, but plays at double the speed getting a voice like the Chipmunks.
What are the requirements for the MP3?
-
- Posts: 358
- Joined: Tuesday 31 March 2015 22:06
- Target OS: Linux
- Domoticz version: 2024.3
- Location: east netherlands
- Contact:
Re: Xiaomi Gateway custom MP3
i guess 128kbs - 44.1khz, mono (or maybe stereo also works)
when you say it plays at double speed, i think it has something to do with the sampling frequency of the audio file.
try to update its file to 44.1khz, and upload again, or try to upload a 22khz version..
i'm not sure the exact reason its double speed, but in here its working perfect!
when you say it plays at double speed, i think it has something to do with the sampling frequency of the audio file.
try to update its file to 44.1khz, and upload again, or try to upload a 22khz version..
i'm not sure the exact reason its double speed, but in here its working perfect!
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
Software: Linux, Android and Windows
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Xiaomi Gateway custom MP3
With wich program did you create the mp3?
-
- Posts: 358
- Joined: Tuesday 31 March 2015 22:06
- Target OS: Linux
- Domoticz version: 2024.3
- Location: east netherlands
- Contact:
Re: Xiaomi Gateway custom MP3
FL Studio
But it can with every program as long there is a mp3 encoder in it.
But it can with every program as long there is a mp3 encoder in it.
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
Software: Linux, Android and Windows
- advokatb
- Posts: 3
- Joined: Monday 19 March 2018 19:22
- Target OS: Windows
- Domoticz version: beta
- Location: Ukraine
- Contact:
Re: Xiaomi Gateway custom MP3
Can you please share how to play custom mp3 in Blocks?
Xiaomi Gateway MP3 block but it doesn't play nothing
Thanks.
I've added Thanks.
-
- Posts: 4
- Joined: Tuesday 10 July 2018 5:00
- Target OS: Linux
- Domoticz version: Beta
- Location: Novosibirsk, RU
- Contact:
Re: Xiaomi Gateway custom MP3
Actually it is not mp3, but aac
(have tried mp3 directly, gateway doesn't play it)
64k aac is ok.
(I believe miHome makes conversion via xiaomi's cloud when accept mp3 in application, but I've tried directly uploaded file)
(have tried mp3 directly, gateway doesn't play it)
64k aac is ok.
(I believe miHome makes conversion via xiaomi's cloud when accept mp3 in application, but I've tried directly uploaded file)
-
- Posts: 4
- Joined: Tuesday 10 July 2018 5:00
- Target OS: Linux
- Domoticz version: Beta
- Location: Novosibirsk, RU
- Contact:
Re: Xiaomi Gateway custom MP3
Need miio (any flavour - php-miio, python-miio, etc.) and available gateway token and IP (token you can look in mihome, at page where you switch on developer's mode).
1. Convert the source mp3 into aac for gateway:
2. Place converted file into place available from gateway by http (m.b. other proto works also; didn't check).
I used webserver on my router; but it is also possible to make it available via dz (however it doesn't return correct mimetype for aac, but downloading via it still works).
3. Via miio with correct ip/token send the command:
Here first param is musicID, must be >=1000. Second is url where gateway will take the music.
4. Periodically check the progress (since donwload command is async):
It will return progress for each music ID in %. Finally you'll take:
5. Play the music. There are two possible ways: by MusicID (which is string), or by index (which is numeric). In first case you can also set the volume
Now you can set MusicID as the custom variable and play/stop it via existing xiaomi gateway buttons. In MiHome this record will be nameless.
Other useful commands are - get list of available music (params m.b. 0,1,2 for 'system' banks, >2 will return list of user music).
- returns available bytes. On 'fresh' gw it is about 11Mb available.
1. Convert the source mp3 into aac for gateway:
Code: Select all
ffmpeg -i 18Track.mp3 -b:a 64k tr18a.aac
I used webserver on my router; but it is also possible to make it available via dz (however it doesn't return correct mimetype for aac, but downloading via it still works).
3. Via miio with correct ip/token send the command:
Code: Select all
{"id":1,"method":"download_user_music","params":["5001","http://192.168.1.150/media/music/tr18.aac"]}
4. Periodically check the progress (since donwload command is async):
Code: Select all
{"id":1,"method":"get_download_progress","params":[]}
Code: Select all
{"result":["5001:100"],"id":1}
Code: Select all
{"id":1,"method":"play_music","params":[5001]}
Code: Select all
{"id":1,"method":"play_music_new","params":["5001",10]}
Other useful commands are
Code: Select all
{"id":1,"method":"get_music_info","params":[0]}
Code: Select all
{"id":1,"method":"delete_user_music","params":["5001"]}
Code: Select all
{"id":1,"method":"get_music_free_space","params":[]}
-
- Posts: 9
- Joined: Monday 30 July 2018 7:05
- Target OS: Linux
- Domoticz version: Latest
- Location: Netherlands
- Contact:
Re: Xiaomi Gateway custom MP3
Could you eleborate step 3? "Via miio with correct ip/token send the command"
What is the command to connect to the gateway with miio? I cannot figure it out. Tried both miio and python-miio, but there is just no good documentation how to run the commands correctly.
What is the command to connect to the gateway with miio? I cannot figure it out. Tried both miio and python-miio, but there is just no good documentation how to run the commands correctly.
-
- Posts: 4
- Joined: Tuesday 10 July 2018 5:00
- Target OS: Linux
- Domoticz version: Beta
- Location: Novosibirsk, RU
- Contact:
Re: Xiaomi Gateway custom MP3
As an example:
Actually I've just wrapped all this long thing into a 1-line script which takes the command and add all this long stuff before it, like
and invoke it as
but this is already small details, you can guess your own comfortable way
(say, auto-increment 'id' param - it is ok to have one and same for gateway, but, say for mirobo it will not work. Encode 'method' as separate, and leave only 'params' hand-coded).
Code: Select all
php miio-cli.php --ip 192.168.1.123 --token 3XXXXXXXXXXXXXXXXXXXXXXXXXXXXX22 --sendcmd '{"id":1,"method":"get_music_free_space","params":[]}’
Code: Select all
#!/bin/bash
php miio-cli.php --ip 192.168.1.123 --token 3XXXXXXXXXXXXXXXXXXXXXXXXXXXXX22 --sendcmd \'$1\’
Code: Select all
./gateway "{"id":1,"method":"download_user_music","params":["5001","http://192.168.1.150/media/music/tr18.aac"]}"
(say, auto-increment 'id' param - it is ok to have one and same for gateway, but, say for mirobo it will not work. Encode 'method' as separate, and leave only 'params' hand-coded).
-
- Posts: 13
- Joined: Friday 25 January 2019 16:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Xiaomi Gateway custom MP3
It doesn't work to me at all. I don't know what I'm doing wrong.
My aac file is located on my RPI: /home/pi/Sounds/0001.aac and I've socond copy on dropbox.
If I execute command:
php miio-cli.php --ip 192.168.1.XXX --token XXX --sendcmd '{"id":1,"method":"download_user_music","params":["10003","https://www.dropbox.com/s/7v6ixits5dwrc7k/0001.aac"]}'
I receive: Устройство 192.168.1.XXX доступно и ответило:
{"result":["ok"],"id":1}
Looks like everything is OK, but aac file is not uploading to my gateway.
DevType is 1066.
I don't want to upload files using mic in my iPhone because of poor quality of the sound. Can you help me somehow to do it using cli?
My aac file is located on my RPI: /home/pi/Sounds/0001.aac and I've socond copy on dropbox.
If I execute command:
php miio-cli.php --ip 192.168.1.XXX --token XXX --sendcmd '{"id":1,"method":"download_user_music","params":["10003","https://www.dropbox.com/s/7v6ixits5dwrc7k/0001.aac"]}'
I receive: Устройство 192.168.1.XXX доступно и ответило:
{"result":["ok"],"id":1}
Looks like everything is OK, but aac file is not uploading to my gateway.
DevType is 1066.
I don't want to upload files using mic in my iPhone because of poor quality of the sound. Can you help me somehow to do it using cli?
Who is online
Users browsing this forum: Bing [Bot] and 1 guest