Mqtt light - state to update card

When I send state : ON to the state topic the light on the car goes on. How can I get the dimmer to match the current % if it was set elsewhere? Does the State topic accept 0-255 and then reflect that on the dimmer without changing the light?

I’m using JSON for reference. All of the manipulation is done in node red so I should be able to do anything required. If Node red changes I light I would like the brightness it set to reflect on HA’s card.

That works, the HA state will match.

I had to send it as json data:

{"state": "ON", "brightness": {{payload}}}

(in a template node in Node Red followed by a JSON node)

So the state now receives {"state": "ON", "brightness": 255} for on full.

Thanks

So you are sending this from Node Red direct to the mqtt topic? Why not use the Node Red / Home Assistant functionality?

New to HA, been using Node RED with OpenHAB for years. I’ll have to check it out, do you have a link?

I see. It depends on how you installed home assistant. If you have the supervisor, the easiest way is to use the addon Home Assistant Community Add-on: Node-RED

It integrates node red and home assistant, so you can (in your example) set node red to turn the light on to 50% brightness, so that would work for any light entity, not just a mqtt light.

the flow should be:
1 NR sets set (or similar) topic in mqtt, including brightness etc
2 the device executed this command
3. the device sets its current state and attributes into its status topic in mqtt
4. HA updates its state from mentioned status topic

So answering your initial question, yes, it should work as you are assuming.

As @nickrout mentioned, using HA integrated NR, you can call light services. resulting setting lights entities in HA, which in turn sets required topic in mqtt in order to execute the action on destination device.
However there might be some operation featured by your device which are not supported by HA light service. So in some cases it’s better to communicate directly through mqtt