skip to Main Content

I am publishing a random temperature with topic:Test/Temperature.

I want a chart that displays this temperature using the topic.

I am getting this error: Function tried to send a message of type string

one

two

three

I tried to remove the function or change the code inside the function, but it wouldn’t work.

2

Answers


  1. Chosen as BEST ANSWER

    @hardillb Very Helpful! I want the publisher and the subscriber to see the following values "temp" , "id" , "status"

    But could the chart show only the temperature value? python code , publish , chart


  2. Function nodes must ALWAYS return and object.

    By returning just the msg.topic you have returned a string, which the error is correctly pointing out.

    The correct version of the function would be:

    msg.topic = 'Test/Temperature'
    return msg
    

    (But you can remove the whole function node and just set the topic and the payload in the inject node)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search