{"id":18779105,"url":"https://github.com/zakaton/decent-scale-web-sdk","last_synced_at":"2025-10-06T16:33:09.057Z","repository":{"id":174759285,"uuid":"652292355","full_name":"zakaton/decent-scale-web-sdk","owner":"zakaton","description":null,"archived":false,"fork":false,"pushed_at":"2023-06-14T23:42:03.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T10:27:59.642Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zakaton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-11T17:32:49.000Z","updated_at":"2023-06-12T17:55:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"656abd6f-aa55-4bee-b868-de5215ab6448","html_url":"https://github.com/zakaton/decent-scale-web-sdk","commit_stats":null,"previous_names":["zakaton/decent-scale-web-sdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakaton%2Fdecent-scale-web-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakaton%2Fdecent-scale-web-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakaton%2Fdecent-scale-web-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakaton%2Fdecent-scale-web-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zakaton","download_url":"https://codeload.github.com/zakaton/decent-scale-web-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239690253,"owners_count":19681066,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T20:18:44.160Z","updated_at":"2025-10-06T16:33:09.008Z","avatar_url":"https://github.com/zakaton.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Decent Scale Web SDK\n\n_A client-side JavaScript SDK for the [Decent Scale](https://decentespresso.com/decentscale) by [Decent Expresso](https://decentespresso.com/)_\n\n## Table of Contents  \n⚙️ Setting up the SDK  \n⚖️ Connecting to your Decent Scale  \n🎛 Sending Commands  \n👂 Listening for Events  \n\n### ⚙️ Setting up the SDK\n\nInclude the following script to your webpage (you can also download the glitch-hosted scripts for local use):  \n\n```\n\u003cscript src=\"https://decent-scale-web-sdk.glitch.me/script/DecentScale.js\"\u003e\u003c/script\u003e\n```\n\nThis will expose a `DecentScale` class you can use to create instances:\n\n```\nconst decentScale = new DecentScale();\n```\n\n### ⚖️ Connecting to your Decent Scale  \n\nYou can only connect to your device via Web Bluetooth:\n\n```\nconst decentScale = new DecentScale();\n\n// the .connect method returns a promise if connected\n// make sure to call this method in response to a user action, like a button click\ndecentScale.connect().then(() =\u003e {\n  console.log(\"connected!\");\n});\n\n// you can also listen for the \"connected\" event:\ndecentScale.addEventListener(\"connected\", () =\u003e {\n  console.log(\"connected!\");\n});\n```\n\n\n### 🎛 Sending Commands  \n\nAfter connecting, you can set the weight/timer visibility, change the displayed weight type, tare the scale, set the timer, and power off:\n\n```\n// setLED(showWeight = false, showTimer = false, showGrams = true)\ndecentScale.setLED();\n// show weight, and show it in grams:\ndecentScale.setLED(true);\n// show weight, but in ounces\ndecentScale.setLED(true, false, false);\n// show weight (in grams), and timer\ndecentScale.setLED(true, true);\n\n// tare\ndecentScale.tare();\n\n// timer\ndecentScale.startTimer();\ndecentScale.stopTimer();\ndecentScale.resetTimer();\n\n// power off\ndecentScale.powerOff();\n\n```\n\n\n### 👂 Listening for Events  \n\nListening for events is pretty staightforward:\n```\n// connected\ndecentScale.addEventListener(\"connected\", () =\u003e {\n  console.log(\"connected\");\n});\n\n// disconnected\ndecentScale.addEventListener(\"disconnected\", () =\u003e {\n  console.log(\"disconnected\");\n});\n\n// firmware version\ndecentScale.addEventListener(\"firmwareVersion\", event =\u003e {\n  const { firmwareVersion } = event.message;\n  console.log(\"firmware version\", firmwareVersion);\n});\n\n// listen for if the device is powered by usb or battery\ndecentScale.addEventListener(\"isUSB\", event =\u003e {\n  const { isUSB } = event.message;\n  console.log(\"isUSB\", isUSB);\n});\n\n// listen for battery life\ndecentScale.addEventListener(\"battery\", event =\u003e {\n  const { battery } = event.message;\n  console.log(\"battery\", battery)\n});\n\n// weight (in grams), isStable and time (if firmware 1.2)\ndecentScale.addEventListener(\"weight\", event =\u003e {\n  const { weight, isStable, time } = event.message;\n  console.log(\"weight\", weight);\n  console.log(\"isStable\", isStable);\n  console.log(\"time\", time.string);\n});\n\n// taps (button is \"left\" or \"right\", and tap is \"short\" or \"long\")\ndecentScale.addEventListener(\"buttonTap\", event =\u003e {\n  const {button, tap} = event.message;\n  console.log(`${button}: ${tap}`)\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakaton%2Fdecent-scale-web-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzakaton%2Fdecent-scale-web-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakaton%2Fdecent-scale-web-sdk/lists"}