Skip to content

liuzikai/homebridge-divergence-meter

Repository files navigation

Homebridge Steins;Gate Divergence Meter

Control Sadudu's Steins;Gate Divergence Meter through Homebridge.

Home View

Features

This plugin models the meter as a TV with input sources as display modes.

  • Soft power off
  • Clock modes with time synchronization
  • Gyroscope mode
  • Controlled random worldline
    • Result memorized
    • Customizable random range
  • Unlimited customized worldlines
  • Auto sleep

Getting Started

Prerequisites

This plugin uses Noble, a Node.js BLE library, to communicate with the meter. On Linux, the following dependencies should be installed:

sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev

For more details and descriptions for other platforms, please see the Noble documentation.

Installation

Install the plugin through the Homebridge UI, or through commandline:

npm install -g homebridge-divergence-meter

Add Accessories to Home

The meter is modeled as a TV. Due to the limitation of HomeKit, Television services can only be published as external accessories, which need to be added to Home manually.

Open the Home app - Add or Scan Accessory - More options... - Select the "Divergence Meter" TV - Enter the setup code shown in Homebridge log:

Please add [Divergence Meter XXXX] manually in Home app. Setup Code: XXX-XX-XXX

This plugin adds a Television with its input sources as display modes. Turning off the device is a soft power off, i.e. the nixie tubes are off but the device is still on.

This plugin also adds a switch for random worldline. Turn on the switch to start randomization. Turn off to settle.

NOTICE: Due to the lack of a read-back interface, this plugin can be out-of-sync with the actual device. It is not aware of external changes: turning on/off physically, pressing the physical buttons, or changes made by the mini program. In those cases, auto-off will not work, and the accessory status may be out-of-sync.

Controlled Random Worldline

The meter can generate random worldlines (by pressing the leftmost button for example). In this plugin, this function is achieved by the random worldline button (described above). The result is not stored.

In addition, this plugin introduces a controlled random mode. When in the "Saved Random" mode, the random worldline is generated by the plugin. The range is configurable (see below, even negative divergence is possible!) and the results are memorized.

Configuration

Configure the plugin through the Homebridge UI, or dd the following part to the "platforms" section of your Homebridge config:

{
    "name": "Divergence Meter",
    "use24H": true,
    "autoOff": true,
    "autoOffTime": 300,
    "randomSwitchName": "Random Worldline",
    "randomMin": 0,
    "randomMax": 0.999999,
    "worldlines": [
        "1.048569",
        "3.141592"
    ],
    "scanningRestartDelay": 10000,
    "platform": "DivergenceMeter"
}
Key Description Default
name TV Accessory name. Divergence Meter
use24H Use 24-hour mode for time display. true
autoOff If enabled, turn off the Divergence Meter after some time since the last operation (turning on, changing mode). Due to the lack of the read-back interface, this plugin is not aware of external changes to the meter: turning on/off physically, pressing the physical buttons, or changes made by the mini program. In those cases, auto-off will not work. true
autoOffTime Time for auto-off in seconds. 300
randomSwitchName Name of the switch for random worldlines. Random Worldline
randomMin Minimum value for controlled random worldline described above. Can be negative. 0
randomMax Maximum value for controlled random worldline described above. 0.999999
worldlines Customized worldlines. Must be 8-character long. Characters other than 0-9 and '.' turn off the nixie tube. When changing the number of customized worldlines, newly added input sources in Home may not be named correctly. Try removing and re-adding the accessory if it doesn't work.
scanningRestartDelay Delay to restart BLE scanning if interrupted. When multiple plugins use BLE, they may interfere with each other. If that is the case, try increasing this number. 10000
platform Must be DivergenceMeter.

Compatibility with the Physical Buttons and the WeChat Mini Program

Due to the lack of a read-back interface, this plugin is not aware of external changes: turning on/off physically, pressing the physical buttons, or changes made by the WeChat mini program. In those cases, auto-off will not work, and the accessory status may be out-of-sync. So generally, this plugin is not expected to be used alone.

As both this plugin and the WeChat mini program use the same BLE protocol, only one of them can connect at the same time (as long as this plugin is enabled and started, even if the accessory is not added to Home). Disable this plugin first before using the mini program.

Internally, customized worldline 1 and 2 is mapped to the original customized worldline 1 and 2. Worldline 3 is the saved random. Worldline 4 is the software off. Physical worldline buttons on the meter are updated once the corresponding worldlines are set once (but remember that this plugin is not aware of physical actions).