Read SQL value and convert to Domoticz MQTT Topic - payload issue

You deleted the incoming msg (overwrote it with empty object) THEN tried to access the values you had deleted.

If it's not obvious I'm afraid you're gonna struggle. Perhaps some basic JavaScript reading and learning would be your next stop.

In essence, the very first line msg = {}; destroyed the incoming data.

Now I understand. Great explanation and education to me. Thank you Steve.
The value is now in the string. The very last part is to get the value 4000 between '4000' for the Domoticz MQTT script.

Update and closed for solved issue:
In my case the value 4000 from the SQL result is numeric. Domoticz expects for svalue a string. So in this example 4000 should be presented as ā€˜4000ā€™.

To do this was relatively simple: use String(msg.payload[0].count_e) and then it will work.

Many thanks to all who helped me to solve this issue. My Java knowledge is minor, no goal for me to become an expert, but thanks to the help of each other in this forum the boundary for many ā€˜usersā€™ like me becomes smaller to explore the power of Node-Red.

1 Like

Not long ago there was some discussion of a plugin for Discourse that can be used to create templates for replies like "how to share code", "what versions are you using?", and now these topics. I know the developers have better things to do than tinker with forum mechanics, but this feature, if used tactfully, could remove a minor irritant and help get new users more complete answers quickly.

1 Like

restult.svalue is a typo it should be
result.svalue

1 Like