Variable inside payload

Hi,

I'm having the following function:

        data :{ 
        title : msg.title,
        message : msg.message,
        data: {
            push: {
                sound: {
                    name: 'default',
                    critical: msg.setCritical,
                    volume: 1
                }
            },
            actions: [msg.action],
        }
    },
        service : msg.receiver
    }

I'm also having this:

if(msg.imageurl){ msg.setImage = "image: https://github.com/home-assistant/assets/blob/master/logo/logo.png?raw=true"; }

But how can I pas the msg.setImage after actions: [msg.action],?

It's not possible to already put image: msg.setImage to it and send a empty image because it's shows a 404 error image.

I don't understand what you have showed us.

That appears to be part of an object, not a function.

Again I don't understand. If you want to include the contents of msg.setImage into the structure then using image: msg.setImage is the correct way to do it. If you do that and look at the result in a debug node (before you do anything else with it) what do you see?

I've created a sub-flow with soms variables on the input side. This is in my function.

I would like to check if msg.imageurl got a value and if so, put is after actions: [msg.action],.

if(msg.imageurl) {
   msg.payload.data.data.image = msg.imageurl;
}

Add something like this after you set the payload. this will check if msg.imageurl exist and add it to your payload.

Something like this after the msg.payload = ... statement

if (msg.imageurl) {
  msg.payload.data.data.image = msg.imageurl
}

Thanks, did the trick!

Thanks, did the trick!!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.