Git Product home page Git Product logo

miservice's Introduction

MiService

XiaoMi Cloud Service for mi.com This is a fork from https://github.com/Yonsm/MiService made some change for xiaogpt

如果有无法登陆的问题请参考置顶 issue, 如果还是不行请留言

本 fork 新增功能

-> 播放音乐

micli play ${mp3_url} 
micli pause

-> 播放音乐高级版

micli loop ${mp3_url}  # 循环播放
micli pause

# make a playlist name test.txt
cat test.txt
# http://192.168.6.212:8000/public/s4.mp3
# http://192.168.6.212:8000/public/s1.mp3
# http://192.168.6.212:8000/public/s2.mp3
# http://193.168.6.212:8000/public/s3.mp3

micli play_list test.txt # play the list

-> 播放 suno.ai trending

micli suno 

-> 播放 suno.ai trending random

micli suno_random

-> 查看硬件信息

micli mina

Install

pip3 install -U miservice_fork
or 
pip3 install .

Library

MiService:XiaoMi Cloud Service
  |
  |-- MiAccount:Account Srvice
  |-- MiBaseService:(TODO if needed)
  |     |
  |     |-- MiIOService:MiIO Service (sid=xiaomiio)
  |     |     |
  |     |     |-- MIoT_xxx:MIoT Service, Based on MiIO
  |     |
  |     |-- MiNAService:MiAI Service (sid=micoapi)
  |     |
  |     |-- MiAPIService:(TODO)
  |-- MiIOCommand:MiIO Command Style Interface

Command Line

Usage: The following variables must be set:
           export MI_USER=<Username>
           export MI_PASS=<Password>
           export MI_DID=<Device ID|Name>

Get Props: micli <siid[-piid]>[,...]
           micli 1,1-2,1-3,1-4,2-1,2-2,3
