-
-
Notifications
You must be signed in to change notification settings - Fork 664
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
feat: 增加小爱音箱通过url播放歌曲的服务 #1261
feat: 增加小爱音箱通过url播放歌曲的服务 #1261
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感谢PR!
希望通过MiotMediaPlayerEntity.play_media
来实现播放功能,可以参考:
hass-xiaomi-miot/custom_components/xiaomi_miot/media_player.py
Lines 768 to 781 in 1bf6ab6
def play_media(self, media_type, media_id, **kwargs): | |
"""Play a piece of media.""" | |
tim = str(int(time.time() * 1000)) | |
pms = { | |
'action': 'play', | |
'type': media_type, | |
'url': media_id, | |
'apikey': self._api_key, | |
'ts': tim, | |
'sign': hashlib.md5(f'mitvsignsalt{media_id}{self._api_key}{tim[-5:]}'.encode()).hexdigest(), | |
} | |
rdt = self.request_mitv_api('controller', params=pms) | |
self.logger.info('%s: Play media: %s', self.name_model, [pms, rdt]) | |
return not not rdt |
service: media_player.play_media
data:
entity_id: media_player.xiaoai_x08c_d135
media_content_type: music
media_content_id: https://click33.gitee.io/xixi/bg.mp3 在我的小爱音响上执行后没有反应🤣。 2023-08-20 02:53:17.727 INFO (MainThread) [custom_components.xiaomi_miot.media_player] 客厅触屏小爱(xiaomi.wifispeaker.x08c): Play media: [{'deviceId': '297a063e-xxxx-xxxx-xxxx-b03f006c1c48', 'path': 'mediaplayer', 'method': 'player_play_url', 'message': '{"url": "https://click33.gitee.io/xixi/bg.mp3", "type": 1, "media": "app_ios"}'}, {'code': 0, 'message': "Msg has been successfully proxy to the device, this service is a simple proxy, if you encounter any problems pls contact ROM's developers directly!!!", 'data': {'code': 0}}] |
使用下面的格式在我的小爱音箱Pro上正常播放: service: media_player.play_media
data:
media_content_id: https://click33.gitee.io/xixi/bg.mp3
media_content_type: music
target:
entity_id: media_player.xiaomi_lx06_3ec7_play_control |
以上服务执行之后我的小爱play 增强版没有反应。是否对小爱的版本有要求 |
大佬,你好,这个在我的小爱art可以正常播放,但是在小爱触屏版和智能家庭屏上也什么反应都没有 |
大佬,最近不知道是更新了什么导致的,播放音乐会一直重复播放 |
增加一个小爱音箱通过url播放歌曲的服务, 可以配合nas使用