Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

spacefoot/ohaus-scale-proxy

Repository files navigation

OHAUS scale proxy

Building

For Raspberry PI

GOOS=linux GOARCH=arm GOARM=7 go build -o ohaus-scale-proxy .

For Windows

GOOS=windows GOARCH=amd64 go build -o ohaus-scale-proxy.exe .

Install

Put the binary into ~/.bin/ohaus-scale-proxy

mkdir -p ~/.bin/
cp ohaus-scale-proxy ~/.bin/

If you want to install it in another location, don't forget to edit the unit file

Use the systemd unit file ohaus-scale-proxy.service and put it on ~/.config/systemd/user/

mkdir -p ~/.config/systemd/user/
cp ohaus-scale-proxy.service ~/.config/systemd/user/

Edit your scale address inside ~/.config/ohaus-scale-proxy.yml

echo "address: <scale_address>" > ~/.config/ohaus-scale-proxy.yml

Start and enable on boot with

systemctl --user enable --now ohaus-scale-proxy

Get the process status with

systemctl --user status ohaus-scale-proxy

Get the process log history with

journalctl --user-unit ohaus-scale-proxy

Example

const socket = new WebSocket('ws://127.0.0.1:23193/ws');

socket.addEventListener('message', event => {
    const payload = JSON.parse(event.data);
    switch (payload.type) {
        case 'weight':
            console.log(`${payload.data} ${payload.unit}`);
            break;
        case 'connected':
            console.log(`connected: ${payload.data}`);
            break;
    }
});

possible output

connected: true
534 g

Releases

No releases published

Packages

No packages published