$ show gysmo38/mitsubishi2MQTT
This repository provides firmware for ESP8266/ESP32 microcontrollers to interface Mitsubishi Heat Pumps (HVAC units) with MQTT and Home Assistant. The firmware runs on the ESP board, which connects to the heat pump's serial interface using the SwiCago/HeatPump library, and exposes a web interface for configuration and control, as well as MQTT topics for integration with smart home systems. It supports Home Assistant MQTT auto-discovery, Prometheus metrics, OTA firmware updates, and multi-language web UI. The architecture is a monolithic Arduino sketch with separate header files for configuration, HTML templates, JavaScript, and language strings. Key entry points are the setup() and loop() functions in mitsubishi2mqtt.ino, which initialize WiFi, MQTT, the heat pump connection, and a web server. Data flows: the ESP reads heat pump status via serial, publishes state to MQTT, subscribes to command topics, and serves a web control panel. External dependencies include the HeatPump library, ArduinoJson, PubSubClient, and the ESP8266/ESP32 Arduino core.
The LLM identified 2 files worth highlighting for reuse:
The `toFahrenheit` and `toCelsius` functions implement temperature conversion using a lookup table for specific mappings (e.g., 16.0°C -> 61°F) and fall back to standard formulas. This pattern is isolated, self-contained, and could be extracted into a standalone utility for any project requiring precise temperature unit conversion with known device mappings.
This header defines a Prometheus metrics endpoint template (`html_metrics`) that exposes heat pump state as gauge metrics. It is a clean, reusable pattern for adding Prometheus exposition to any ESP-based project by simply replacing placeholder variables. The template is self-contained and demonstrates a non-obvious integration of Prometheus with constrained devices.