#Modify MQTT messages before reaching broker

8 messages · Page 1 of 1 (latest)

olive comet
#

Hello, as the title says: I need to find a way to modify MQTT messages before they reach the MQTT server. I already tried Node-RED but this didn't intercept the messages but rather sent an extra message along with the original one which is not what I want.

The reason for wanting to achieve this is I have bulbs that do not work properly with a single .json that has both "state" on/off and "color" attributes. I need to send the "color"/etc. attributes first before I send "state" for a smooth transition. Right now HA is sending both "state" and "color" in the same message by default.

I have also looked at the option of disabling autodiscovery and adding all lights manually but this is a tedious, long process which I do not want to do.

Ideally I would like to edit the MQTT integration files so that I can edit the default command that is being sent and split it into two commands. Does anyone have any experience with this?

crisp crest
#

The best way to do that is to use two actions in your scripts/automations 😉

olive comet
crisp crest
#

If it's MQTT you can just do two MQTT publish actions

olive comet
#

Or rather the way that light.turn_on currently works. There is also no way to intercept light.turn_on

crisp crest
olive comet
#

Is "aliasing" an existing MQTT light as simple as referencing that light in the template or do I have to recreate every property?