heyho
ive got an issue during the migration from oh2.5 to 3.2.
im too stupid to convert some of my rules to the new engine
val stark = ShellyStarke80.state as Number //(this item is a group)
val starkgt = 64
val wer = triggeringItem.name
starkhoch80.sendCommand(wer)
if(starkgt <= stark)
{
val wer = triggeringItem.name
mailstarke80.sendCommand(ON)
starkhoch80.sendCommand(wer)
}
if(starkgt > stark)
{
mailstarke80.sendCommand(OFF)
}
the error i get is:
Duplicate local variable wer; line 7, column 146, length 3
2022-01-24 15:05:48.103 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'e525c8d5c7' failed: val stark = ShellyStarke80
no matter what i try, i cant get it working…
help anyone?
thanks
2022-01-24 16:09:32.529 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'e525c8d5c7' failed: <eval>:1:4 Expected ; but found stark
val stark = ShellyStarke80.state as Number
^ in <eval> at line number 1 at column number 4
Fair enough, still does not really look useful (with limited knowledge of your rule).
Nevertheless that’s only your first line, the other error points to your first Code var.
How is your group item defined? Is it a number type?
i copy-paste the execution-part of the rule from oh 2.5 to the script part int he ui of oh 3.2
the whole rule looks like that in oh2.5
rule "shellystark80"
when
Member of ShellyStarke80 changed
then
val stark = ShellyStarke80.state as Number
val starkgt = 64
val wer = triggeringItem.name
starkhoch80.sendCommand(wer)
if(starkgt <= stark)
{
val wer = triggeringItem.name
mailstarke80.sendCommand(ON)
starkhoch80.sendCommand(wer)
}
if(starkgt > stark)
{
mailstarke80.sendCommand(OFF)
}
end
taking only the execution-part thats what the rule looks like in 3.2
configuration: {}
triggers:
- id: "1"
configuration:
groupName: ShellyStarke80
type: core.GroupStateUpdateTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/javascript
script: |-
val stark = ShellyStarke80.state as Number
val starkgt = 64
val wer2 = triggeringItem.name
starkhoch80.sendCommand(wer2)
if(starkgt <= stark)
{
val wer2 = triggeringItem.name
mailstarke80.sendCommand(ON)
starkhoch80.sendCommand(wer2)
}
if(starkgt > stark)
{
mailstarke80.sendCommand(OFF)
}
type: script.ScriptAction
p.s. i changed the var wer to wer2 just for testing purpose
back to the original issue
i jsut remove the second declaration and thats it i guess
2022-01-24 16:45:04.531 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'e525c8d5c7' failed: val stark = ShellyStarke80.state as Number
val starkgt = 60
val wer2 = triggeringItem.name
starkhoch80.sendCommand(wer2)
if(starkgt <= stark)
{
val wer2 = triggeringItem.name
mailstarke80.sendCommand(ON)
starkhoch80.sendCommand(wer2)
}
if(starkgt > stark)
{
mailstarke80.sendCommand(OFF)
}
Duplicate local variable wer2; line 7, column 148, length 4