Xiaomi Gateway custom MP3

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.
Post Reply
User avatar
Egregius
Posts: 2695
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: Beta
Location: Beitem, BE
Contact:

Xiaomi Gateway custom MP3

Post by Egregius » Wednesday 14 March 2018 12:19

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?

BarryT
Posts: 264
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: beta
Location: east netherlands
Contact:

Re: Xiaomi Gateway custom MP3

Post by BarryT » Sunday 18 March 2018 22:25

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! :)
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

User avatar
Egregius
Posts: 2695
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: Beta
Location: Beitem, BE
Contact:

Re: Xiaomi Gateway custom MP3

Post by Egregius » Monday 19 March 2018 0:13

With wich program did you create the mp3?

BarryT
Posts: 264
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: beta
Location: east netherlands
Contact:

Re: Xiaomi Gateway custom MP3

Post by BarryT » Monday 19 March 2018 0:27

FL Studio :)
But it can with every program as long there is a mp3 encoder in it.
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

User avatar
advokatb
Posts: 4
Joined: Monday 19 March 2018 20:22
Target OS: Windows
Domoticz version: beta
Location: Ukraine
Contact:

Re: Xiaomi Gateway custom MP3

Post by advokatb » Thursday 05 April 2018 17:16

Can you please share how to play custom mp3 in Blocks?
dom.PNG
dom.PNG (18.42 KiB) Viewed 1325 times
I've added Xiaomi Gateway MP3 block but it doesn't play nothing :(
Thanks.


klirik
Posts: 5
Joined: Tuesday 10 July 2018 5:00
Target OS: Linux
Domoticz version: Beta
Location: Novosibirsk, RU
Contact:

Re: Xiaomi Gateway custom MP3

Post by klirik » Wednesday 11 July 2018 8:19

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)

klirik
Posts: 5
Joined: Tuesday 10 July 2018 5:00
Target OS: Linux
Domoticz version: Beta
Location: Novosibirsk, RU
Contact:

Re: Xiaomi Gateway custom MP3

Post by klirik » Friday 13 July 2018 7:23

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:

Code: Select all

ffmpeg -i 18Track.mp3 -b:a 64k tr18a.aac
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:

Code: Select all

{"id":1,"method":"download_user_music","params":["5001","http://192.168.1.150/media/music/tr18.aac"]}
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):

Code: Select all

{"id":1,"method":"get_download_progress","params":[]}
It will return progress for each music ID in %. Finally you'll take:

Code: Select all

{"result":["5001:100"],"id":1}
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

Code: Select all

{"id":1,"method":"play_music","params":[5001]}

Code: Select all

{"id":1,"method":"play_music_new","params":["5001",10]}
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

Code: Select all

{"id":1,"method":"get_music_info","params":[0]}
- get list of available music (params m.b. 0,1,2 for 'system' banks, >2 will return list of user music).

Code: Select all

{"id":1,"method":"delete_user_music","params":["5001"]}

Code: Select all

{"id":1,"method":"get_music_free_space","params":[]}
- returns available bytes. On 'fresh' gw it is about 11Mb available.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests