当前位置: 首页 > 软件库 > 其他开源 > 物联网 >

homebridge-rusty-spotify

Spotify plugin for Homebridge written in Rust
授权协议 MIT License
开发语言 JavaScript
所属分类 其他开源、 物联网
软件类型 开源软件
地区 不详
投 递 者 云建木
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

homebridge-rusty-spotify

Spotify plugin for Homebridge written in Rust.The plugin requires a Spotify Premium account.

Installation and Setup

  1. Install Homebridge: sudo npm install -g homebridge
  2. Install the plugin: sudo npm install -g homebridge-rusty-spotify
  3. Register the plugin as app in the Spotify Developer Dashboard
    1. Login
    2. Select "Create a client ID"
    3. Provide a name and description in the pop-up; click "Next"
    4. Copy the "Client ID" and "Client Secret" which will be required in the following configuration step
    5. Click "Edit Settings"
    6. Add http://localhost/callback as "Redirect URI" and save
  4. Configure the plugin using the generated client ID and client secret (see Configuration)

Configuration

The generate_config script can be used to generate the config. It requires for the client_id, client_secret andSpotify username needs to be set since those are required to authenticate to the Spotify Web API. To run the script,make sure to have Python 3 and the spotipylibrary installed.

Running the script will open a web browser asking to authenticate to Spotify which is required to retrieve the refresh_token.

$ ./generate_config --help
usage: generate_config [-h] [--client_id CLIENT_ID]
                       [--client_secret CLIENT_SECRET]
                       [--redirect_uri REDIRECT_URI] [--username USERNAME]

Script to retrieve an access and refresh token for using the Spotify API

optional arguments:
  -h, --help            show this help message and exit
  --client_id CLIENT_ID, --client-id CLIENT_ID
                        Spotify client ID
  --client_secret CLIENT_SECRET, --client-secret CLIENT_SECRET
                        Spotify client secret
  --redirect_uri REDIRECT_URI, --redirect-uri REDIRECT_URI
                        Redirect URI
  --username USERNAME   Spotify username


$ ./generate_config --client_id=<client_id> --client_secret=<client_secret> --username=<username>
  {
    "platform": "Spotify",
    "name": "Spotify",
    "service_type": "light",    // "light" or "speaker"; Speaker is not supported by HomeKit
    "client_id": "<client_id>",
    "client_secret": "<client_secret>",
    "refresh_token": "<refresh_token>"
  }

The generated config needs to copied to the Homebridge config file (e.g. ~/.homebridge/config.json). For example:

//...
"platforms": [
  {
    "platform": "Spotify",
    "name": "Spotify",
    "service_type": "light",    // "light" or "speaker"; Speaker is not supported by HomeKit
    "client_id": "<client_id>",
    "client_secret": "<client_secret>",
    "refresh_token": "<refresh_token>",
  }
]
//...

service_type specifies whether Spotify devices should use the Lightbulbor Speaker service. If service_type is not specified, "light" will be used by default.HomeKit currently does not support Speaker services and will show "This accessory is not certified and may not work reliably with HomeKit".

Usage

Add the plugin in the Home app. The plugin will automatically discover available Spotifydevices and add them as accessories.Turning a Spotify accessory on will resume playing music on the device, turning off theaccessory will pause the music. The accessory also allows to change the playback volume.

Accessories get refreshed every 10 seconds (or as specified in the configuration file).

Development

  1. Install the Rust toolchain, wasm-pack, cargo-generate and npm by following this guide
  2. Clone the repository
  3. Run make
    • This will create a pkg/ directory containing all the generated nodejs files
  4. Copy the generated files to a device/directory that can be discovered by Homebridge
  5. Switch to the directory and run npm install to install all required dependencies
  6. Run Homebridge in debug mode and specify the directory with the plugin files: DEBUG=* homebridge -D -P /path/to/plugin/homebridge-rusty-spotify

A blog post about writing plugins for Homebridge and specifically this plugin has been published here.

 相关资料
  • Rusty-blockparser Rust 写的多线程比特币区块链解析库。它允许从基于比特币的区块链中提取各种数据类型。 特点 回调 回调建立在核心解析器之上,可以用以提取特定类型的信息。 多线程 支持多线程优化资源利用,可用 --threads 配置。 内存占用低 大约 1.3GB 内存即可运行。要进一步减少内存占用,可以使用更低的 --backlog 值,最小内存仅需 500MB。 脚本评估

  • Homebridge 是一个轻量级 NodeJS 服务器,它模拟 iOS HomeKit API,提供从 HomeKit 到“智能家居”设备制造商提供的各种第三方 API 的基本桥接。通过 Homebridge 的桥接,可以让 Siri 控制完全不支持 HomeKit 的设备。 此外 Homebridge 支持插件。

  • homebridge-vsx homebridge-vsx is a plugin made for homebridge,which allows switching on and off your Pioneer AV receiver. All AV receivers (VSX and SC),which work with the iControl AV5 App are support

  • homebridge-sesame Control and monitor your Sesame smart lock with HomeKit integration. Prerequisites Installation of Homebridge iOS 11 or later Sesame lock with enabled cloud integration Sesame Wifi A

  • homebridge-panasonictv A homebridge plugin for turning on and off your Panasonic Viera TV. The plugin also has experimental support for changing the volume and channel. These characteristics are not r

  • Quick Start | Contribute A Wake on Lan plugin for Homebridge Turn your PCs, laptops, servers and more on and off through Siri Quick Start To install the plugin, head over to the machine with Homebridg