I have 2 energy-counters with Modbus (Eastron SDM630 and Eastron SDM120) in my garage and want to connect them together in one bus and to one controller (Lolin NodeMcu).
Is it possible to send data to different topics through MQTT from one NodeMcu to the same broker? One topic (for the SDM603) is domoticz/in and the second meter (SDM120M) should send to topic energy/goodwe.
In the software (Build: ESP_Easy_mega_20231130_energy_ESP8266_4M1M Nov 30 2023) I created a second MQTT controller with different topicname but that seems to be not allowed... Error: One one mqtt controller should be active.
Is there a solution for this problem? In tab Devices I can select a controller...
Or build another NodeMcu with another configuration of the topic: energy/goodwe
Send MQTT to different topics?
Moderators: grovkillen, Stuntteam, TD-er
Re: Send MQTT to different topics?
You can send whatever you like via rules.
For example act on the event of a new measurement and send all values using the publish command.
See also documentation for formatting domoticz-syntax formatted messages: https://espeasy.readthedocs.io/en/lates ... er-parsing
Assuming your task is called "SDM2" and you have checked the checkbox to send all values in a single event (checkbox in the task config page)
Or if you need the values all in a single message:
For example act on the event of a new measurement and send all values using the publish command.
See also documentation for formatting domoticz-syntax formatted messages: https://espeasy.readthedocs.io/en/lates ... er-parsing
Assuming your task is called "SDM2" and you have checked the checkbox to send all values in a single event (checkbox in the task config page)
Code: Select all
on sdm2#all do
publish,"energy/goodwe/1",%eventvalue1%
publish,"energy/goodwe/2",%eventvalue2%
publish,"energy/goodwe/3",%eventvalue3%
publish,"energy/goodwe/4",%eventvalue4%
endon
Code: Select all
publish,"energy/goodwe","%eventvalue1%,%eventvalue2%,%eventvalue3%,%eventvalue4%"
Re: Send MQTT to different topics?
Thnx Gijs for quick reply and examples.
I forgot to tell that data from the SDM120 must be sent via broker to 2 different destinations. The one to Domoticz is clear to me.
This is the rule:
The second destination is to Node-Red...
I am able to simulate that proces by sending a message by Publish in MQTT Explorer. The data is picked up by the flow and send correctly to PVoutput.org..
Hopefully tomorrow I recieve the new SDM120M and in the mean time I can figure out how to edit the MQTT-node in NodeRED.. Or create a rule in ESPeasy for NodeRED..
The message I publish is for example:
I must rearrange that in the rule I guess with some extra text. That is the goal for this evening.
I forgot to tell that data from the SDM120 must be sent via broker to 2 different destinations. The one to Domoticz is clear to me.
This is the rule:
Code: Select all
On SDM_Goodwe#All Do
Publish,energy/goodwe,'{"command":"udevice","idx":2506,"nvalue":0,"svalue":"%eventvalue1%"}'
Publish,energy/goodwe,'{"command":"udevice","idx":2507,"nvalue":0,"svalue":"%eventvalue2%"}'
Publish,energy/goodwe,'{"command":"udevice","idx":2508,"nvalue":0,"svalue":"%eventvalue3%"}'
Publish,energy/goodwe,'{"command":"udevice","idx":2509,"nvalue":0,"svalue":"%eventvalue4%"}'
Endon
I am able to simulate that proces by sending a message by Publish in MQTT Explorer. The data is picked up by the flow and send correctly to PVoutput.org..
Hopefully tomorrow I recieve the new SDM120M and in the mean time I can figure out how to edit the MQTT-node in NodeRED.. Or create a rule in ESPeasy for NodeRED..
The message I publish is for example:
Code: Select all
{{"pvpowerout": 130, "pvenergytoday": 2400}}
I must rearrange that in the rule I guess with some extra text. That is the goal for this evening.
Re: Send MQTT to different topics?
Just as a tip, you can easily test your strings by sending them to log using the command "logentry".
This also does all string replacements.
This also does all string replacements.
Code: Select all
//Publish,energy/goodwe,'{"command":"udevice","idx":2509,"nvalue":0,"svalue":"%eventvalue4%"}'
logentry,'{"command":"udevice","idx":2509,"nvalue":0,"svalue":"%eventvalue4%"}'
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests