Simple animation

I’m trying to animate a pump component based on a mqtt tag value but cannot work this out even though it should be simple.

My tag is

{[MQTT Engine]PUMP/home/pump/status}

and I’ve tried

if ({[MQTT Engine]PUMP/home/pump/status} = 1, "running", "stopped")
also
if ({[MQTT Engine]PUMP/home/pump/status} = "1", "running", "stopped")
also other variants without quotation marks etc to no avail

What am I missing here?

The value I have is either 1 or 0

Regards

Is this in vision or perspective?

If this is an expression binding in Perspective than the way you are referencing that path won’t work, the braces are for referencing properties.

You likely want to do a tag binding (You could make this an indirect binding if it needed to be more dynamic) and then a map transform

Looks like this:

Well :face_with_open_eyes_and_hand_over_mouth:

Helps if I write the expression in the Binding type>Expression as opposed to the expression section under ‘Tag’ !

Solved :smile:

We posted the same time. Thanks, I’ll check this method out compared to the one I just got to work

One call out on the one you got to work, make sure you aren’t doing this:
if(tag({[MQTT Engine]PUMP/home/pump/status}) = "1", "running", "stopped")

The utilization of that tag() expression there can cause some performance issues over time, especially if used often in a project due to how it updates and polls its data

If you need to more dynamically define what your tag path is, try using an indirect tag binding

Thanks for the advice. Seems this doesn’t work however. Any idea what I’ve done wrong? Seems to always be “stopped”

What’s the data type of that mqtt tag in the tag properties set to?

wish I could say. Bear with me, I’m a noob with ignition. Assuming as it’s from mqtt it will be a string, however this doesn’t tell me?

If you’re not sure then try setting Input Type: value = '1' rather than 1.

This was my initial thought however it seems to not work

OK. Sorry about that. I meant to use single quotes but accidentally typed doubles (corrected now) but I doubt that’s the problem.
I’m not familiar with MQTT but it’s surprising that they don’t give you the data type. It looks like it’s returning a numeric type. My next option would be to try true and Fallback.

1 Like

Add a script transform before the map and return type(value)

2 Likes