Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@sensebox/sketch-templater
Advanced tools
Arduino sketch templates used by the openSenseMap-api
Install via npm install --save @sensebox/sketch-templater
or yarn add @sensebox/sketch-templater
const Sketcher = require('@sensebox/sketch-templater');
const mySketcher = new Sketcher('<your api post domain>');
// generate Sketch
const mySketch = mySketcher.generateSketch(box);
To add new templates, just create a new .tpl
file in the templates
directory. A template consists of two parts. The first line contains a JSON object for configuration. The second line until the end is used as the template text.
Specify a single model:
{ "model": "homeEthernet" }
Specify multiple models:
{ "models": ["homeWifi", "homeWifiFeinstaub"] }
The templater uses special transformers to process the templates. The transformers are applied through searching for @@SUB_TEMPLATE_KEY@@
occurrences in the template files. Each replacement starts and ends with a double @
. To specify a transformer, append a pipe (|
) and the transformer name. When no transformer is specified, it just returns the input variable. For adding new template transformers, see Adding Transformers.
As of writing this, the following replacements can be made:
Template text | Replacement |
---|---|
@@SENSEBOX_ID@@ | the senseBox ID |
@@SENSOR_IDS@@ | sensor IDs |
@@NUM_SENSORS@@ | the number of sensors |
@@INGRESS_DOMAIN@@ | the domain of your ingress server |
Additionally, the following transformers are implemented:
Transformer name | Description |
---|---|
as-is | Do nothing. |
toHex | Transforms a single string to hex tuples. Example: "DEADBEEF" => "0xDE, 0xAD, 0xBE, 0xEF" |
toDefine | Transform an array of sensors to multiple #define statements. |
toHexArray | Transform an array of sensors to a list of hex encoded arrays. Uses toHex internally. |
In order to add a new transformer, just add a function in src/transformers.js
to the module.exports
. The function should return a string.
Add your additional replacements in src/index.js
in the method _cloneBox
to the second parameter of the Object.assign
call.
v1.0.1
Fix npm package name in README.md
FAQs
nodejs library to create senseBox Arduino Sketches
The npm package @sensebox/sketch-templater receives a total of 16 weekly downloads. As such, @sensebox/sketch-templater popularity was classified as not popular.
We found that @sensebox/sketch-templater demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.