All, just an important DISCLAIMER:
I presented this demo at two Java/Eclipse developer conferences - so what I showed is not stuff that is ready for the average openHAB user yet, but rather the current state of work in progress. The intention of those presentations is to get people interested in it and to find developers joining the efforts - so see it as an invitation to get involved in the developments (which is primarily at Eclipse SmartHome and not here in the openHAB forum).
Now let me try to briefly answer the questions above:
There indeed currently is not good place for the mp3s. But the whole audio framework is currently re-designed and once this is there, the Sonos binding will be adapted as well. And we should have an AudioSource that serves mp3 files directly from the files ystem.
It isn’t possible to add templates through the REST API, but you can import them from the file system through console commands. Here is the template that I used:
[
{
"uid":"demo:energymeter",
"label":"Energy Meter",
"description":"Visualizes the current energy consumption.",
"configDescriptions":[
{
"name":"consumption",
"type":"TEXT",
"context":"item",
"label":"Consumption Item",
"description":"Data source for current consumption",
"required":true
},
{
"name":"light",
"type":"TEXT",
"context":"item",
"label":"Color Item",
"description":"Color light to use for visualisation",
"required":true
},
{
"name":"max",
"type":"INTEGER",
"label":"Max. consumption",
"description":"Maximum value (in W) for red light",
"required":true,
"defaultValue":1500
}
],
"triggers": [
{
"id": "trigger",
"label": "Current consumption changes",
"description": "Triggers whenever the current consumption changes its value",
"configuration": {
"itemName": "$consumption"
},
"type": "ItemStateChangeTrigger"
}
],
"conditions": [],
"actions": [
{
"inputs": {},
"id": "setcolor",
"label": "Change the light color",
"description": "Sets the color to a value in the range from green (low consumption) to red (high consumption)",
"configuration": {
"type": "application/javascript",
"script": "var power = trigger.event.getItemState().toString()\nvar percent = power / (${max} / 100) \nif(percent < 0) percent = 0\nvar hue = 120 - percent\nevents.sendCommand('${light}', hue +',100,100')"
},
"type": "ScriptAction"
}
]
}
]
(On how to activate the new rule engine/editor at all, see here)
Regards,
Kai