Hello Community,
I have used OpenHab2 for some time now and have read alot of the tutorials on this page to get started. So far I have figured everything out by myself although some rules might not be as elegant as they could be everything works out just fine
I now have a problem I can´t seem to figure out by myself though, mainly because I don´t now how to program anything else than basic stuff. I have OpenHab2 running inside a VM on my HomeServer, a couple of days ago I installed Snips.ai on a Raspberry Pi. I have set up everything and it works great. The problem is that I can`t use anything else than simple ON/OFF Commands. I would like to be able to change the Color of e.g. the Living Room Bulbs but I don´t know how to program that.
Right now the part of my my snips.rule which should change color according to whats posted in Snips_Intent looks like this:
rule "Snips Intent"
when
Item Snips_Intent received update
then
logInfo("Snips Intent: ", Snips_Intent.state.toString)
end
rule "Snips"
when
Item Snips_Intent received update
then
logInfo("Snips Intent: ", Snips_Intent.state.toString)
var String intentName = transform("JSONPATH", "$.intent.intentName", Snips_Intent.state.toString)
var String pureIntent = intentName.split(":").get(1);
var String device_val = transform("JSONPATH", "$.slots[0].value.value", Snips_Intent.state.toString)
var String color_val = transform("JSONPATH", "$.slots[1].value.value", Snips_Intent.state.toString)
logInfo("Snips Gerät: ", device_val)
logInfo("Snips Farbe: ", color_val)
pureIntent = pureIntent.toLowerCase
logInfo("Snips device value: ", pureIntent)
function getColorValue(c) {
switch (c) {
case 'white': return '0,0,100';
case 'rose': return '300,100,10';
case 'yellow': return '500,100,100';
case 'orange': return '25,100,100';
case 'green': return '100,100,50';
case 'violet': return '280,100,100';
case 'blue': return '200,100,100';
case 'red': return '0,100,100';
default: return '0,0,100';
}
}
if (pureIntent == 'farbewechseln') {
oh2COLOR = "getColorValue(color)"
}
if (device_val == 'Wohnzimmer') {
sendCommand(WZFarbe,oh2COLOR)
}
Once I upload the rule it says:
2019-02-12 20:04:13.331 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'snips.rules' has errors, therefore ignoring it: [40,36]: missing '}' at ';'
[41,5]: mismatched input 'case' expecting '}'
[41,16]: mismatched input ':' expecting 'end'
So there seems to be a mistake in the âfunction getColorValueâ part. Does anyone now a solution to this problem? Thanks in advance!