第一次在这里使用HomeKit。
我有飞利浦色调,使用Siri (HomeKit)我用我的声音激活不同的场景/环境,这真的很酷。
我想再走一步。
在HomeKit中,我看到我们可以使用地形仪,风扇,灯,门,窗帘,背带,警报器,传感器.但我看到创造环境的一个关键元素是缺少的:音乐。
我知道使用Hue可以创造环境,比如沙滩日落,用红色和橙色作为灯光,但同时我也想播放一个特定的播放列表,比如大海或海浪的声音,或者仅仅是夏威夷音乐。可能性可能是无限的和超酷的。
我该怎么做?
我是否必须创建自己的应用程序,使用HomeKit和Spotify API或?
我的想法是使用Siri (即灯和音乐)启动环境,但我不知道我想要的在技术上是否可行。
有什么建议吗?那就太棒了。
发布于 2016-05-02 19:19:36
您可以很容易地使用AppleScript (如果您使用Macintosh,即.)下面是一些示例AppleScript代码,您可以从这里开始。(将此代码粘贴到脚本编辑器窗口。)
-- define baseUrl to point to your Hue hub address and one of the keys in your whitelist
set baseUrl to " http://YOUR-HUB-IP/api/YOUR-WHITELIST-ENTRY"
-- read the info about light 1
set lightJson to do shell script "curl " & baseUrl & "/lights/1"
-- define some JSON to set a light state
set lightStateOn to the quoted form of " {\"on\": true,\"bri\": 254,\"hue\": 8000,\"sat\": 254} "
-- send the JSON to set a light state (on and with specified hue, saturation, and brightness)
do shell script "curl --request PUT --data " & lightStateOn & baseUrl & "/lights/1/state/"
tell application "Spotify"
play track "spotify:track:3AhXZa8sUQht0UEdBJgpGc"
end tell
set lightStateOff to the quoted form of "{\"on\": false}"
do shell script "curl --request PUT --data " & lightStateOff & baseUrl & "/lights/1/state/"编辑baseUrl以包含集线器的真实IP和集线器JSON文件中的白名单(用户)中的一个键。
然后编写curl命令脚本,以获取或发送JSON到集线器,这会改变您的灯光。
最后,Spotify和iTunes都是可编写脚本的,因此您可以告诉它们播放歌曲、播放列表等。请参阅http://dougscripts.com/了解有关脚本iTunes的更多信息。
您也可以在其他语言和平台中这样做,这取决于您的硬件和技能。语法将是不同的,但策略是相似的:发送命令来控制色调集线器,然后发送其他命令来控制音乐播放器。
发布于 2017-05-23 17:29:57
我也面临着同样的问题,所以我决定开发自己的应用程序。实际上,这是一个Mac,它使用AppleScript连接到您的Spotify桌面应用程序,并获取Spotify API,以便将灯光与音乐完美地同步。这是基本的,但非常准确,完全免费:
https://itunes.apple.com/fr/app/lightshow/id1217138942?l=en&mt=12
https://stackoverflow.com/questions/36981659
复制相似问题