Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Climate control trigger, lambdas in binary sensor delay filters, deduplicator helper changes #5024

Closed
wants to merge 6 commits into from

Conversation

dudanov
Copy link
Contributor

@dudanov dudanov commented Jun 29, 2023

What does this implement/fix?

  1. Lambda functions in a trigger climate.on_control now get a reference to the control object ClimateCall, which can be modified. It useful, for example, implement automatic condensate purge at shutdown.
climate:
  - platform: ...
    on_control:
      - lambda: |-
          if (x.get_mode() != CLIMATE_MODE_OFF) {
              id(turnoff_script).stop();
              return;
          }
          if (id(condensate_sensor).state) {
              id(turnoff_script).execute();
              x.set_mode(CLIMATE_MODE_FAN_ONLY);
          }
  1. Binary sensor delay filters now can be configured with template parameters similar to the delay action.
binary_sensor:
  - platform: ...
    filters:
      - delayed_on_off: !lambda "return id(drying_delay).state * 1000;"
  1. Changed the deduplicator class by applying the optional<T> class. Added a method optional<std::pair<T, T>> next_change(const T &value) for returning a optional pair of (previous, current) values.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#3030

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@dudanov dudanov marked this pull request as ready for review June 29, 2023 11:29
@probot-esphome
Copy link

Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration (binary_sensor) you are listed as a code owner for? Thanks!
Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration (climate) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@ssieb
Copy link
Member

ssieb commented Jun 29, 2023

Don't combine multiple changes in one PR. Each one needs to be separate, especially since these are all potentially controversial changes.

@dudanov
Copy link
Contributor Author

dudanov commented Jun 30, 2023

Don't combine multiple changes in one PR. Each one needs to be separate, especially since these are all potentially controversial changes.

Thank you for your advice. Corrected. Divided into three PRs:

  1. Fix binary_sensor initial state filters bug #5026
  2. climate triggers Climate and ClimateCall references #5028
  3. binary_sensor filters templatable delays #5029

@dudanov dudanov deleted the climate-230728 branch June 30, 2023 06:16
@github-actions github-actions bot locked and limited conversation to collaborators Jul 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants