{"id":24508400,"url":"https://github.com/opendds/opendds-mqtt-examples","last_synced_at":"2025-03-15T09:20:41.640Z","repository":{"id":90793228,"uuid":"480721930","full_name":"OpenDDS/opendds-mqtt-examples","owner":"OpenDDS","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-15T22:05:06.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-22T00:15:49.175Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenDDS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-12T08:36:05.000Z","updated_at":"2022-12-23T17:13:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed582679-f828-49f7-a973-b0e4519adc7a","html_url":"https://github.com/OpenDDS/opendds-mqtt-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenDDS%2Fopendds-mqtt-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenDDS%2Fopendds-mqtt-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenDDS%2Fopendds-mqtt-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenDDS%2Fopendds-mqtt-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenDDS","download_url":"https://codeload.github.com/OpenDDS/opendds-mqtt-examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243707893,"owners_count":20334718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-22T00:15:54.565Z","updated_at":"2025-03-15T09:20:41.614Z","avatar_url":"https://github.com/OpenDDS.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Examples of Bridging OpenDDS and MQTT to Control Tasmota Smart Devices\n\nThese are examples of bridging data between DDS and MQTT using\n[OpenDDS](https://opendds.org) and [Eclipse Paho\nC++](https://github.com/eclipse/paho.mqtt.cpp) to control [Tasmota smart\ndevices](https://tasmota.github.io/docs/). This is discussed in this [Object\nComputing Inc Middleware News Brief Article](https://objectcomputing.com/resources/publications/mnb/2022/06/01/bridging-opendds-and-mqtt-messaging).\n\n## Requirements\n\nBuilding the examples requires OpenDDS and CMake. Running the examples requires\na MQTT broker to be setup and at least one Tasmota device connected to the\nbroker that supports power on/off and power usage reporting functionality.\n\n## Building\n\nAssuming OpenDDS is available in the environment, then building is the same as\nany normal CMake project:\n\n```\ncmake -S . -B build\ncmake --build build\n```\n\nPaho C and C++ libraries are included as git submodules and will be built and\nused automatically. To skip this and use another set of Paho libraries, pass\n`-DBUILD_PAHO=FALSE` to the CMake configure command.\n\n## Running\n\nBoth examples consist of a MQTT relay that has to be connected to a MQTT broker\nand a controller OpenDDS-only application that communicates with the MQTT relay\nusing DDS.\n\n### `generic-relay` Example\n\n`generic-relay` and `tasmota-toggle` use a direct mapping between MQTT and DDS\nmessages. This consists of two DDS topics to send and receive from MQTT. The\ntopics share the same topic type that consist of the MQTT topic name and the\nmessage contents as a string. See\n[`common/MqttMessage.idl`](common/MqttMessage.idl) for the `MqttMessage` type.\n\n[`generic-relay`](generic-relay/generic-relay.cpp) receives MQTT messages and\nwrites them to the DDS topic and vice versa. It has no knowledge of how Tasmota\nworks, the contents are only interpreted by `tasmota-toggle`.\n[`tasmota-toggle`](generic-relay/tasmota-toggle.cpp) gets the on/off status of\neach Tasmota device it discovers, then sends a message to toggle it. This could\nbe done without getting the on/off status, as Tasmota has a way to toggle the\npower directly, but this is done for showing an example of a back and forth\ndata exchange.\n\n```\n./build/generic-relay/generic-relay 127.0.0.1 \u0026\n./build/generic-relay/tasmota-toggle\n```\n\n### `idl-relay` Example\n\n`idl-relay` and `tasmota-power` use a more complex mapping between MQTT\nmessages and DDS messages. It also uses two topics, but the type are specific\nto how the topics will be used. See [`common/tasmota.idl`](common/tasmota.idl)\nfor the `Power` and `Wattage` types.\n\n[`idl-relay`](idl-relay/idl-relay.cpp) is similar to the `tasmota-toggle`\napplication in that it is trying to discover Tasmota devices, but it's doing\nthis using MQTT directly and then getting and writing the wattage usage the\ndevices to a DDS topic. It will send power on/off commands to the device if\nanother DDS topic call for that. [`tasmota-power`](idl-relay/tasmota-power.cpp)\ntakes a wattage limit and reads the DDS topic for wattage usage and for every\ndevice that pushes the total wattage over the argument, it shuts off that\ndevice using the other DDS topic.\n\n```\n./build/idl-relay/idl-relay 127.0.0.1 \u0026\n./build/idl-relay/tasmota-power 100\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopendds%2Fopendds-mqtt-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopendds%2Fopendds-mqtt-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopendds%2Fopendds-mqtt-examples/lists"}