You can use computed attributes to change the result message.
Ohhhhhh, I get it. Since "commandResult" is already an existing notification type I can recompute it as it arrives using Computed Attributes.
Smart.
This is working, however I am still such a JEXL n00b that I don't know if the "null" at the end is necessary.
result == "DOUT1:IGNORED DOUT2:Command not executed-NOFIX DOUT3:IGNORED" ? "Vehicle Disable Failed - No Satellite signal" : result == "DOUT1:1 Timeout:2s DOUT2:IGNORED DOUT3:IGNORED" ? "Vehicle Activated" : result == "DOUT1:IGNORED DOUT2:1 Timeout:2s Speed:25 DOUT3:IGNORED" ? "Vehicle Disable Commanded" : null
I realise now that with this Computed attribute for any of the Devices where it is assigned (connected), every check-in which doesn't include a Command Result fills the Traccar log with this:
2025-02-11 07:42:50 WARN: Attribute computation error - org.traccar.handler.ComputedAttributesHandler.computeAttribute:155@1:1 variable 'result' is undefined - Variable (ComputedAttributesHandler:156 < *:168 < BasePositionHandler:34 < ProcessingHandler:172 < MotionHandler:41 < ...)
I feel like this is just perhaps my JEXL syntax being wrong?
Fixed it. I did say I was a n00b:
result ?
(result == "DOUT1:IGNORED DOUT2:Command not executed-NOFIX DOUT3:IGNORED" ? "Vehicle Disable Failed - No Satellite signal" :
result == "DOUT1:1 Timeout:2s DOUT2:IGNORED DOUT3:IGNORED" ? "Vehicle Activated" :
result == "DOUT1:IGNORED DOUT2:1 Timeout:2s Speed:25 DOUT3:IGNORED" ? "Vehicle Disable Commanded" : null)
: null
The initial syntax of result ?
only triggers the expression if the decoded AVL data has this attribute.
Kaldex, What happens if the message is not any of those 3? Is it lost?
Yeah I stuffed it up. It needs to be this:
result ?
(result == "DOUT1:IGNORED DOUT2:Command not executed-NOFIX DOUT3:IGNORED" ? "Vehicle Disable Failed - No Satellite signal" :
result == "DOUT1:1 Timeout:2s DOUT2:IGNORED DOUT3:IGNORED" ? "Vehicle Activated" :
result == "DOUT1:IGNORED DOUT2:1 Timeout:2s Speed:25 DOUT3:IGNORED" ? "Vehicle Disable Commanded" : result)
: null
The above JEXL basically says:
IF there is a result, and the result is one of these three strings, change the result to the new text. Otherwise, leave it as-is.
This one Computed Attribute could be edited to keep adding any needed translations for anything that comes back as a decoded command result (in this case, from Teltonika devices).
Here's an example of the updated Computed Attribute to translate another response into better English:
result ?
(result == "DOUT1:IGNORED DOUT2:Command not executed-NOFIX DOUT3:IGNORED" ? "Vehicle Disable Failed - No Satellite signal" :
result == "DOUT1:1 Timeout:2s DOUT2:IGNORED DOUT3:IGNORED" ? "Vehicle Activated" :
result == "DOUT1:IGNORED DOUT2:1 Timeout:2s Speed:25 DOUT3:IGNORED" ? "Vehicle Disable Commanded" :
result == "On Demand Tracking started. Period: 10, Duration: 600" ? "On Demand Tracking Activated for 5 minutes" : result)
: null
sorry for hijacking this thread.
i cant find the command result option in the attributes list on the computed attributes page
but i dont have those entrys
Make sure you do a proper search and not just scroll.
Even with a search i dont see the entrys
I'm remotely immobilizing vehicles using a latching relay (it works great by the way) and Teltonika devices. My customers want better feedback if the commands to activate or disable the vehicle have worked. The "command result" notification spews out text like the below example which is not helpful for the layman:
I want to set up a new Custom Attribute which looks at the commandResult event and translates it so that they can receive a Notification (even if it needs to be an alarm) that says "Vehicle Disabled" or "Vehicle Activated".
I'll take any guidance before I spend too much time tinkering with it.