Blackymas / NSPanel_HA_Blueprint

This allows you to configure your complete NSPanel via Blueprint with UI and without changing anything in the code
1.44k stars 259 forks source link

`Bug` Not possible use as heating OR cooling climate. #2237

Open Andrecall opened 2 months ago

Andrecall commented 2 months ago

TFT Version

4.3.11

Firmware Version

4.3.11

Blueprint Version

4.3.11

Panel Model

EU

What is the bug?

I have a floor heating, which acts as a cooling in summer. System controller activates 220v output when it's in cooling mode("cross over function"). This output goes to all the standard thermostats in my apartment, so those switch from heating to cooling mode. The most important here that is all controlled using the same relay/valve, so the system can either heat or cool(when water pump pushes a cold water in pipes), both simultaneously are not possible.

I would like to replace a standard thermostat with the NS Panel and achieve more or less the same (It's clear, that NS Panel doesn't have a 220v input, but it could be some virtual switch or another esphome device with an input):

  1. Disable Heat_cool mode, only heat or cool should be available, not both at the same time
  2. Thermostat should be able to switch from heat to cool mode based on some condition or via HA, but not trough the NS Panel's UI

Could you tell, how could I achieve this?

Steps to Reproduce

No response

Your Panel's YAML

No response

ESPHome Logs

No response

Home Assistant Logs

No response

andythomas commented 3 weeks ago

Could you achieve that behavior in HA, i.e. not using the panel but the build-in climate thingies and other stuff that is available?

Andrecall commented 3 weeks ago

Could you achieve that behavior in HA, i.e. not using the panel but the build-in climate thingies and other stuff that is available?

Yes, this works perfectly fine with Dual Thermostat integration in Heat pump mode

edwardtfn commented 1 week ago

Hey, sorry for my relay in a reply here... I left it to later and for some reason I missed it.

Are you still looking for a solution for this?

So, this is not a trivial thing. I believe playing with the API a bit it would be possible to dynamically set the supported modes and with that restrict to the ones defined by an external sensor. Maybe as a redundancy we could try to set the mode which should be unavailable to do nothing when the external sensor is not on the desired state... this is probably a bit easier with some customization. Another challenge is related to a protection preventing the same relay to be assigned to both actions. In fact this is only generating an error message on log, but I'm not sure it prevents compiling. Anyways, I could easily replace it by a warning instead, but in this case you will have to wait for a new release, as this cannot be easily changed by a customization. 😞

Andrecall commented 1 week ago

Hey, sorry for my relay in a reply here... I left it to later and for some reason I missed it.

Are you still looking for a solution for this?

So, this is not a trivial thing. I believe playing with the API a bit it would be possible to dynamically set the supported modes and with that restrict to the ones defined by an external sensor. Maybe as a redundancy we could try to set the mode which should be unavailable to do nothing when the external sensor is not on the desired state... this is probably a bit easier with some customization. Another challenge is related to a protection preventing the same relay to be assigned to both actions. In fact this is only generating an error message on log, but I'm not sure it prevents compiling. Anyways, I could easily replace it by a warning instead, but in this case you will have to wait for a new release, as this cannot be easily changed by a customization. 😞

Hey! The natively supported solution in Blueprint would be perfect. As for now, I'm using the Dual Thermostat integration as a main way to control the underfloor heating/cooling, but I've also added some logic to esphome yaml of nspanel as a fallback solution. This check if nspanel is connected to HA and if not, turns on the integrated thermostat control, which does only supports heating. As you can see, it works, but not an ideal solution for sure

edwardtfn commented 1 week ago

Another challenge is related to a protection preventing the same relay to be assigned to both actions. In fact this is only generating an error message on log, but I'm not sure it prevents compiling. Anyways, I could easily replace it by a warning instead, but in this case you will have to wait for a new release, as this cannot be easily changed by a customization. 😞

I can confirm this is triggering an error message on the log, but it's not preventing it to work: https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/e146b1f35dfe38cd8d2da90828695f8a37865b0c/esphome/nspanel_esphome_addon_climate_base.yaml#L159

