A CommonJS Node.js module for hOn authentication and air conditioner controls.
- Speed: cached AC preset runs take about 1 second.
- CLI: easy to set up and use.
- Module: easy to reuse in other projects.
This project is a Node.js port of Andre0512/pyhOn, which was originally developed by Andre0512 under the MIT License.
All credit for the original implementation goes to Andre0512. This version reimplements the library in Node.js and may differ in API and functionality to better suit the JavaScript ecosystem.
After this package is published, install it globally:
npm install -g node-honThen create a working config in the installed package folder or run from a checkout that has config.js, presets, and cache files available.
-
Clone or download this repository.
-
Install dependencies:
npm install- Create your local config:
cp config_example.js config.js-
Edit
config.jsand set your hOn account values. -
Install this checkout as a global npm command:
npm install -g .- Confirm the CLI is available:
node-hon listList available air conditioners:
node-hon listApply a preset by MAC address:
node-hon apply xx-xx-xx-xx-xx-xx preset_fanApply a preset by AC name:
node-hon apply Bedroom preset_fanTurn an AC off:
node-hon apply bedroom offGenerate a preset interactively from live hOn capabilities:
node-hon generate-presetPurge cached session and appliance command data:
node-hon purge-cacheThe AC identifier can be a MAC address, unique ID, or nickname. Nickname lookup is case-insensitive, so Bedroom and bedroom can both match the same AC.
Generated and bundled presets live in presets/. Preset names are passed without .json, for example preset_fan loads presets/preset_fan.json.
Runtime cache files live under cache/ by default, including session and appliance command cache data. Run node-hon purge-cache, or set forceApplianceCacheRefresh: true in config.js, when the appliance command model changes or a preset cannot find a parameter that exists in the app.
You can also run the CLI scripts directly from the repository:
node cli/show_my_ac_devices.js
node cli/ac_generate_preset.jsac_generate_preset.js loads the latest AC capabilities from the hOn API. You can set AC_ID or PRESET_NAME to preselect the air conditioner or output preset name.
npm testBefore publishing, make sure you are logged in:
npm login
npm whoamiVerify the package:
npm test
npm run typecheck
npm pack --dry-runPublish:
npm publish --access publicThis project is released under the MIT License.
The original Python library is also MIT-licensed. See the LICENSE file for details and attribution.