Skip to content

MQTT Interoperability: cmd/result JSON format and 'ramses_rf' compatibility #39

@PWhite-Eng

Description

@PWhite-Eng

Hi Peter / @IndaloTech,

I am currently working on the ramses_cc Home Assistant integration (specifically ramses-rf/ramses_cc#483), adding native support for Home Assistant's MQTT service as a transport layer.

During the code review of the ramses_esp MQTT implementation (specifically in ramses-mqtt.c), we identified an interoperability hurdle that affects how standard libraries like ramses_rf interact with the firmware via MQTT.

The Observation

In components/ramses-mqtt/ramses-mqtt.c, the mqtt_publish_cmd_result function formats the JSON payload using an integer for the return code:

// Current implementation
sprintf( data, "{ \"cmd\":\"%s\", \"err\":\"%s\", \"return\":%d} ",cmd, esp_err_to_name(err),retVal );

This results in a payload like: {"cmd": "!V", "return": 0}.

The Issue

Most RAMSES client libraries (including ramses_rf) are designed to interact with a serial port, where they expect the response to a command (like !V) to be a specific string (e.g., # evofw3 0.7.1).

When ramses_esp returns an integer 0 via MQTT:

  1. Type Mismatch: Clients expecting a string response may crash or fail to parse the integer.
  2. Handshake Failure: The !V command is critical for identifying the gateway. If the client receives 0 instead of a string containing # evofw3..., it assumes the gateway is invalid and aborts the connection.

Suggestion

To improve compatibility with the broader ecosystem, would you consider updating the MQTT response to include the actual console output or version string in the JSON payload?

For example, returning the string value would allow the MQTT transport to act as a transparent bridge for existing libraries:

JSON

{
  "cmd": "!V",
  "return": "# evofw3 0.7.1"
}

We have implemented a workaround in the ramses_cc client side for now (synthesizing a fake handshake when we see return: 0), but a fix at the firmware level would make ramses_esp plug-and-play compatible with more Home Assistant integrations out of the box.

Thanks

Phil / @PWhite-Eng

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions