Skip to content

flaxes/node-hon

Repository files navigation

hOn Node.js AC Controls

A CommonJS Node.js module for hOn authentication and air conditioner controls.

Advantages

  • Speed: cached AC preset runs take about 1 second.
  • CLI: easy to set up and use.
  • Module: easy to reuse in other projects.

About This Project

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.

Install From NPM

After this package is published, install it globally:

npm install -g node-hon

Then create a working config in the installed package folder or run from a checkout that has config.js, presets, and cache files available.

Global CLI Setup From This Repo

  1. Clone or download this repository.

  2. Install dependencies:

npm install
  1. Create your local config:
cp config_example.js config.js
  1. Edit config.js and set your hOn account values.

  2. Install this checkout as a global npm command:

npm install -g .
  1. Confirm the CLI is available:
node-hon list

CLI Usage

List available air conditioners:

node-hon list

Apply a preset by MAC address:

node-hon apply xx-xx-xx-xx-xx-xx preset_fan

Apply a preset by AC name:

node-hon apply Bedroom preset_fan

Turn an AC off:

node-hon apply bedroom off

Generate a preset interactively from live hOn capabilities:

node-hon generate-preset

Purge cached session and appliance command data:

node-hon purge-cache

The 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.

Development CLI

You can also run the CLI scripts directly from the repository:

node cli/show_my_ac_devices.js
node cli/ac_generate_preset.js

ac_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.

Tests

npm test

Publishing

Before publishing, make sure you are logged in:

npm login
npm whoami

Verify the package:

npm test
npm run typecheck
npm pack --dry-run

Publish:

npm publish --access public

License

This project is released under the MIT License.
The original Python library is also MIT-licensed. See the LICENSE file for details and attribution.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors