'-' in Payload is not accepted

Hello everyone,

I've been dealing with the following problem for a while now, but somehow I can't solve it.

I have an influx DB that I fill with data. Previously this was done from a different system, but now I want to switch to node red.
Basically it works, but now I have a payload with "-"
--> WW-Storage_Temperature_above: msg.payload
And the "-" leads to a failure. But the expression exists in the database and so I want to keep it.
What can I do?

Sorry for this maybe simple question

You can use that as a property name in JavaScript but it isn't recommended. It means that you will always have to reference it using bracket notation instead of dot notation.

// This does not work

// This DOES work

Hello TotallyInformation,

thank you for your fast reply. But this also will not work. (The function node is marked with an red triangle)

Then something else is the problem and you will need to share more details about the problem. If you share the code, people can take a look.

So I tried some variants now. And with your suggestion "" in s slightly different way seems to work.
This is the expression:
[WW-Speicher_Temperatur_oben]: msg.payload

Which is why you should have shared your code because then we could have avoided the confusion. I now know that what you wanted was a reference inside an object as in:

   [some-thing]: 42

That wasn't clear in your original post. When asking for help, please try to be clear and comprehensive about what you are asking and do not make assumptions that other people will recognise what you are saying.

Hi TotallyInformation,

yes I missed to copy the hole code, sorry.
For me it was not clear that the code around has impact in this case.
For the next time I know and will post the hole code.

Thanks for helping.

1 Like

Just want to add the final solution that works for me.

Jesterday with the expression
[WW-Speicher_Temperatur_oben]: msg.payload
Node red "accepted" the expression. But today when I made the final cutover to node red no entries in influx DB.
With the following modification it works fine:
['WW-Speicher_Temperatur_oben']: msg.payload

And the hole code is:
msg.payload = [
['WW-Speicher_Temperatur_oben']: msg.payload


    Sensor: 'Temperatur'

return msg;

1 Like

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