I will look in a different approach for a future release, but this is not blocking the use now (still pending some customization).

edwardtfn commented 1 week ago

How is the info about the heat pump working as a cooler available in Home Assistant? Do you have a binary sensor for this? Or any other type of entity with this info?

Andrecall commented 1 week ago

How is the info about the heat pump working as a cooler available in Home Assistant? Do you have a binary sensor for this? Or any other type of entity with this info?

Yes, I do have a simple binary sensor (it could be a helper as well, basically any binary sensor should work). Here is the link, how it could be configured in Dual Smart Thermostat for HA: https://github.com/swingerman/ha-dual-smart-thermostat?tab=readme-ov-file#heat-pump-one-switch-heatcool-mode

edwardtfn commented 1 week ago

I'm trying to do in a way you don't have to use Dual Smart Thermostat for HA... ;) But as I understood, you already have a sensor like the one used on their example, right?

heat_pump_cooling: sensor.study_heat_pump_state

I will try to make it simpler and will start playing as if you have a sensor binary_sensor.heat_pump_cooling which will be true when cooling and false when heating, ok!? Then later we see the best approach here.

Andrecall commented 1 week ago

Sure, that would be great to have a solution, which could work standalone, when HA is down for some reason. You're right, I do have a sensor binary_sensor.heat_pump_cooling ( I suppose it should be possible to select one in Blueprint/NS Panel settings). It's indeed "true" when cooling function is on

edwardtfn commented 1 week ago

