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 🙏

© 2024 – Pkg Stats / Ryan Hefner

cncjs-mqtt

v0.2.0

Published

An mqtt/websocket adapter for cncjs

Downloads

15

Readme

cncjs-mqtt

Connect cncjs to an mqtt pendant. This could be used to connect it to your home automation system like home assistant. Useful for adding monitoring dashboards or automation.

This is based on work started by https://git.maglab.space/fooker/cncjs-pendants/blob/master/cncjs-status-mqtt

TAKE NOTE: This is still very much a work in progress, any updates before 1.0 probably won't be backwards compatible.

Installation

$ npm install -g cncjs-mqtt

Running

cncjs-mqtt \
  --cncjs-address 'localhost' \
  --cncjs-port '8000' \
  --secret 'your secret from .cncrc' \
  --mqtt-address 'mqtt.server.local' \
  --mqtt-username 'cncjs mqtt username' \
  --mqtt-password 'secret stuff' \
  --mqtt-port '1883' \
  --port '/path/to/port'

You can omit --secret if you're running in the user folder with .cncrc in it.

Using PM2

pm2 start cncjs-mqtt -- \
  --cncjs-address 'localhost' \
  --cncjs-port '8000' \
  --secret 'your secret from .cncrc' \
  --mqtt-address 'mqtt.server.local' \
  --mqtt-username 'cncjs mqtt username' \
  --mqtt-password 'secret stuff' \
  --mqtt-port '1883' \
  --port '/path/to/port'

You can omit --secret if you're running in the user folder with .cncrc in it.

Integration with home Assistant

Since discovery isn't implemented yet, you'll have to manually implement the sensors in your configuration.yaml.

sensor:
  - platform: mqtt
    name: Cnc Controller State
    state_topic: "<base topic>/state"
    value_template: "{{ value_json.status.activeState }}"
    json_attributes_topic: "<base topic>/state"
    json_attributes_template: "{{ value_json | tojson }}"
  - platform: mqtt
    name: Cnc Controller Program Status
    state_topic: "<base topic>/sender"
    value_template: "{{ value_json.name }}"
    json_attributes_topic: "<base topic>/sender"
    json_attributes_template: "{{ value_json | tojson }}"
  - platform: mqtt
    name: Cnc Controller Instruction Queue
    state_topic: "<base topic>/feeder"
    value_template: "{{ value_json.queue }}"
    json_attributes_topic: "<base topic>/feeder"
    json_attributes_template: "{{ value_json | tojson }}"
  - platform: mqtt
    name: Cnc Controller Settings
    state_topic: "<base topic>/settings"
    value_template: "{{ value_json.version }}"
    json_attributes_topic: "<base topic>/settings"
    json_attributes_template: "{{ value_json.settings | tojson }}"
  - platform: mqtt
    name: Cnc Controller Task Status
    state_topic: "<base topic>/task"
    value_template: "{{ value_json.action }}"
    json_attributes_topic: "<base topic>/sender"
    json_attributes_template: "{{ value_json.state | tojson }}"

This would create 5 sensors that looks something like:

sensor.cnc_controller_state

State: Idle (current activity state)

Attributes:

parserstate:
  feedrate: '0'
  modal:
    coolant: M9
    distance: G90
    feedrate: G94
    motion: G0
    plane: G17
    spindle: M5
    units: G21
    wcs: G54
  spindle: '0'
  tool: '0'
status:
  activeState: Alarm
  buf:
    planner: 14
    rx: 128
  feedrate: 0
  mpos:
    x: '0.000'
    'y': '0.000'
    z: '0.000'
  ov:
    - 100
    - 100
    - 100
  spindle: 0
  subState: 0
  wco:
    x: '-802.530'
    'y': '-731.260'
    z: '-67.782'
  wpos:
    x: '802.530'
    'y': '731.260'
    z: '67.782'
friendly_name: Cnc Controller State

sensor.cnc_controller_program_status

State: my_gcode.nc (Name of program)

Attributes:

context: {}
elapsedTime: 0
finishTime: 0
hold: false
holdReason: null
name: 'my_gcode.nc'
received: 0
remainingTime: 0
sent: 0
size: 0
sp: 1
startTime: 0
total: 0
friendly_name: CNC Controller Program Status

sensor.cnc_controller_instruction_queue

State: 0 (Queue size)

Attributes:

changed: false
hold: false
holdReason: null
pending: false
queue: 0
friendly_name: CNC Controller Instruction Queue

sensor.cnc_controller_settings

State: 1.1f (reported firmware version)

Attributes:

$0: '10'
$1: '255'
$10: '255'
$100: '39.660'
$101: '40.120'
$102: '200.000'
$11: '0.020'
$110: '10000.000'
$111: '10000.000'
$112: '1000.000'
$12: '0.010'
$120: '500.000'
$121: '500.000'
$122: '270.000'
$13: '0'
$130: '849.000'
$131: '850.000'
$132: '95.000'
$2: '0'
$20: '1'
$21: '0'
$22: '1'
$23: '0'
$24: '100.000'
$25: '2000.000'
$26: '25'
$27: '3.000'
$3: '2'
$30: '1000'
$31: '0'
$32: '0'
$4: '0'
$5: '0'
$6: '0'
friendly_name: CNC Controller Settings

sensor.cnc_controller_task_status

State: started (last action)

Attributes:

action: started
state: No idea what goes in here TBH
friendly_name: CNC Controller Task Status