npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

mclimate-payload-helper

v1.2.21

Published

Mclimate payload helper

Downloads

779

Readme

mclimate-payload-helper

Utilities for working with MClimate IoT device payloads. The package exposes TypeScript helpers to parse uplink payloads, construct downlink command payloads, and reuse the enums/schemas that describe each supported device family.

Features

  • Typed uplinkPayloadParser that converts raw payload buffers into structured data for every supported DeviceType.
  • Command builders and enums for devices such as Vicki, Relay 16, TFlood, CO₂ sensors, thermostats, and more.
  • Shared error helpers (CustomError) and validation schemas so client apps can keep business logic consistent with the firmware payload contracts.

Installation

npm install mclimate-payload-helper

The library ships TypeScript declarations, so no extra typings package is required.

Usage

import { uplinkPayloadParser, CommandBuilder, DeviceType } from 'mclimate-payload-helper'

const uplink = uplinkPayloadParser({
	deviceType: DeviceType.Relay16,
	payloadHex: '0100aa34ff...',
})

const command = new CommandBuilder()
	.forDevice(DeviceType.Vicki)
	.useCommand('setTargetTemperature')
	.withPayload({ temperature: 22 })
	.build()

Refer to the src/decoders and src/encoders directories for the complete list of parsers, commands, enums, and helper functions.

Pre-commit hooks

Husky enforces repository quality gates before every commit (.husky/pre-commit):

  1. npm run format:check – Prettier formatting guard.
  2. npm run type-check – Ensures the TypeScript project still compiles.
  3. npm run lint – ESLint with the repo ruleset.
  4. npm run test – Jest unit tests.

If a hook fails, fix the issue locally before committing again.

Publishing a new version

  1. Bump the version in package.json (or run npm version patch|minor|major which updates the lockfile and creates a git tag).
  2. Run the full quality suite locally (npm run format, npm run lint, npm run type-check, npm test) and ensure npm run build succeeds.
  3. Publish the package with npm publish. The prepublishOnly script will rebuild the dist folder automatically.

Skipping the version bump will cause npm publish to fail, so always increment the version before publishing.

Testing approach

Unit tests live next to their encoders in src/encoders (e.g., Relay16Commands.ts and Relay16Commands.test.ts). For each command class with set commands:

  • All set commands are exercised with exact BaseCommand payload expectations (command id + hex params).
  • CommandBuilder is used when the device is available there, so registry routing and camel-casing are covered.
  • Each suite includes at least one validation error case to ensure zod schema failures surface as CustomError.

Mixin-only classes are covered via the concrete implementations they extend; only classes with distinct command surfaces get their own suite. GeneralCommands is also tested to validate shared helpers like custom hex, keepalive, uplink type, and watchdog parameters.

  • Decoder tests remain consolidated in src/test/payloadDecoders.test.ts.

Adding encoder commands with AI helpers

Two interactive guides exist to speed up encoder additions:

  • add-encoder-command-existing.md: walks through adding commands to an existing device class (prompts for command names, params, BaseCommand payloads, schema updates, mixins, and exclusions).
  • add-encoder-command-new.md: guides creating a brand-new device class, wiring it into CommandBuilder, and adding schemas/types and mixins.

Both scripts explain the expected file locations (src/encoders, src/encoders/types/schemas.ts), import style (@/...), and validation patterns (Zod + CustomError). Use them as a step-by-step checklist.