Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT "error" topic is not cleared after succesful transmission #20

Open
matthias-bs opened this issue Mar 11, 2023 · 2 comments
Open

MQTT "error" topic is not cleared after succesful transmission #20

matthias-bs opened this issue Mar 11, 2023 · 2 comments

Comments

@matthias-bs
Copy link

Hi Csongor,

if there was a Modbus communication error, e.g. error = Response timed out and communication is resumed normally, the MQTT topic "error" is not updated.

I think in ReadHoldingRegisters(), the "error" topic should also be updated if the condition (result == growattInterface.Success) is true (e.g. error = "none").

Besides, the message string should be put in double quotes, i.e. error = "Response timed out".

Regards
Matthias

@nygma2004
Copy link
Owner

Hi Matthias,

I was not planning to update the error topic with anything, after all once communication is up and running, you will start receiving messages in the data topic. Therefore the error topic keeps the data of the last reason the communication failed.

I am not sure what do you mean with double quotes, the message text is already in double quotes in the code.

Csongor

@matthias-bs
Copy link
Author

Hi Csongor,

You could have sporadic Modbus transmission errors, even after the communication was set up correctly.

The current output is error = Response timed out, but it should be error = "Response timed out", because the value is a string. (please compare to the other MQTT topics with strings) Most MQTT clients/JSON parsers seem to accept the former, but it could lead to problems with others.

To achieve this in the code, you can write

message = "\"" + message + "\""; 
mqtt.publish(topic, message.c_str());

Best regards,
Matthias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants