geoffdavis / esphome-mitsubishiheatpump

ESPHome Climate Component for Mitsubishi Heatpumps using direct serial connection
BSD 2-Clause "Simplified" License
560 stars 153 forks source link

Make this usable as an `external_component` #28

Closed sijk closed 3 years ago

sijk commented 3 years ago

ESPHome v1.18.0 introduced external components which makes it easier to define custom components without having to use lambdas to create them. This pull request makes it possible to use this repository as an external component, which substantially simplifies the necessary configuration.

You can test it by adding the following to your config:

external_components:
  - source: github://sijk/esphome-mitsubishiheatpump@external_component

climate:
  - platform: mitsubishi_heatpump
    name: "Lounge heat pump"

Note that if you're modifying an existing config you should remove esphome.libraries and esphome.includes and also delete the build folder to avoid 'multiple definition' linker errors.

sijk commented 3 years ago

The changes in 65edd60 provide the fix requested in #19. The supported traits can be configured in YAML so there's no need to modify the source.

geoffdavis commented 3 years ago

@sijk Thanks! This is great! Let me do a quick review of it on my home system to make sure it doesn't completely blow up, but on the face of it the external_components feature is a huge step forward in terms of custom code usability.

geoffdavis commented 3 years ago

I just merged this into the development branch, and I'll work on cutting a new release as a 2.0 since this ends up being a pretty major API change (for the better.) Thanks again!

geoffdavis commented 3 years ago

@sijk Especially happy with your find on the UART to Serial conversion in components/climate.py - I literally spent days trying to figure out how to do that cleanly using ye olde custom component.