I was exploring the API and I cannot set the modes dynamically (the method was implemented, but it isn't public, so cannot be accessed from ESPHome directly). It probably can be done with a customization to the climate component, but that is probably outside of the scope here and will require quite a lot of tests to be able to submit this new capability to ESPHome team. One thing we can do is to set the cooler action to do nothing if the heat pump is in heating mode, and set the heater action to do nothing when the heat pump is in the cooling mode. It will still offer the two options (heat/cooling), but one of the options will do nothing depending on the heat pump mode.

edwardtfn commented 1 week ago

I think I will get there... πŸ˜†

edwardtfn commented 1 week ago

Please try to set your panel with addon climate dual, same relay for both (for now this will trigger an error message on log, but you can ignore that). Also, please add this to your panel's yaml and flash it:

select:
  - id: heat_pump_mode
    name: Heat pump mode
    platform: template
    optimistic: true
    options:
      - Heating
      - Cooling
    initial_option: Heating
    restore_value: true
    set_action:
      then:
        - if:
            condition:
              - lambda: return x == "Cooling";
            then:
              - lambda: |-
                  ESP_LOGI("select.heat_pump_mode", "Setting cooling only mode supported");
                  thermostat_embedded->set_supports_cool(true);
                  thermostat_embedded->set_supports_heat(false);
                  thermostat_embedded->set_supports_heat_cool(false);
                  thermostat_embedded->setup();
              - delay: 2s
              - climate.control:
                  id: thermostat_embedded
                  mode: COOL
            else:
              - lambda: |-
                  ESP_LOGI("select.heat_pump_mode", "Setting heating only mode supported");
                  thermostat_embedded->set_supports_heat(true);
                  thermostat_embedded->set_supports_cool(false);
                  thermostat_embedded->set_supports_heat_cool(false);
                  thermostat_embedded->setup();
              - delay: 2s
              - climate.control:
                  id: thermostat_embedded
                  mode: HEAT
        - delay: 2s
        - lambda: |-
            thermostat_embedded->dump_config();

Please try to change the mode with the new drop-down on the device's page (under Settings > Devices & services > ESPHome), wait like 5min and let me know if the supported modes changes.

if that works, I can look for a better implementation where it can follow the selected mode from boot time.

edwardtfn commented 1 week ago

You can force a reload using this:

action: homeassistant.reload_config_entry
target:
  entity_id: climate.office_workstation_panel_thermostat
Andrecall commented 1 week ago

I was exploring the API and I cannot set the modes dynamically (the method was implemented, but it isn't public, so cannot be accessed from ESPHome directly). It probably can be done with a customization to the climate component, but that is probably outside of the scope here and will require quite a lot of tests to be able to submit this new capability to ESPHome team. One thing we can do is to set the cooler action to do nothing if the heat pump is in heating mode, and set the heater action to do nothing when the heat pump is in the cooling mode. It will still offer the two options (heat/cooling), but one of the options will do nothing depending on the heat pump mode.

Sorry for a bit late reply. The main problem with such approach, that I would still see 2 sliders in NS Panel UI (as well as in HA climate entity for NS Panel). The second issue would be necessity to set up both temperatures required in cool_heat capable thermostat (and it is actually even worse: you can't set up heating temperature lower than cooling temperature, which makes sense but not for cool_OR_heat system, where this is exactly opposite)

Andrecall commented 1 week ago

Please try to set your panel with addon climate dual, same relay for both (for now this will trigger an error message on log, but you can ignore that). Also, please add this to your panel's yaml and flash it:

select:
  - id: heat_pump_mode
    name: Heat pump mode
    platform: template
    optimistic: true
    options:
      - Heating
      - Cooling
    initial_option: Heating
    restore_value: true
    set_action:
      then:
        - if:
            condition:
              - lambda: return x == "Cooling";
            then:
              - lambda: |-
                  ESP_LOGI("select.heat_pump_mode", "Setting cooling only mode supported");
                  thermostat_embedded->set_supports_cool(true);
                  thermostat_embedded->set_supports_heat(false);
                  thermostat_embedded->set_supports_heat_cool(false);
                  thermostat_embedded->setup();
              - delay: 2s
              - climate.control:
                  id: thermostat_embedded
                  mode: COOL
            else:
              - lambda: |-
                  ESP_LOGI("select.heat_pump_mode", "Setting heating only mode supported");
                  thermostat_embedded->set_supports_heat(true);
                  thermostat_embedded->set_supports_cool(false);
                  thermostat_embedded->set_supports_heat_cool(false);
                  thermostat_embedded->setup();
              - delay: 2s
              - climate.control:
                  id: thermostat_embedded
                  mode: HEAT
        - delay: 2s
        - lambda: |-
            thermostat_embedded->dump_config();

Please try to change the mode with the new drop-down on the device's page (under Settings > Devices & services > ESPHome), wait like 5min and let me know if the supported modes changes.

if that works, I can look for a better implementation where it can follow the selected mode from boot time.

Sure, will try this out and let you know. Hope esp32 could handle this together with bt proxy and directly connected bt temperature sensor (btw., which works rock solid and could be included in a standard release of the Blueprint)

Andrecall commented 1 week ago

Ok, the switch/selection, you've built in, seems to work as expected. It always reverts to "heat" if I try to select "heat_cool" in climate settings. I've also tried the same approach with an automation on HA side, which did more or less the same: prohibit usage of heat_cool mode and reverts back to previous state if heat_cool was selected. But as I mentioned 1 post earlier, this still uses cool_heat UI with all the disadvantages like "you can't set up heating temperature lower than cooling temperature" image

edwardtfn commented 1 week ago

It should be able to handle all of that, but you should expect the system working a bit warmer, which will reflect on its embedded temperature sensor measurements.

Andrecall commented 1 week ago

It should be able to handle all of that, but you should expect the system working a bit warmer, which will reflect on its embedded temperature sensor measurements.

Yes, I've successfully updated the firmware and NS started without any problems. Your extended logic works fine, but there are some quirks as I mentioned 1 or 2 messages earlier: 1) I still see 2 sliders in NS Panel UI (as well as in HA climate entity for NS Panel) 2) It is now required to set up both temperatures as in cool_heat capable thermostat 3) And the worst here: you can't set up heating temperature lower than cooling temperature, which makes no sense for cool_OR_heat system

edwardtfn commented 1 week ago

Ok, I will look at that. It should be requiring a single target temperature...