14 Commits

Author SHA1 Message Date
dc2cd4ec4c Update comment 2025-03-21 12:03:20 -05:00
b37f96fc08 Update SetHeatMode to support other heater types
Thanks to @afri in #1
2025-03-21 12:03:07 -05:00
458048b58a Reinstate ws WebSocket library
All checks were successful
Node.js CI / build (18.x) (push) Successful in 16m17s
Node.js CI / build (20.x) (push) Successful in 11s
Node.js CI / build (22.x) (push) Successful in 11s
In some environments, such as MagicMirror modules, the WebSocket class is not defined. This is apparently a client-only class and generally only exists in browsers, but I'm confused how the unit tests were passing when run against just node. Either way, this means we have to disable the test again since ws is not compatible with jest-websocket-mock, and I haven't found an alternative mock server that is.
2025-01-25 12:06:01 -06:00
f8e2aa0f3e Get basic test up and passing
This replaces the 'ws' library with built-in websockets so that we can mock a server and successfully connect to it. A simple test verifies that Unit is handling a message request and response as we expect it to.
2025-01-13 13:06:58 -06:00
7976348197 Pass error along with error event
All checks were successful
Node.js CI / build (18.x) (push) Successful in 11s
Node.js CI / build (20.x) (push) Successful in 10s
Node.js CI / build (22.x) (push) Successful in 11s
2025-01-08 21:16:46 -06:00
2ffed2204b Fix timeouts and errors not emitting "close" 2025-01-08 21:11:45 -06:00
617c8df511 Add support for tests
I was trying to make a websocket test, but the "ws" library doesn't appear to be easily mocked and I prefer to use it over the built-in WebSocket. So we'll see what I can do in the future.
2025-01-08 21:04:50 -06:00
f657b8e8aa Minor formatting update
All checks were successful
Node.js CI / build (18.x) (push) Successful in 27s
Node.js CI / build (20.x) (push) Successful in 8s
Node.js CI / build (22.x) (push) Successful in 9s
2025-01-07 00:14:40 -06:00
ddabc810c2 Copy linted files to their destinations 2025-01-05 17:00:07 -06:00
3149e42e46 Attempt to populate package.jsons in a more portable way 2025-01-05 16:58:12 -06:00
1f3bf02518 Use GetRequest helper method
This ensures we populate `messageID` and is generally a good "best practice" to use in example code.
2025-01-05 16:43:18 -06:00
3d4d6b930b Minor type/doc update
I've seen this STATUS parameter have different values with some messages, so it no longer makes sense to attempt to lock in the type to one of these strings.
2025-01-05 16:20:49 -06:00
3e40e015d9 Add list-objects script
This can be used to find all the controllable circuits in your system.

When invoked with `npm run list-objects` or `node esm/list-objects.js` it will search for units, then request and format+display the objects to the user. There are a few arguments available:
* --controllerAddr=1.2.3.4
  * Specifies the IntelliCenter controller's address directly which skips the searching phase.
* --controllerPort=1234
  * Specifies the port to use when connecting to the controller (probably should never use this; does nothing if --controllerAddr is not specified)
* --multicastAddr=1.2.3.4
  * Specifies the address of the network interface to send the multicast search packet on (useful if you have multiple adapters/interfaces and the system is picking the wrong one; does nothing if --controllerAddr is specified)
* --onlyToggleable
  * Only displays objects which can be toggled on or off

Note that if you are invoking this with `npm run list-objects` then the arguments must be specified after an empty `--` so that they are given to the script rather than npm itself. Example: `npm run list-objects -- --controllerAddr=10.0.0.41 --onlyToggleable`
2025-01-05 16:20:49 -06:00
c445a844ee Split into commonjs and ESM outputs
This allows require() and import to work for even better compatibility between CJS and ESM consumers.

I dislike that this kills our ability for top-level awaits in example.ts, but seeing as how my primary use case for this library is a commonjs module, I think this is a fair trade-off.

Also changed "messages" to not encapsulate its export under the name "messages" to remove some repetition in importing "messages" and still needing to do "messages." to get the methods out. Now it's simple to import each message by name or group them under something like "messages" as desired on a per-library-user basis.

Refs:
* https://www.kravchyk.com/typescript-npm-package-json-exports/
* https://arethetypeswrong.github.io/
* https://evertpot.com/universal-commonjs-esm-typescript-packages/
2025-01-05 15:34:07 -06:00