From 34c22a96934f331b7da6832982532fe7eb0c3d97 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 20:17:33 +0000 Subject: [PATCH 1/3] Initial plan From 409567d8243e57a93297ccb4a1b3202a9ceadf46 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 20:29:42 +0000 Subject: [PATCH 2/3] Add documentation and API endpoint for Home Assistant serial port connection Co-authored-by: rvdbreemen <8645876+rvdbreemen@users.noreply.github.com> --- README.md | 26 ++++++++++++++++++++++++-- restAPI.ino | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ffda78f..f83cfbd 100644 --- a/README.md +++ b/README.md @@ -34,20 +34,42 @@ The features of this Nodosop OpenTherm Gateware ESP8266 based firmware are: - parsing the OT protocol on the ESP8266 - parsing all known OT protocol message ID's (OpenTherm v2.2+2.3b), including Heating/Ventilation and Remeha specific msgid's - wide range of connection and data sharing options: - - telnet (interpreted data and debugging) + - telnet on port 23 (interpreted data and debugging) - MQTT (publishing every parsed OT message, publish commands to this topic `OTGW/set//command`) - simple REST GET API (`http:///api/v0/otgw/{id}`) - simple REST GET API (`http:///api/v1/otgw/id/{id}` or `http:///api/v1/otgw/label/{textlabel eg. Tr or Toutside}` - simple REST PUT or POST commands on `/api/v1/otgw/command/{any command})` - serial interface on port 25238 for original OTmonitor application (bi-directional) - OTmonitor Web UI (standalone interface) -- automatic integration with Home Assistant using _Home Assistant Discovery_ (Home Assistant Core v2021.2.0+) +- automatic integration with Home Assistant using _Home Assistant Discovery_ (Home Assistant Core v2021.2.0+) via MQTT +- alternative Home Assistant integration using the [OpenTherm Gateway integration](https://www.home-assistant.io/integrations/opentherm_gw/) with connection type `socket://:25238` - integration with any MQTT based Home Automation solution, like Domoticz (plugin available) & OpenHAB - reliable OTGW PIC upgrades (v0.6.0+), to the latest firmware available at http://otgw.tclcode.com/download.html - cleaner RestAPI's for Telegraf OTmonitor integration - readout Dallas-type temperture sensors (eg. DS18B20) connected to GPIO, added automatic Home Assistant Discovery - readout S0 output counter and timing from kWh meter connected to configurable GPIO - Enhance Home Assistant discovery for Dallas sensors and S0 output counter + +## Connectivity Options + +This firmware provides multiple ways to connect and interact with your OpenTherm Gateway: + +| Port | Protocol | Purpose | Usage | +|------|----------|---------|-------| +| 80 | HTTP | Web Interface & REST API | Access the configuration interface at `http://` | +| 23 | Telnet | Debug & Logging | Connect for real-time debugging: `telnet ` | +| 25238 | Serial over TCP | OTGW Serial Interface | For OTmonitor app or Home Assistant OpenTherm Gateway integration: `socket://:25238` | +| MQTT | MQTT | Home Automation Integration | Recommended for Home Assistant (auto-discovery enabled) | + +### Home Assistant Integration + +There are two ways to integrate with Home Assistant: + +1. **Recommended: MQTT Auto-Discovery** - Configure MQTT settings in the web interface. Home Assistant will automatically discover all sensors and controls. + +2. **Alternative: OpenTherm Gateway Integration** - Use Home Assistant's [OpenTherm Gateway integration](https://www.home-assistant.io/integrations/opentherm_gw/) with the connection string: `socket://:25238` (where `` is your device's IP address). + + **Important:** Use port `25238`, not port `23`. Port 23 is for debugging only and will not work with the Home Assistant integration. **Warning: Never flash your OTGW PIC firmware through wifi using OTmonitor application, you can brick your OTGW PIC. Instead use the buildin PIC firmware upgrade feature (based on code by Schelte Bron)** diff --git a/restAPI.ino b/restAPI.ino index 7c1595b..3bbc51c 100644 --- a/restAPI.ino +++ b/restAPI.ino @@ -339,6 +339,7 @@ void sendDeviceInfo() sendNestedJsonObj("hostname", CSTR(settingHostname)); sendNestedJsonObj("ipaddress", CSTR(WiFi.localIP().toString())); sendNestedJsonObj("macaddress", CSTR(WiFi.macAddress())); + sendNestedJsonObj("serialtcpport", OTGW_SERIAL_PORT); sendNestedJsonObj("freeheap", ESP.getFreeHeap()); sendNestedJsonObj("maxfreeblock", ESP.getMaxFreeBlockSize()); sendNestedJsonObj("chipid", CSTR(String( ESP.getChipId(), HEX ))); From 836034d141341c1a0a03b8c279dc469baaf4129a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 20:34:47 +0000 Subject: [PATCH 3/3] Add connection information display in WebUI device info page Co-authored-by: rvdbreemen <8645876+rvdbreemen@users.noreply.github.com> --- data/index.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/data/index.js b/data/index.js index 5ad5ea6..e0a8235 100644 --- a/data/index.js +++ b/data/index.js @@ -425,13 +425,41 @@ fetch(APIGW+"v0/devinfo") .then(response => response.json()) .then(json => { - console.log("then(json => ..)"); + console.log("then(json => ..")"); //console.log("parsed .., data is ["+ JSON.stringify(json)+"]"); data = json.devinfo; + + // Add connection info header if it doesn't exist yet + var deviceinfoPage = document.getElementById('deviceinfoPage'); + if (!document.getElementById("connection_info_header")) { + var infoDiv = document.createElement("div"); + infoDiv.setAttribute("id", "connection_info_header"); + infoDiv.setAttribute("class", "devinforow"); + infoDiv.style.background = "#e8f4f8"; + infoDiv.style.padding = "10px"; + infoDiv.style.marginBottom = "10px"; + infoDiv.style.border = "1px solid #b0d4e0"; + infoDiv.style.borderRadius = "4px"; + + var ipAddress = ""; + var serialPort = ""; + for (let i in data) { + if (data[i].name === "ipaddress") ipAddress = data[i].value; + if (data[i].name === "serialtcpport") serialPort = data[i].value; + } + + infoDiv.innerHTML = "Connection Information:
" + + "• Web Interface: http://" + ipAddress + "
" + + "• Telnet (Debug): telnet " + ipAddress + " 23
" + + "• Serial (OTmonitor/HA): socket://" + ipAddress + ":" + serialPort + "
" + + "For Home Assistant OpenTherm Gateway integration, use the Serial connection string above."; + + deviceinfoPage.insertBefore(infoDiv, deviceinfoPage.firstChild); + } + for( let i in data ) { console.log("["+data[i].name+"]=>["+data[i].value+"]"); - var deviceinfoPage = document.getElementById('deviceinfoPage'); if( ( document.getElementById("devinfo_"+data[i].name)) == null ) { // if element does not exists yet, then build page var rowDiv = document.createElement("div"); @@ -758,6 +786,7 @@ ,[ "HostName", "Hostname (add .local)"] ,[ "ipaddress", "IP address"] ,[ "macaddress", "MAC address"] + ,[ "serialtcpport", "Serial TCP Port (for HA/OTmonitor)"] ,[ "freeheap", "Free Heap Mem (bytes)"] ,[ "maxfreeblock", "Max. Free Mem (bytes)"] ,[ "chipid", "Unique Chip ID"]