Please remove this block after reading these instructions
Add the published tag when your submission is ready to be made available to the public, but not before. Breaking changes in Blockly libraries can have adverse changes for the rules of early adopters. You can self-assess the maturity level tags yourself and add appropriate tags from mature, stable, beta or alpha.
[ Add a logo icon for the blocks here and configure the image’s “alt” as “logo” that will serve as the icon in the add-on store UI - i.e.

. It will not appear in the description. A logo is not strictly necessary but is encouraged]
[ Add a primary screenshot of the blocks here. If a logo is not specified above this first image of the post will serve as the icon in the add-on list in the UI.]
[ Replace with your description.]
This example library demonstrates the different types of blocks that can be developed, and the features available
Blocks
[ Describe what the individual blocks do.]
TODO
Changelog
[ Add a list of the changes you made for each version, as suggested below (remove example sections)]
Version 0.1
- initial release
Resources
[ You can either add code fences with explicit
yaml
language (```yaml … ```
), or a direct link to a *.yaml file hosted by your preferred service: GitHub, GitHub Gist (gist.github.com), etc.
uid: tutorial
props:
parameters: []
parameterGroups: []
component: BlockLibrary
config:
name: Tutorial
slots:
blocks:
- component: BlockType
config:
args0:
- check: Number
name: RADIUS
type: input_value
colour: 70
message0: circumference of circle with radius %1
output: ""
tooltip: Returns the circumference of a circle given its radius
type: radius
slots:
code:
- component: BlockCodeTemplate
config:
order: ORDER_MULTIPLICATION
template: 2 * Math.PI * {{input:RADIUS:ORDER_MULTIPLICATION}}
- component: BlockType
config:
args0:
- angle: 45
name: ANGLE
type: field_angle
- check: Number
name: RADIUS
type: input_value
colour: 50
message0: arc length with angle %1 and radius %2
output: ""
tooltip: Returns the length of a arc given its radius and angle
type: arc_length
slots:
code:
- component: BlockCodeTemplate
config:
order: ORDER_MULTIPLICATION
template: "{{utility:degrees_to_radians}}({{field:ANGLE:ORDER_ATOMIC}}) * {{input:RADIUS}}"
toolbox:
- component: PresetField
config:
name: ANGLE
value: 270
- component: PresetInput
config:
fields:
NUM: 123
name: RADIUS
shadow: true
type: math_number
- component: BlockType
config:
args0:
- type: input_dummy
- name: CODE
type: input_statement
colour: 240
helpUrl: ""
message0: only before noon do %1 %2
nextStatement: ""
previousStatement: ""
tooltip: ""
type: only_before_noon
slots:
code:
- component: BlockCodeTemplate
config:
template: >-
if (new Date().getHours() < 12) {
{{statements:CODE}}
}
- component: BlockType
config:
args0:
- name: NAMESPACE
text: namespace
type: field_input
- check: String
name: ITEMNAME
type: input_value
colour: 0
helpUrl: ""
message0: get item %1 metadata value for %2
output: ""
tooltip: ""
type: metadata_value
slots:
code:
- component: BlockCodeTemplate
config:
template: "{{utility:get_metadata_value}}('{{field:NAMESPACE}}', {{input:ITEMNAME}}))"
- component: Separator
config:
gap: 100
- component: BlockAssembly
config:
blockXml: >
<block type="procedures_defnoreturn">
<mutation>
<arg name="list"></arg>
</mutation>
<field name="NAME">randomize</field>
<statement name="STACK">
<block type="controls_for" inline="true">
<field name="VAR">x</field>
<value name="FROM">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
<value name="TO">
<block type="lists_length" inline="false">
<value name="VALUE">
<block type="variables_get">
<field name="VAR">list</field>
</block>
</value>
</block>
</value>
<value name="BY">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
<statement name="DO">
<block type="variables_set" inline="false">
<field name="VAR">y</field>
<value name="VALUE">
<block type="math_random_int" inline="true">
<value name="FROM">
<block type="math_number">
<field name="NUM">1</field>
</block>
</value>
<value name="TO">
<block type="lists_length" inline="false">
<value name="VALUE">
<block type="variables_get">
<field name="VAR">list</field>
</block>
</value>
</block>
</value>
</block>
</value>
<next>
<block type="variables_set" inline="false">
<field name="VAR">temp</field>
<value name="VALUE">
<block type="lists_getIndex" inline="true">
<mutation statement="false" at="true"></mutation>
<field name="MODE">GET</field>
<field name="WHERE">FROM_START</field>
<value name="AT">
<block type="variables_get">
<field name="VAR">y</field>
</block>
</value>
<value name="VALUE">
<block type="variables_get">
<field name="VAR">list</field>
</block>
</value>
</block>
</value>
<next>
<block type="lists_setIndex" inline="false">
<value name="AT">
<block type="variables_get">
<field name="VAR">y</field>
</block>
</value>
<value name="LIST">
<block type="variables_get">
<field name="VAR">list</field>
</block>
</value>
<value name="TO">
<block type="lists_getIndex" inline="true">
<mutation statement="false" at="true"></mutation>
<field name="MODE">GET</field>
<field name="WHERE">FROM_START</field>
<value name="AT">
<block type="variables_get">
<field name="VAR">x</field>
</block>
</value>
<value name="VALUE">
<block type="variables_get">
<field name="VAR">list</field>
</block>
</value>
</block>
</value>
<next>
<block type="lists_setIndex" inline="false">
<value name="AT">
<block type="variables_get">
<field name="VAR">x</field>
</block>
</value>
<value name="LIST">
<block type="variables_get">
<field name="VAR">list</field>
</block>
</value>
<value name="TO">
<block type="variables_get">
<field name="VAR">temp</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</statement>
</block>
- component: BlockAssembly
config:
blockXml: >
<block type="oh_print">
<value name="message">
<block type="text">
<field name="TEXT">'Twas brillig, and the slithy toves</field>
</block>
</value>
<next>
<block type="oh_print">
<value name="message">
<block type="text">
<field name="TEXT"> Did gyre and gimble in the wabe:</field>
</block>
</value>
<next>
<block type="oh_print">
<value name="message">
<block type="text">
<field name="TEXT">All mimsy were the borogroves,</field>
</block>
</value>
<next>
<block type="oh_print">
<value name="message">
<block type="text">
<field name="TEXT"> And the mome raths outgrabe.</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
utilities:
- component: UtilityFunction
config:
code: >-
function {{name}}(degrees) {
var pi = Math.PI;
return degrees * (pi/180);
}
name: degrees_to_radians
- component: UtilityFrameworkService
config:
name: metadataService
serviceClass: org.openhab.core.items.MetadataRegistry
- component: UtilityJavaType
config:
javaClass: org.openhab.core.items.MetadataKey
name: MetadataKey
- component: UtilityFunction
config:
code: >-
function {{name}}(metadata, itemName) {
var result = {{metadataService}}.get(new {{MetadataKey}}(namespace, itemName));
return (result) ? result.getValue() : null;
}
name: get_metadata_value