Basic help sending an MQTT payload via a slider

Hi,

Just migrating a dashboard I had set up inside HA so that it becomes just an MQTT based version.

In the HA version, I'm connecting a dashboard slider to a call service node, and can manipulate the payload on the call service side like this:


{	 "brightness_pct":msg.payload	}

With the MQTT approach, apparently I cannot manipulate the payload on either side. On the slider side, payload is just hard wired to 'Current state', and on the MQTT side, there doesn't seem to be anywhere to set the payload that goes to the MQTT topic. I can see in MQTT Explorer, my light is showing


set = 49

When I need it to say

set = {"brightness_pct": 49}

I tried putting the payload in the topic field, but it's not substituting the variable msg.payload.

Here's where I'm being thick. I found this solution:

But I don't know how to implement it :frowning:

I put a template node between my slider and MQTT out, and I put this value in the Template field:

brightness_pct:{{payload}}

But the debug shows the output of the template node is exactly the same as the output from the slider. No I don't understand template nodes yet, sorry being a noob. I'll get there.

I should type out my questions and not post, sorry.

I can see now template node was referring to the function template not the dashboard template node. Now it makes sense.

I think this might be a simpler solution. Insert a Change node between the slider and the MQTT node configured like this.

image

1 Like

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