How to publish / send a mqtt message IP Symcon

Hi,

I am trying to figure out how to publish a mqtt message from IP Symcon and I have searched the forum but without finding the pieces I need to put it all together.

I have an ESP8266 that controls 2 relayes that I would like to control from IPS.

On the ESP8266 I have installed ESP Easy and set up mqtt.

In IPS I have added MQTT server (and MQTT client).

I can send mqtt messages from ESP8266 and they are received in IPS.

My problem is that I have no idea how to send a mqtt message from IPS to ESP8266 (or anything else for that matter)!

In IPS I have a boolean variable with a on off toggle switch (that shows up in the WebFront) but how do I send true and false over mqtt from it?

I am totally lost her so any pointers would be appreciated!

yoggi

That’s a good start. Is it also a boolean? If yes, can you see it in the WebFront? Normally you already should be able to switch directly there and after switching it should send the new values through MQTT.

paresy

Hi paresy,

Thanks for the pointer!

The ESP8266 is returning 0 or 1 for GPIO 14, the pin that the relay is connected to. The variable that shows up in ISP is of type string… how and where do you suggest that I turn it into a boolean (true or false)?

If I get the ESP8266 to return true or false will it then show up as a boolean in IPS?

yoggi

Just open up the instance configuration for your MQTT topic. You can then change the type to boolean and IP-Symcon should happily cast it. Then attach a valid variable profile and the WebFront/App will do the rest.

paresy

Hi again,

I am a bit closer, at lest I think so.

I have managed to change the incoming string (0 or 1) to boolean so now when GPIO 14 on the ESP8266 is activated and the relay connects this gets reflected by the switch in the IPS WebFront (it switches between On an Off when GPIO 14 is activated and deactivate). In this case I am using a http command to activate and deactivate the GPIO.

So mqtt message from ESP8266 gets to IPS.

The remaining problem is, if I toggle the switch in IPS WebFront nothing happens. No mqtt message is sent back. I have watched the log of ESP Easy and I have tried using MQTTX client connected to IPS mqtt server but it would appear that no mqtt message is sent from IPS.

I must be missing something fundamental regarding how mqtt works in IPS. I have tried to search the forum (including the German section with Google translate) but I have not found something I could use.

What am I missing?

yoggi

PS
I have looked at this post, do I need some php script in order to send a mqtt message when the boolean variable changes?

MiLight über ESP8266 - IP-Symcon 4.x/5.x/6.x / PHP-Module (Diskussion) - IP-Symcon Community

Hi paresy,

If I look at DEBUG: MQTT Server under Splitter Instances when a mqtt message (received by IPS) is received I see that the reply (TX) is skipped on purpose (see below). Yes it makes sense to rebroadcast/forward the message to the sender but could this skipp function allows affect mqtt messaging that should be sent, e.g. from the WebFront when the On Off is toggled?

03/12/2022, 09:57:45 PM | MQTT:RX:PUBLISH | Topic: Bee_Easy/MQTT_Switch/StateOnOff, Payload: 1

03/12/2022, 09:57:45 PM | MQTT:TX:PUBLISH (Forward) | Skipped sending to Bee_Easy_1 (192.168.8.200:62673)

Information: IPS 6.0 Pro on a Raspberry Pi 5.10.63-v7+

IP-Symcon 6.0, Raspberry Pi (armhf), 08/28/2021, 883beea87a99

This skipping makes sure that we do not end up with an endless loop. When toggling from the WebFront you should clearly see messages going out. Are you sure that your ESP device subscribed to the topic?

paresy

Hi paresy,

I eventually got it to work, I dropped ESP Easy in favor of the Arduino framework and the pubsubclient library that works with ESP8266. I did the coding in Visual Studio Code IDE with PlatformIO extension. Actually not to hard at all and not much code was needed to get it to work.

The problem I had was that I couldn’t get ESP easy to react to topic from IP Symcons mqtt. I eventually found out that IP Symcon was indeed sending a mqtt message when the on/off switch was toggle but I needed a separate mqtt client to verify this (I used MQTTX for this).

As a beginner it was hard to understand where the problem was, were in the chain it went wrong.

Maybe I would have been helped if IP Symcon would have listed outgoing mqtt messages in some way, maybe in a debug window/mode.

yoggi

1 „Gefällt mir“

Is there any reason why you don’t use tasmota firmware with the ESP?

There is everything already included and you can use the tasmota modul for switching.