gysmo38 / mitsubishi2MQTT

Mitsubishi to MQTT with ESP8266 module
GNU Lesser General Public License v2.1
371 stars 132 forks source link

Add support for ESP32_S2_MINI, improve device support flexibility, improve debug logging and fix web control interface. #248

Open andrewleech opened 6 months ago

andrewleech commented 6 months ago

This MR contains a whole bunch of changes in separate commits, let me know if you'd prefer them split out into separate MR's.

This all started when I wanted to upgrade an older unit I had running and it took me a while to remember what hardware I used. I thought it'd be handy to show the correct / expected build on the firmware upgrade page, eg. image

I then wanted to test my changes on a separate esp32 module rather than the one tucked up in my aircon, but the only one I had handy was a newer esp32-s2, so I added support for that.

The default Serial object on the S3 is the internal USB port, not a uart. So I added support for specifying the desired UART via: build_flags = -DHVAC_UART=0

Finally I was having some more issues so wanted serial logging; now that hvac can be configured to run on a separate uart, I decided to make debug logging automatically enabled if HVAC is on a different uart to the default Serial output.

andrewleech commented 4 months ago

I've spent some time today fixing the web control interface, I had found on an older unit as well as this S2 based one that many commands from the web control page just didn't seem to stick, or ended up selecting the wrong thing.

settings updates in change_states() were failing as the String.c_str() values go out of scope too quickly. The scope of changes is now more tightly controlled.

The control web page now auto-refreshes when settings changes are received from the hvac unit, either from external changes, mqtt changes or just delayed responses to web changes.

This should also fix https://github.com/gysmo38/mitsubishi2MQTT/issues/182

andrewleech commented 4 months ago

ps. For anyone who wants to build this project without needing to install / configure PlatformIO I've got it building and flashing my esp32 board in docker with this little bash script:

IMAGE=shaguarger/platformio:6.1.9

if [ -z "$(docker ps -f "name=mitsubishi2mqtt" -f "status=running" -q )" ]; then

docker run --rm -d --name mitsubishi2mqtt -ti --privileged --net=host -v /dev:/dev \
  -v `pwd`:/workspace -w /workspace \
  $IMAGE sleep infinity

fi

docker exec -ti mitsubishi2mqtt pio run -e ESP32-S2-MINI -t upload
andrewleech commented 4 months ago

My S2 MINI build is bow installed in a HVAC unit and needed a couple of extra fixes, these are now included in this branch.

andrewleech commented 4 months ago

... But looking at the CI here, it appears some of my debug logging changes don't work on 8266, I'll have to look into that.

andrewleech commented 2 months ago

Ok all the compatibility issues have been resolved, this change set should now work well on all platforms. It's been tested and is in active use on two HVAC units, running the esp32 and esp32s2 builds. Web UI control works great now. I was previously also getting glitches with vane control from mqtt/ha on a previous release on esp32 which is also resolved with this build. The debug messages over mqtt also help quite a lot at times. The UART pins can also now be chosen for any platforms, but the default remains the same as official release / arduino default pins.