jarvis

package module
v0.0.0-...-0d17c7f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 7 Imported by: 0

README

Build Docker Build hairyhenderson/jarvis_exporter on DockerHub

jarvis_exporter

A Prometheus exporter for the Fully Jarvis standing desk. With a bit of simple custom hardware, it can export the desk's current height, as a Prometheus metric!

Based on the excellent reverse-engineering done by @phord at https://github.com/phord/Jarvis.

Docker Images available for Linux on x86-64, arm64, armv7 (Raspberry Pi), and armv6 (Pi Zero) platforms.

Dashboard configuration

With jarvis_exporter, you can create a Grafana dashboard that looks like this:

Grafana dashboard displaying stand/sit ratio and other metrics

This dashboard has been exported to `dashboard/desk_metrics.json.

Note that this dashboard in particular also uses some metrics exported by a simple script that I wrote to export the display brightness (and whether or not the display is asleep). It's scheduled to run every minute via cron, and uses the brightness tool to read the current brightness. The output is then scraped by node_exporter's textfile collector.

Hardware

A description of the hardware I've put together is coming soon, but for now see this discussion for some hints!

TODO

  • Support multiple UARTs for reading from both handset & desk (probably on a Raspberry Pi)

License

The MIT License

Copyright (c) 2021-2023 Dave Henderson

Documentation

Index

Constants

View Source
const (
	Height    uint8 = 0x01 // Height report (in mm, P0/P1, P2 unused - always 0xf)
	LimitResp uint8 = 0x20 // Max-height set/cleared; response to SetMax (0x21)
	GetMax    uint8 = 0x21 // Report max-height; [P0,P1] = max-height (c.f. SetMax)
	GetMin    uint8 = 0x22 // Report min-height; [P0,P1] = min-height
	LimitStop uint8 = 0x23 // Min/Max reached (0x01 "Max-height reached", 0x02 "Min-height reached")
	Reset     uint8 = 0x40 // Indicates desk in RESET mode; Displays "RESET"
	Preset    uint8 = 0x92 // Moving to Preset location ([0x4,0x8,0x10,0x20] mapping to presets [1,2,3,4])
)

Commands sent by desk

View Source
const (
	ProgMem1   uint8 = 0x03 // Set memory position 1 to current height
	ProgMem2   uint8 = 0x04 // Set memory position 2 to current height
	ProgMem3   uint8 = 0x25 // Set memory position 3 to current height
	ProgMem4   uint8 = 0x26 // Set memory position 4 to current height
	Units      uint8 = 0x0e // Set units to cm/inches (param 0x00 == cm, 0x01 == in)
	MemMode    uint8 = 0x19 // Set memory mode (0x00 One-touch mode, 0x01 Constant touch mode)
	CollSens   uint8 = 0x1d // Set anti-collision sensitivity (Sent 1x; no repeats, 1/2/3 high/medium/low)
	SetMax     uint8 = 0x21 // Set max height; Sets max-height to current height
	SetMin     uint8 = 0x22 // Set min height; Sets min-height to current height
	LimitClear uint8 = 0x23 // Clear min/max height (0x01 Max-height cleared, 0x02 Min-height cleared)
	Wake       uint8 = 0x29 // Poll message sent when desk doesn't respond to BREAK messages
	Calibrate  uint8 = 0x91 // Height calibration (Repeats 2x) (Desk must be at lowest position, enters RESET mode after this)
)

Commands sent by handset

Variables

This section is empty.

Functions

This section is empty.

Types

type Jarvis

type Jarvis struct {
	// contains filtered or unexported fields
}

func New

func New(r io.Reader, metrics *Metrics) *Jarvis

func (*Jarvis) NextMessage

func (j *Jarvis) NextMessage(ctx context.Context) (*Message, error)

NextMessage reads the next *Message from the given reader.

the format is: [addr (2b)][command (1b)][param len (1b)][params (0-3b)][cksum (1b)][EOM (1b)]

states (at beginning of loop) 0 = unsynchronized 1 = half-synchronized 2 = synchronized 3 = received command 4 = received param length (0-3), reading params 5 = received all params 6 = verified checksum 7 = eom

func (*Jarvis) ReadMessages

func (j *Jarvis) ReadMessages(ctx context.Context, errch chan error, ch chan *Message)

ReadMessages -

type Message

type Message struct {
	Type uint8
	// contains filtered or unexported fields
}

func (Message) Height

func (m Message) Height() uint64

Height returns the height (in mm)

func (Message) Preset

func (m Message) Preset() uint8

func (*Message) String

func (m *Message) String() string

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func InitMetrics

func InitMetrics(ns string) *Metrics

func (*Metrics) Collect

func (m *Metrics) Collect(ch chan<- prometheus.Metric)

Collect implements Prometheus.Collector.

func (*Metrics) Describe

func (m *Metrics) Describe(ch chan<- *prometheus.Desc)

Describe implements Prometheus.Collector.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL