trying to creat new powerOn powerOff notification

nabil boumimimak4 months ago

in my coban 103 (protocol gps103) devices , when sending the comaand to stop engine an attribute called event : jt received and for resume engine the event become : tk
i am trying to make a custom notification in computed attribute like this :
attribute : alarm
experssion : event == 'kt' ? 'powerOn' : null (or : event == 'jt' ? 'PowerOff' : null)
tpe: string
but i keep getting this error

org.traccar.handler.ComputedAttributesHandler.computeAttribute:138@1:1 variable 'event' is undefined - Variable (ComputedAttributesHandler:139 < AttributeResource:63 < ... < OverrideFilter:49 < ...)

even thou in my config i have this set up :

    <entry key='processing.copyAttributes.enable'>true</entry>
    <entry key='processing.copyAttributes'>
    <entry key='processing.computedAttributes.localVariables'>true</entry>
    <entry key='processing.computedAttributes.loops'>true</entry>
    <entry key='processing.computedAttributes.deviceAttributes.config'>true</entry>
    <entry key='processing.computedAttributes.deviceAttributes'>true</entry>
    <entry key='processing.computedAttributes.lastAttributes'>true</entry>
    <entry key='processing.computedAttributes.newInstanceCreation'>true</entry>

can anyone please help me

Anton Tananaev4 months ago

The error seems to be pretty clear. Event is not available, so your expression is failing. You have to check that it exists before using it.

nabil boumimimak4 months ago

the moment i tested it , it did exist,
when i sent the command resume engine i received an attribute event=kt
i imidietly went and tested the computed attribute

editting
you are totaly right
i just wasnt fast enough
now its working

Anton Tananaev4 months ago

It's possible that it exists in some positions only.

nabil boumimimak4 months ago

i am sorry Anton i edited my comment
you were right , when i tested it the attribute wasnt availbale
sorry again

nabil boumimimak4 months ago

after through testing , its working but not all the time
the first couple of time the alarm got triggered byt now its not .

Anton Tananaev4 months ago

Are you sure it's not a duplicate alarm?

nabil boumimimak4 months ago

no its not