How nitaybz/homebridge-tami4 works
Project type and purpose
• This is a Node.js “platform” plugin for the [Homebridge](https://github.com/nfarina/homebridge) ecosystem, named homebridge-tami4. Its purpose is to expose a Tami4 Edge+ water purifier’s capabilities (lighting, heating, night mode, etc.) as HomeKit accessories.
File structure
Top-level files
• index.js – Plugin entry point: registers the “Tami4” platform with Homebridge.
• config-sample.json & config.schema.json – Sample and JSON-schema for plugin configuration (refreshToken, feature flags, polling interval, debug).
Directories
• homebridge-ui/
– server.js – Express‐style server to serve plugin settings UI inside Homebridge/Hoobs.
– public/index.html – React/vanilla HTML UI shell for collecting refreshToken & settings.
• homekit/
– StateManager.js – Caches and normalizes Tami4 state, debounces HomeKit updates.
– device.js – Constructs HomeKit switch/accessory objects, implements the HomeKit API handlers.
• tami4/
– api.js – Wraps REST calls to Tami4 Edge cloud (login, device status, control commands).
– syncHomeKitCache.js – Sync logic between remote cloud state and local HomeKit state cache.
README for additional insights
• The plugin “platform” polls Tami4 Edge cloud at a configurable interval (statePollingInterval) using a long-lived refreshToken.
• Incoming state updates drive HomeKit accessory updates. User actions in HomeKit translate to REST calls back to the Tami4 cloud.
• The Homebridge UI plugin portion is responsible only for obtaining and storing the refreshToken and initial plugin settings.