Set Props: micli <siid[-piid]=[#]value>[,...]
           micli 2=#60,2-2=#false,3=test
Do Action: micli <siid[-piid]> <arg1|#NA> [...] 
           micli 2 #NA
           micli 5 Hello
           micli 5-4 Hello #1

Call MIoT: micli <cmd=prop/get|/prop/set|action> <params>
           micli action '{"did":"267090026","siid":5,"aiid":1,"in":["Hello"]}'

Call MiIO: micli /<uri> <data>
           micli /home/device_list '{"getVirtualModel":false,"getHuamiDevices":1}'

Devs List: micli list [name=full|name_keyword] [getVirtualModel=false|true] [getHuamiDevices=0|1]
           micli list Light true 0

MIoT Spec: micli spec [model_keyword|type_urn] [format=text|python|json]
           micli spec
           micli spec speaker
           micli spec xiaomi.wifispeaker.lx04
           micli spec urn:miot-spec-v2:device:speaker:0000A015:xiaomi-lx04:1

MIoT Decode: micli decode <ssecurity> <nonce> <data> [gzip]

套路,例子:

请在 Mac OS 或 Linux 下执行,Windows 下要支持也应该容易但可能需要修改?

1. 先设置账号

export MI_USER=<Username>
export MI_PASS=<Password>

2. 查询自己的设备

micli list

可以显示自己账号下的设备列表,包含名称、类型、DID、Token 等信息。

3. 设置 DID

为了后续操作,请设置 Device ID(来自上面这条命令的结果)。

export MI_DID=<Device ID|Name>

4. 查询设备的接口文档

查询设备的 MIoT 接口能力描述:

micli spec xiaomi.wifispeaker.lx04

其中分为属性获取、属性设置、动作调用三种描述。

5. 查询音量属性

micli.py 2-1

其中 2siid1piid(如果是 1 则可以省略),可从 spec 接口描述中查得。

6. 设置音量属性

micli.py 2=#60

siidpiid 规则同属性查询命令。注意 # 号的意思是整数类型,如果不带则默认是文本字符串类型,要根据接口描述文档来确定类型。

7. 动作调用:TTS 播报和执行文本

以下命令执行后小爱音箱会播报“您好”:

micli.py 5 您好

其中,5 为 siid,此处省略了 1aiid

以下命令执行后相当于直接对对音箱说“小爱同学,查询天气”是一个效果:

micli.py 5-4 查询天气 #1

其中 #1 表示设备语音回应,如果要执行默默关灯(不要音箱回应),可以如下:

micli.py 5-4 关灯 #0

8. 播放音乐

micli play ${mp3_url} 
micli pause

9. 播放音乐高级版

micli loop ${mp3_url}  # 循环播放
micli pause

# make a playlist name test.txt
cat test.txt
# http://192.168.6.212:8000/public/s4.mp3
# http://192.168.6.212:8000/public/s1.mp3
# http://192.168.6.212:8000/public/s2.mp3
# http://193.168.6.212:8000/public/s3.mp3

micli play_list test.txt # play the list

10. 其它应用

在扩展插件中使用,比如,参考 ZhiMsg 小爱同学 TTS 播报/执行插件

miservice's People

Contributors

kylezhang avatar sundy-li avatar xinzhi avatar yihong0618 avatar yonsm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

miservice's Issues

多个音响的使用方法?

目前的用户是通过 evn用户名密码设定的。micli 下达命令后,会给指定DID的设备下达。如果用户有多个音响,更好的管理方法会是怎样的?

本项目会考虑多音响需求吗?

谢谢作者。

一直报错we have no mi_did

$ micli list
we have no mi_did: please use micli mina to check
$ micli mina
we have no mi_did: please use micli mina to check

Login failed

image

export user 和pass设置后,登录失败,确定账号密码没有输入错误

Unable to install miservice

error PS C:\Projects\PythonProjects\AI\MiService> pip3 install miservice Collecting miservice Using cached miservice-2.0.1.tar.gz (12 kB) Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [21 lines of output]
Traceback (most recent call last):
File "c:\users\0real\appdata\local\programs\python\python39\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in <
module>
main()
File "c:\users\0real\appdata\local\programs\python\python39\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in m
ain
json_out['return_val'] = hook(**hook_input['kwargs'])
File "c:\users\0real\appdata\local\programs\python\python39\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 118, in g
et_requires_for_build_wheel
return hook(config_settings)
File "C:\Users\0real\AppData\Local\Temp\pip-build-env-exux2q9a\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_bui
ld_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "C:\Users\0real\AppData\Local\Temp\pip-build-env-exux2q9a\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "C:\Users\0real\AppData\Local\Temp\pip-build-env-exux2q9a\overlay\Lib\site-packages\setuptools\build_meta.py", line 480, in run_setup
super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
File "C:\Users\0real\AppData\Local\Temp\pip-build-env-exux2q9a\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
exec(code, locals())
File "", line 25, in
File "c:\users\0real\appdata\local\programs\python\python39\lib\pathlib.py", line 1256, in read_text
return f.read()
File "c:\users\0real\appdata\local\programs\python\python39\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 2062: character maps to
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

The last sentence suggests that this error is likely not a problem with pip.

小爱音箱适配问题

micli的play方法播放音乐,是否有音箱型号的限制?目前小爱触屏音箱无法使用,信号lx04

Sent from PPHub

micli启动后无反应

D:\Github\MiService-main>
[main 2023-04-07T07:16:10.277Z] [SharedProcess] using utility process
[main 2023-04-07T07:16:10.418Z] update#setState idle
[main 2023-04-07T07:16:11.575Z] [UtilityProcess type: shared-process, pid: <none>]: creating new...
[main 2023-04-07T07:16:11.579Z] [UtilityProcess id: 1, type: fileWatcher, pid: <none>]: creating new...
[main 2023-04-07T07:16:11.586Z] [UtilityProcess id: 1, type: extensionHost, pid: <none>]: creating new...
[main 2023-04-07T07:16:11.596Z] [UtilityProcess type: shared-process, pid: 16240]: successfully created
[main 2023-04-07T07:16:11.617Z] [UtilityProcess id: 1, type: fileWatcher, pid: 896]: successfully created
[main 2023-04-07T07:16:11.652Z] [UtilityProcess id: 1, type: extensionHost, pid: 14276]: successfully created
[main 2023-04-07T07:16:40.424Z] update#setState checking for updates
[main 2023-04-07T07:16:40.542Z] update#setState idle

到此就为止了,后面就一直没反应。

mute_xiaoai 设置true,但是仍然回复

这个mute_xiaoai参数,设置true后,使用关键字提问题,小爱同学本身还是会回答大约5-7个字才停止。
效果上和发送一个无法播放的文字来打断正在播放是一样的。
是我操作问题吗?有没有真正意义上的不让小爱回复。
使用静音来间接达到效果,但是也是伪静音,只是声音很小而已。

'MiNAService' object has no attribute 'play_by_url'

micli sunomicli play /storage/emulated/0/Download/故事的最结尾mno/故事的最结尾 MMO.wav都出现了找不到"play_by_url"的错误,请求micli suno时返回了音乐列表,但由于这个错误播放失败了

执行./micli.py list报错

image
执行报错如下
./micli.py: line 1: from: command not found
./micli.py: line 6: syntax error: unexpected end of file
求解,谢谢

语音不连贯

同样的是L05C,配置上了以后 觉得gpt返回的消息很快,但是小爱读的语句很慢,如果有逗号或者句号 简短差不多能有2-3秒,体验不太好.

这个问题可以解决吗?

谢谢了

micli.py 5-4 查询天气 #1 返回 -704220025

我试了下5-5也不行,我的是lx06
Intelligent_Speaker = 5
_Text_Content = 1
_Silent_Execution = 2 # bool
Sleep_Mode = 3 # bool # rwn
Audio_Id = 4 # rn

_Play_Text = 1  # in=[1]
_Play_Music = 2
_Wake_Up = 3
_Play_Radio = 4
_Execute_Text_Directive = 5  # in=[1, 2]

账号密码的问题总是这样

Exception on login None: {'qs': '%3Fsid%3Dxiaomiio%26_json%3Dtrue', 'code': 70016, 'description': '登录验证失败', 'securityStatus': 0, '_sign': '0psXfr43eNI0IX6q9Suk3qWbRqU=', 'sid': 'xiaomiio', 'result': 'error', 'captchaUrl': None, 'callback': 'https://sts.api.io.mi.com/sts', 'location': '', 'pwd': 0, 'child': 0, 'desc': '登录验证失败'}
Traceback (most recent call last):
File "/home/linux1/.local/lib/python3.10/site-packages/miservice/miaccount.py", line 69, in login
raise Exception(resp)
Exception: {'qs': '%3Fsid%3Dxiaomiio%26_json%3Dtrue', 'code': 70016, 'description': '登录验证失败', 'securityStatus': 0, '_sign': '0psXfr43eNI0IX6q9Suk3qWbRqU=', 'sid': 'xiaomiio', 'result': 'error', 'captchaUrl': None, 'callback': 'https://sts.api.io.mi.com/sts', 'location': '', 'pwd': 0, 'child': 0, 'desc': '登录验证失败'}
Error https://api.io.mi.com/app/home/device_list: Login failed
linux1@gongzhonghao-xiaomi:~/MiService$

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.