Door status computed attribute help

Vladimir S6 years ago

Hello,

i have door status on Coban 306A.. io1 is 0 for closed and 1 for opened.. I want to create computed atribute with boolean output.

Doors
in1 ? in1 == 0 : false
Boolean

When i open or close door, it still shows me false.. i have tried to change 0 to 1 without any change.. i have assigned computed attribute to device.

I want to create event or alarm when my doors are opened.

Thanks a lot for help..

Anton Tananaev6 years ago

What protocol does your device use? The IO value might be a string, not a number.

Vladimir S6 years ago

device uses gps103 protocol.. value is changing to 1 when i open door..

select from database

{"io1":"0","io3":"0.00%","distance":0.0,"totalDistance":24.11,"motion":false}
{"io1":"1","io3":"0.00%","distance":0.0,"totalDistance":24.11,"motion":false}

i have copied expression from example..it looks like this exactly in my setting..

doors
io1 ? io1 == 0 : false
Boolean

Anton Tananaev6 years ago

As you can see yourself, value is a string, not a number, as I suspected. Your expressions won't work. You need to convert both sides of comparison expression to the same type.

Vladimir S6 years ago

Please can you help me with example? I dont know how to change both sides to the same type. I want only to show attribute Doors opened : Yes/No.. And receive alert when there are doors opened.

Anton Tananaev6 years ago

I don't have an example. You can try to find some examples on the forum or you can check JEXL documentation.

socstur6 years ago

There’s an example in the forum for io3( reported as string) which gets converted to number before being used for fuel calculation. Search for io3 and let me know if you can’t find it.