geoffdavis / esphome-mitsubishiheatpump

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

Some questions about responsivness and fan and wane settings #2

Closed jascdk closed 4 years ago

jascdk commented 4 years ago

Hi Geoff.

I now managed to get the heatpump up and running with ESPHOME - thanks alot for putting your effort in to getting this to work:D

I experience some kind of long responsivness when i change temperature, modes. I see you write instant responsivness in your readme. How fast does your system response?

The next thing i came to think of is if it possible to get a feedback on the state of the heatpump in the UI. It always says it is off, when the heatpump is actually running / heating.

Before mowing to ESPHOME i used the code made by gysmo38. It is also a very nice code, but i had some issues with it. In his code it is possible to set the fan to other states - like QUIET and so on. I cant see this in this integration - it goes from Auto, low medium middle and high.

The same thing is with the VANE. In gysmos code there was different modes and also a SWING mode.

Is it something that needs to be put in the code or does ESPHOME not support it?

All the best

Jacob from denmark

jascdk commented 4 years ago

This is taken from the code at Gysmos repo:

Here is some examples of the states of the fan and vane:

https://pastebin.com/rNznHWEB

if (strcmp(settings.fan, "AUTO") == 0) { 700 controlPage.replace("_FANA", "selected"); 701 } 702 else if (strcmp(settings.fan, "QUIET") == 0) { 703 controlPage.replace("_FANQ", "selected"); 704 } 705 else if (strcmp(settings.fan, "1") == 0) { 706 controlPage.replace("_FAN1", "selected"); 707 } 708 else if (strcmp(settings.fan, "2") == 0) { 709 controlPage.replace("_FAN2", "selected"); 710 } 711 else if (strcmp(settings.fan, "3") == 0) { 712 controlPage.replace("_FAN3", "selected"); 713 } 714 else if (strcmp(settings.fan, "4") == 0) { 715 controlPage.replace("_FAN4", "selected"); 716 } 717

718 controlPage.replace("_VANEV", settings.vane); 719 if (strcmp(settings.vane, "AUTO") == 0) { 720 controlPage.replace("_VANEA", "selected"); 721 } 722 else if (strcmp(settings.vane, "1") == 0) { 723 controlPage.replace("_VANE1", "selected"); 724 } 725 else if (strcmp(settings.vane, "2") == 0) { 726 controlPage.replace("_VANE2", "selected"); 727 } 728 else if (strcmp(settings.vane, "3") == 0) { 729 controlPage.replace("_VANE3", "selected"); 730 } 731 else if (strcmp(settings.vane, "4") == 0) { 732 controlPage.replace("_VANE4", "selected"); 733 } 734 else if (strcmp(settings.vane, "5") == 0) { 735 controlPage.replace("_VANE5", "selected"); 736 } 737 else if (strcmp(settings.vane, "SWING") == 0) { 738 controlPage.replace("_VANES", "selected"); 739 } 740

741 controlPage.replace("_WIDEVANEV", settings.wideVane); 742 if (strcmp(settings.wideVane, "<<") == 0) { 743 controlPage.replace("_WVANE1", "selected"); 744 } 745 else if (strcmp(settings.wideVane, "<") == 0) { 746 controlPage.replace("_WVANE2", "selected"); 747 } 748 else if (strcmp(settings.wideVane, "|") == 0) { 749 controlPage.replace("_WVANE3", "selected"); 750 } 751 else if (strcmp(settings.wideVane, ">") == 0) { 752 controlPage.replace("_WVANE4", "selected"); 753 } 754 else if (strcmp(settings.wideVane, ">>") == 0) { 755 controlPage.replace("_WVANE5", "selected"); 756 } 757 else if (strcmp(settings.wideVane, "SWING") == 0) { 758 controlPage.replace("_WVANES", "selected"); 759 }

DeltaAngle commented 4 years ago

The fan and swing modes in Geoff's code are based on the supported functions in the ESPHome Dev branch. You can see these documented here, https://next.esphome.io/components/climate/index.html. ESPHome would need to be updated to support the numerical fan speed, vane swing, and wide vane swing settings.

jascdk commented 4 years ago

@DeltaAngle Ahhh thanks - that makes sense;)

Any thoughts on the responsiveness?

geoffdavis commented 4 years ago

The lack of responsiveness is likely due to the polling loop only running once every two seconds. You might get it to be more responsive by fiddling with the value for _pollinterval - decrease that from the default of 2000 milliseconds to 1000 and see if it works any better. In your lambda, declare it like auto my_heat_pump = new HeatPump(&Serial, 1000); in your lambda.

(Code that implements is here)

A possibly better solution would be to convert to callbacks but I was unable to get those to work during my development, and just wanted to get this thing out the door.

geoffdavis commented 4 years ago

As for the different fan modes, @DeltaAngle nailed it on the head.

I'd love to get the custom modes like gysmo's implementation, but I haven't figured out how to override the ESPHome definitions. There seems to be a lot of work that would have to happen in the ESPHome code base in order to provide custom fan levels, as the conversation between ESPHome and HomeAssistant is pretty heavily locked down. There may be a way to make it work akin to how the FastLED component lets you declare "lamba modes", but that's likely a whole lot of development work.

geoffdavis commented 4 years ago

@jascdk I did some experiments with the refresh interval, and found that:

Watching the logs, it appears that the heat pump doesn't report a changed state until the fan vanes open. In particular, if the unit is off, and you turn it on, the HeatPump won't report the change over it's serial port until the slats open up. This can take up to 10 seconds.

So that's one mode of slowness.

The other sluggish part is the temperature changes. I have a feeling that getting the callbacks working is going to help that. Right now, the code sends an update to Home Assistant every polling loop. My theory is that the constant stream of state changes is too much for HomeAssistant, either in the core (not likely) or in the web front end components. By converting to callbacks, update messages would only be sent to home assistant IF something changed. I'll see if I can get that functionality working.

geoffdavis commented 4 years ago

Release 1.1.0 addresses the responsiveness issue.

I got callbacks to work (turns out that my initialization fixes had fixed all of the crashes I was seeing with the callbacks), and increased the polling interval from 2 seconds to 500 ms. The web interface is much snappier, and your temperature graphs shouldn't be as large now due to it only including data points when things change rather than every update.

Please try it out and let me know if you see any problems in a new ticket.

Thanks!

jascdk commented 4 years ago

Release 1.1.0 addresses the responsiveness issue.

I got callbacks to work (turns out that my initialization fixes had fixed all of the crashes I was seeing with the callbacks), and increased the polling interval from 2 seconds to 500 ms. The web interface is much snappier, and your temperature graphs shouldn't be as large now due to it only including data points when things change rather than every update.

Please try it out and let me know if you see any problems in a new ticket.

Thanks!

Hi Geoff:)

That did make an hell of a difference instead of the old one:) Nice that you got it working out! If I have other issues I will get back to you. I have put this repo on my watch list, so I can keep up with eventually other updates! Nice work Geoff!!!!